diff options
| author | Alan Stern <[email protected]> | 2008-06-24 18:47:12 +0000 |
|---|---|---|
| committer | Greg Kroah-Hartman <[email protected]> | 2008-07-21 22:16:41 +0000 |
| commit | 61ad04a89f0e3e6adaed0d9adfc0c9b431ccbb92 (patch) | |
| tree | 7aefa64191cc2628be8c9a756b6f08bf6ff36ba0 /drivers/usb/core/devio.c | |
| parent | usbfs: send disconnect signals when device is unregistered (diff) | |
| download | kernel-61ad04a89f0e3e6adaed0d9adfc0c9b431ccbb92.tar.gz kernel-61ad04a89f0e3e6adaed0d9adfc0c9b431ccbb92.zip | |
usbfs: simplify the lookup-by-minor routines
This patch (as1105) simplifies the lookup-by-minor-number code in
usbfs. Instead of passing the minor number to the callback, which
must then reconstruct the entire dev_t value, the patch passes the
dev_t value directly.
Signed-off-by: Alan Stern <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Diffstat (limited to 'drivers/usb/core/devio.c')
| -rw-r--r-- | drivers/usb/core/devio.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index bbd029f68faa..57bedcebf96c 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -550,20 +550,16 @@ static int check_ctrlrecip(struct dev_state *ps, unsigned int requesttype, return ret; } -static int __match_minor(struct device *dev, void *data) +static int match_devt(struct device *dev, void *data) { - int minor = *((int *)data); - - if (dev->devt == MKDEV(USB_DEVICE_MAJOR, minor)) - return 1; - return 0; + return (dev->devt == (dev_t) data); } -static struct usb_device *usbdev_lookup_by_minor(int minor) +static struct usb_device *usbdev_lookup_by_devt(dev_t devt) { struct device *dev; - dev = bus_find_device(&usb_bus_type, NULL, &minor, __match_minor); + dev = bus_find_device(&usb_bus_type, NULL, (void *) devt, match_devt); if (!dev) return NULL; put_device(dev); @@ -589,9 +585,10 @@ static int usbdev_open(struct inode *inode, struct file *file) goto out; ret = -ENOENT; + /* usbdev device-node */ if (imajor(inode) == USB_DEVICE_MAJOR) - dev = usbdev_lookup_by_minor(iminor(inode)); + dev = usbdev_lookup_by_devt(inode->i_rdev); #ifdef CONFIG_USB_DEVICEFS /* procfs file */ if (!dev) |
