diff options
| author | Greg Kroah-Hartman <greg@kroah.com> | 2003-04-30 20:14:42 -0700 |
|---|---|---|
| committer | Greg Kroah-Hartman <greg@kroah.com> | 2003-04-30 20:14:42 -0700 |
| commit | ec381992dfd6bd827579cb0278541b2ae605b5d2 (patch) | |
| tree | 107048b847a3635efbf6d80b46cd29bbd17c1beb | |
| parent | eb0a5728e048e61e7802a0aa3e1dcd9d0353e78f (diff) | |
[PATCH] USB: replace kdev_t with int in usb_interface structure, as only drivers with the USB major use it.
| -rw-r--r-- | drivers/usb/class/usblp.c | 8 | ||||
| -rw-r--r-- | drivers/usb/core/usb.c | 12 | ||||
| -rw-r--r-- | drivers/usb/image/scanner.c | 10 | ||||
| -rw-r--r-- | drivers/usb/image/scanner.h | 2 | ||||
| -rw-r--r-- | drivers/usb/usb-skeleton.c | 25 | ||||
| -rw-r--r-- | include/linux/usb.h | 16 |
6 files changed, 31 insertions, 42 deletions
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 4ecbf9ac4130..d9e866071e88 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -330,7 +330,7 @@ static int usblp_open(struct inode *inode, struct file *file) lock_kernel(); retval = -ENODEV; - intf = usb_find_interface(&usblp_driver, mk_kdev(USB_MAJOR,minor)); + intf = usb_find_interface(&usblp_driver, minor); if (!intf) { goto out; } @@ -920,9 +920,7 @@ static int usblp_probe(struct usb_interface *intf, usblp->dev->descriptor.idProduct); usb_set_intfdata (intf, usblp); - - /* add device id so the device works when advertised */ - intf->kdev = mk_kdev(USB_MAJOR,usblp->minor); + intf->minor = usblp->minor; return 0; @@ -1109,7 +1107,7 @@ static void usblp_disconnect(struct usb_interface *intf) struct usblp *usblp = usb_get_intfdata (intf); /* remove device id to disable open() */ - intf->kdev = NODEV; + intf->minor = -1; if (!usblp || !usblp->dev) { err("bogus disconnect"); diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index b61decf58f61..222ba70b1081 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -457,12 +457,13 @@ usb_match_id(struct usb_interface *interface, const struct usb_device_id *id) /** * usb_find_interface - find usb_interface pointer for driver and device * @drv: the driver whose current configuration is considered - * @kdev: the desired device + * @minor: the minor number of the desired device * * This walks the driver device list and returns a pointer to the interface - * with the matching kdev_t. + * with the matching minor. Note, this only works for devices that share the + * USB major number. */ -struct usb_interface *usb_find_interface(struct usb_driver *drv, kdev_t kdev) +struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor) { struct list_head *entry; struct device *dev; @@ -476,9 +477,10 @@ struct usb_interface *usb_find_interface(struct usb_driver *drv, kdev_t kdev) continue; intf = to_usb_interface(dev); - if (kdev_same(intf->kdev,kdev)) { + if (intf->minor == -1) + continue; + if (intf->minor == minor) return intf; - } } /* no device found that matches */ diff --git a/drivers/usb/image/scanner.c b/drivers/usb/image/scanner.c index d9363d46008e..81824c94b5ff 100644 --- a/drivers/usb/image/scanner.c +++ b/drivers/usb/image/scanner.c @@ -464,7 +464,7 @@ open_scanner(struct inode * inode, struct file * file) dbg("open_scanner: scn_minor:%d", scn_minor); - intf = usb_find_interface(&scanner_driver, mk_kdev(USB_MAJOR,scn_minor)); + intf = usb_find_interface(&scanner_driver, scn_minor); if (!intf) { up(&scn_mutex); err("open_scanner(%d): Unable to access minor data", scn_minor); @@ -1118,9 +1118,7 @@ probe_scanner(struct usb_interface *intf, up(&scn_mutex); usb_set_intfdata(intf, scn); - - /* add device id so the device works when advertised */ - intf->kdev = mk_kdev(USB_MAJOR,scn->scn_minor); + intf->minor = scn_minor; return 0; } @@ -1130,8 +1128,8 @@ disconnect_scanner(struct usb_interface *intf) { struct scn_usb_data *scn = usb_get_intfdata(intf); - /* remove device id to disable open() */ - intf->kdev = NODEV; + /* disable open() */ + intf->minor = -1; usb_set_intfdata(intf, NULL); if(scn->intr_ep) { diff --git a/drivers/usb/image/scanner.h b/drivers/usb/image/scanner.h index 193fb2cd13f6..3b70b41396f4 100644 --- a/drivers/usb/image/scanner.h +++ b/drivers/usb/image/scanner.h @@ -324,10 +324,8 @@ MODULE_DEVICE_TABLE (usb, scanner_device_ids); #define SCN_CLASS_SCANJET 16 #ifdef CONFIG_USB_DYNAMIC_MINORS -#define SCN_MAX_MNR 256 #define SCN_BASE_MNR 0 #else -#define SCN_MAX_MNR 16 /* We're allocated 16 minors */ #define SCN_BASE_MNR 48 /* USB Scanners start at minor 48 */ #endif diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 906c619d575c..6f7b2421a81d 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c @@ -87,12 +87,8 @@ static struct usb_device_id skel_table [] = { MODULE_DEVICE_TABLE (usb, skel_table); -#ifdef CONFIG_USB_DYNAMIC_MINORS -#define USB_SKEL_MINOR_BASE 0 -#else /* Get a minor range for your devices from the usb maintainer */ #define USB_SKEL_MINOR_BASE 192 -#endif /* Structure to hold all of our device specific stuff */ struct usb_skel { @@ -153,16 +149,6 @@ static struct file_operations skel_fops = { * This also means that the kernel can decrement * the use-counter again before calling release() * or should the open() function fail. - * - * Not all device structures have an "owner" field - * yet. "struct file_operations" and "struct net_device" - * do, while "struct tty_driver" does not. If the struct - * has an "owner" field, then initialize it to the value - * THIS_MODULE and the kernel will handle all module - * locking for you automatically. Otherwise, you must - * increment the use-counter in the open() function - * and decrement it again in the release() function - * yourself. */ .owner = THIS_MODULE, @@ -236,8 +222,7 @@ static int skel_open (struct inode *inode, struct file *file) /* prevent disconnects */ down (&disconnect_sem); - interface = usb_find_interface (&skel_driver, - mk_kdev(USB_MAJOR, subminor)); + interface = usb_find_interface (&skel_driver, subminor); if (!interface) { err ("%s - error, can't find device for minor %d", __FUNCTION__, subminor); @@ -619,8 +604,8 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i /* let the user know what node this device is now attached to */ info ("USB Skeleton device now attached to USBSkel-%d", dev->minor); - /* add device id so the device works when advertised */ - interface->kdev = mk_kdev(USB_MAJOR, dev->minor); + /* set the minor of the interface, so open() works */ + interface->minor = dev->minor; goto exit; @@ -667,8 +652,8 @@ static void skel_disconnect(struct usb_interface *interface) down (&dev->sem); - /* remove device id to disable open() */ - interface->kdev = NODEV; + /* disable open() */ + interface->minor = -1; minor = dev->minor; diff --git a/include/linux/usb.h b/include/linux/usb.h index 7ad72ec2c8ad..36dee7b0e228 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -73,12 +73,20 @@ struct usb_host_interface { /** * struct usb_interface - what usb device drivers talk to * @altsetting: array of interface descriptors, one for each alternate - * setting that may be selected. each one includes a set of - * endpoint configurations. + * setting that may be selected. Each one includes a set of + * endpoint configurations and will be in numberic order, + * 0..num_altsetting. * @num_altsetting: number of altsettings defined. * @act_altsetting: index of current altsetting. this number is always * less than num_altsetting. after the device is configured, each * interface uses its default setting of zero. + * @max_altsetting: + * @minor: the minor number assigned to this interface, if this + * interface is bound to a driver that uses the USB major number. + * If this interface does not use the USB major, this field should + * be unused. The driver should set this value in the probe() + * function of the driver, after it has been assigned a minor + * number from the USB core by calling usb_register_dev(). * @dev: driver model's view of this device * * USB device drivers attach to interfaces on a physical device. Each @@ -111,7 +119,7 @@ struct usb_interface { unsigned max_altsetting; /* total memory allocated */ struct usb_driver *driver; /* driver */ - kdev_t kdev; /* node this interface is bound to */ + int minor; /* minor number this interface is bound to */ struct device dev; /* interface specific device info */ }; #define to_usb_interface(d) container_of(d, struct usb_interface, dev) @@ -279,7 +287,7 @@ extern void usb_driver_release_interface(struct usb_driver *driver, const struct usb_device_id *usb_match_id(struct usb_interface *interface, const struct usb_device_id *id); -extern struct usb_interface *usb_find_interface(struct usb_driver *drv, kdev_t kdev); +extern struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor); extern struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum); |
