On Fri, Apr 26, 2002 at 06:54:37AM +0200, Oliver Neukum wrote:
> > > Devfs goes the whole way.
> > > Let's look at the basic function of major:minor combinations.
> > > You use them to assign names and permissions to a device.
> > > If minors become dynamic minors no longer have any function,
> > > you are better of eliminating them.
> >
> > I would love to eliminate minors, but can't due to the current system.
> > If the core of the kernel that handles major/minor numbers changes, then
> > I will change USB to match that. But for today, this is what is needed
> > for large number of devices.
>
> Partially. In a machine with a few PCI slots, you still could overwhelm
> the new scheme. As I see it, you still are working around an issue.
Yes, I'm working around the current 16 device limit issue. Yes I push
that limit out to 256, but that's a workable limit for today. If I
wanted to abolish minor numbers all together, I could get an unlimited
number of devices, but this tiny little patch does not do that, nor
attempt to do that. It is working within today's system.
If you have a better solution for the original (16 devices) problem,
please let me know.
> > > What is the loop supposed to do then ?
> > > It has some comments about looking internally for a minor.
> >
> > That loop executes if CONFIG_USB_DYNAMIC_MINORS is NOT enabled. It's
> > the existing way of finding a minor number for a device. I'm not
> > changing that logic at all, just moving it within a if() call. This
> > way, if CONFIG_USB_DYNAMIC_MINORS is not enabled, the driver falls back
> > to the original way of handling its minors.
>
> But you do. That loop will trigger in the error case and happily assign
> any random number. If you are responsible for an #IFDEF , don't hide it.
> In other words, run out of minors and you are screwed.
Ah, good point. How's the patch attached to this message? It documents
the different return values, and shows how to handle the return values
properly.
> > Remember, devfs does not remove our need for minor numbers. It just
>
> But it handles them dynamically. Which is the best you can do
> with the present architecture. I repeat, a dynamic minor makes
> the concept of a minor meaningless and reduces it to feature
> of backwards compatibility.
devfs does not handle the existing USB numbers dynamically. Or am I
missing something? I still see the 16 devices limitation in the USB
core.
> > imposes a naming scheme on the kernel for the major/minor pairs that
> > happen to be present in the system at a moment in time. This patch is
> > still needed to extend our usage of the USB minor range.
>
> If you did use devfs to the extent it can be used, you could have 256
> devices of all types.
Please explain. How could this be done within today's framework? And
remember, 99.9% of all machines do not use devfs today :) This patch
solves a real problem for all machines, without requiring people to use
devfs.
thanks,
greg k-h
diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
--- a/drivers/usb/core/usb.c Fri Apr 26 14:10:31 2002
+++ b/drivers/usb/core/usb.c Fri Apr 26 14:10:31 2002
@@ -155,8 +155,10 @@
* usb_deregister_dev() should be called when the driver is done with
* the minor numbers given out by this function.
*
- * Returns a negative error code on failure and 0 on success, alone with
- * a value that the driver should use in start_minor.
+ * Returns -ENODEV if CONFIG_USB_DYNAMIC_MINORS is not enabled in this
+ * kernel, -EINVAL if something bad happens with trying to register a
+ * device, and 0 on success, alone with a value that the driver should
+ * use in start_minor.
*/
#ifdef CONFIG_USB_DYNAMIC_MINORS
int usb_register_dev (struct usb_driver *new_driver, int num_minors, int *start_minor)
diff -Nru a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
--- a/drivers/usb/usb-skeleton.c Fri Apr 26 14:10:31 2002
+++ b/drivers/usb/usb-skeleton.c Fri Apr 26 14:10:31 2002
@@ -525,6 +525,7 @@
int minor;
int buffer_size;
int i;
+ int retval;
char name[10];
@@ -535,7 +536,13 @@
}
down (&minor_table_mutex);
- if (usb_register_dev (&skel_driver, 1, &minor)) {
+ retval = usb_register_dev (&skel_driver, 1, &minor);
+ if (retval) {
+ if (retval != -ENODEV) {
+ /* something prevented us from registering this driver */
+ info ("Not able to get a minor for this device.");
+ goto exit;
+ }
/* we could not get a dynamic minor, so lets find one of our own */
for (minor = 0; minor < MAX_DEVICES; ++minor) {
if (minor_table[minor] == NULL)
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel