Commit ec381992 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] USB: replace kdev_t with int in usb_interface structure, as only...

[PATCH] USB: replace kdev_t with int in usb_interface structure, as only drivers with the USB major use it.
parent eb0a5728
...@@ -330,7 +330,7 @@ static int usblp_open(struct inode *inode, struct file *file) ...@@ -330,7 +330,7 @@ static int usblp_open(struct inode *inode, struct file *file)
lock_kernel(); lock_kernel();
retval = -ENODEV; retval = -ENODEV;
intf = usb_find_interface(&usblp_driver, mk_kdev(USB_MAJOR,minor)); intf = usb_find_interface(&usblp_driver, minor);
if (!intf) { if (!intf) {
goto out; goto out;
} }
...@@ -920,9 +920,7 @@ static int usblp_probe(struct usb_interface *intf, ...@@ -920,9 +920,7 @@ static int usblp_probe(struct usb_interface *intf,
usblp->dev->descriptor.idProduct); usblp->dev->descriptor.idProduct);
usb_set_intfdata (intf, usblp); usb_set_intfdata (intf, usblp);
intf->minor = usblp->minor;
/* add device id so the device works when advertised */
intf->kdev = mk_kdev(USB_MAJOR,usblp->minor);
return 0; return 0;
...@@ -1109,7 +1107,7 @@ static void usblp_disconnect(struct usb_interface *intf) ...@@ -1109,7 +1107,7 @@ static void usblp_disconnect(struct usb_interface *intf)
struct usblp *usblp = usb_get_intfdata (intf); struct usblp *usblp = usb_get_intfdata (intf);
/* remove device id to disable open() */ /* remove device id to disable open() */
intf->kdev = NODEV; intf->minor = -1;
if (!usblp || !usblp->dev) { if (!usblp || !usblp->dev) {
err("bogus disconnect"); err("bogus disconnect");
......
...@@ -457,12 +457,13 @@ usb_match_id(struct usb_interface *interface, const struct usb_device_id *id) ...@@ -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 * usb_find_interface - find usb_interface pointer for driver and device
* @drv: the driver whose current configuration is considered * @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 * 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 list_head *entry;
struct device *dev; struct device *dev;
...@@ -476,9 +477,10 @@ struct usb_interface *usb_find_interface(struct usb_driver *drv, kdev_t kdev) ...@@ -476,9 +477,10 @@ struct usb_interface *usb_find_interface(struct usb_driver *drv, kdev_t kdev)
continue; continue;
intf = to_usb_interface(dev); intf = to_usb_interface(dev);
if (kdev_same(intf->kdev,kdev)) { if (intf->minor == -1)
continue;
if (intf->minor == minor)
return intf; return intf;
}
} }
/* no device found that matches */ /* no device found that matches */
......
...@@ -464,7 +464,7 @@ open_scanner(struct inode * inode, struct file * file) ...@@ -464,7 +464,7 @@ open_scanner(struct inode * inode, struct file * file)
dbg("open_scanner: scn_minor:%d", scn_minor); 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) { if (!intf) {
up(&scn_mutex); up(&scn_mutex);
err("open_scanner(%d): Unable to access minor data", scn_minor); err("open_scanner(%d): Unable to access minor data", scn_minor);
...@@ -1118,9 +1118,7 @@ probe_scanner(struct usb_interface *intf, ...@@ -1118,9 +1118,7 @@ probe_scanner(struct usb_interface *intf,
up(&scn_mutex); up(&scn_mutex);
usb_set_intfdata(intf, scn); usb_set_intfdata(intf, scn);
intf->minor = scn_minor;
/* add device id so the device works when advertised */
intf->kdev = mk_kdev(USB_MAJOR,scn->scn_minor);
return 0; return 0;
} }
...@@ -1130,8 +1128,8 @@ disconnect_scanner(struct usb_interface *intf) ...@@ -1130,8 +1128,8 @@ disconnect_scanner(struct usb_interface *intf)
{ {
struct scn_usb_data *scn = usb_get_intfdata(intf); struct scn_usb_data *scn = usb_get_intfdata(intf);
/* remove device id to disable open() */ /* disable open() */
intf->kdev = NODEV; intf->minor = -1;
usb_set_intfdata(intf, NULL); usb_set_intfdata(intf, NULL);
if(scn->intr_ep) { if(scn->intr_ep) {
......
...@@ -324,10 +324,8 @@ MODULE_DEVICE_TABLE (usb, scanner_device_ids); ...@@ -324,10 +324,8 @@ MODULE_DEVICE_TABLE (usb, scanner_device_ids);
#define SCN_CLASS_SCANJET 16 #define SCN_CLASS_SCANJET 16
#ifdef CONFIG_USB_DYNAMIC_MINORS #ifdef CONFIG_USB_DYNAMIC_MINORS
#define SCN_MAX_MNR 256
#define SCN_BASE_MNR 0 #define SCN_BASE_MNR 0
#else #else
#define SCN_MAX_MNR 16 /* We're allocated 16 minors */
#define SCN_BASE_MNR 48 /* USB Scanners start at minor 48 */ #define SCN_BASE_MNR 48 /* USB Scanners start at minor 48 */
#endif #endif
......
...@@ -87,12 +87,8 @@ static struct usb_device_id skel_table [] = { ...@@ -87,12 +87,8 @@ static struct usb_device_id skel_table [] = {
MODULE_DEVICE_TABLE (usb, 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 */ /* Get a minor range for your devices from the usb maintainer */
#define USB_SKEL_MINOR_BASE 192 #define USB_SKEL_MINOR_BASE 192
#endif
/* Structure to hold all of our device specific stuff */ /* Structure to hold all of our device specific stuff */
struct usb_skel { struct usb_skel {
...@@ -153,16 +149,6 @@ static struct file_operations skel_fops = { ...@@ -153,16 +149,6 @@ static struct file_operations skel_fops = {
* This also means that the kernel can decrement * This also means that the kernel can decrement
* the use-counter again before calling release() * the use-counter again before calling release()
* or should the open() function fail. * 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, .owner = THIS_MODULE,
...@@ -236,8 +222,7 @@ static int skel_open (struct inode *inode, struct file *file) ...@@ -236,8 +222,7 @@ static int skel_open (struct inode *inode, struct file *file)
/* prevent disconnects */ /* prevent disconnects */
down (&disconnect_sem); down (&disconnect_sem);
interface = usb_find_interface (&skel_driver, interface = usb_find_interface (&skel_driver, subminor);
mk_kdev(USB_MAJOR, subminor));
if (!interface) { if (!interface) {
err ("%s - error, can't find device for minor %d", err ("%s - error, can't find device for minor %d",
__FUNCTION__, subminor); __FUNCTION__, subminor);
...@@ -619,8 +604,8 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i ...@@ -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 */ /* let the user know what node this device is now attached to */
info ("USB Skeleton device now attached to USBSkel-%d", dev->minor); info ("USB Skeleton device now attached to USBSkel-%d", dev->minor);
/* add device id so the device works when advertised */ /* set the minor of the interface, so open() works */
interface->kdev = mk_kdev(USB_MAJOR, dev->minor); interface->minor = dev->minor;
goto exit; goto exit;
...@@ -667,8 +652,8 @@ static void skel_disconnect(struct usb_interface *interface) ...@@ -667,8 +652,8 @@ static void skel_disconnect(struct usb_interface *interface)
down (&dev->sem); down (&dev->sem);
/* remove device id to disable open() */ /* disable open() */
interface->kdev = NODEV; interface->minor = -1;
minor = dev->minor; minor = dev->minor;
......
...@@ -73,12 +73,20 @@ struct usb_host_interface { ...@@ -73,12 +73,20 @@ struct usb_host_interface {
/** /**
* struct usb_interface - what usb device drivers talk to * struct usb_interface - what usb device drivers talk to
* @altsetting: array of interface descriptors, one for each alternate * @altsetting: array of interface descriptors, one for each alternate
* setting that may be selected. each one includes a set of * setting that may be selected. Each one includes a set of
* endpoint configurations. * endpoint configurations and will be in numberic order,
* 0..num_altsetting.
* @num_altsetting: number of altsettings defined. * @num_altsetting: number of altsettings defined.
* @act_altsetting: index of current altsetting. this number is always * @act_altsetting: index of current altsetting. this number is always
* less than num_altsetting. after the device is configured, each * less than num_altsetting. after the device is configured, each
* interface uses its default setting of zero. * 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 * @dev: driver model's view of this device
* *
* USB device drivers attach to interfaces on a physical device. Each * USB device drivers attach to interfaces on a physical device. Each
...@@ -111,7 +119,7 @@ struct usb_interface { ...@@ -111,7 +119,7 @@ struct usb_interface {
unsigned max_altsetting; /* total memory allocated */ unsigned max_altsetting; /* total memory allocated */
struct usb_driver *driver; /* driver */ 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 */ struct device dev; /* interface specific device info */
}; };
#define to_usb_interface(d) container_of(d, struct usb_interface, dev) #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, ...@@ -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 *usb_match_id(struct usb_interface *interface,
const struct usb_device_id *id); 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); extern struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment