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)
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");
......
......@@ -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,10 +477,11 @@ 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 */
return NULL;
......
......@@ -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) {
......
......@@ -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
......
......@@ -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;
......
......@@ -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);
......
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