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

USB core

Took out the limitation that drivers had to take up 16 minors.  Now
they can use only 1 if they want to.
parent bb74359b
...@@ -1090,6 +1090,7 @@ static struct usb_driver usblp_driver = { ...@@ -1090,6 +1090,7 @@ static struct usb_driver usblp_driver = {
disconnect: usblp_disconnect, disconnect: usblp_disconnect,
fops: &usblp_fops, fops: &usblp_fops,
minor: USBLP_MINOR_BASE, minor: USBLP_MINOR_BASE,
num_minors: USBLP_MINORS,
id_table: usblp_ids, id_table: usblp_ids,
}; };
......
...@@ -71,8 +71,10 @@ static ssize_t usb_driver_read(struct file *file, char *buf, size_t nbytes, loff ...@@ -71,8 +71,10 @@ static ssize_t usb_driver_read(struct file *file, char *buf, size_t nbytes, loff
int minor = driver->fops ? driver->minor : -1; int minor = driver->fops ? driver->minor : -1;
if (minor == -1) if (minor == -1)
start += sprintf (start, " %s\n", driver->name); start += sprintf (start, " %s\n", driver->name);
else if (driver->num_minors == 1)
start += sprintf (start, " %3d: %s\n", minor, driver->name);
else else
start += sprintf (start, "%3d-%3d: %s\n", minor, minor + 15, driver->name); start += sprintf (start, "%3d-%3d: %s\n", minor, minor + driver->num_minors - 1, driver->name);
if (start > end) { if (start > end) {
start += sprintf(start, "(truncated)\n"); start += sprintf(start, "(truncated)\n");
break; break;
......
...@@ -59,7 +59,7 @@ LIST_HEAD(usb_driver_list); ...@@ -59,7 +59,7 @@ LIST_HEAD(usb_driver_list);
devfs_handle_t usb_devfs_handle; /* /dev/usb dir. */ devfs_handle_t usb_devfs_handle; /* /dev/usb dir. */
static struct usb_driver *usb_minors[16]; static struct usb_driver *usb_minors[256];
/** /**
* usb_register - register a USB driver * usb_register - register a USB driver
...@@ -72,12 +72,17 @@ static struct usb_driver *usb_minors[16]; ...@@ -72,12 +72,17 @@ static struct usb_driver *usb_minors[16];
*/ */
int usb_register(struct usb_driver *new_driver) int usb_register(struct usb_driver *new_driver)
{ {
int i;
if (new_driver->fops != NULL) { if (new_driver->fops != NULL) {
if (usb_minors[new_driver->minor/16]) { for (i = new_driver->minor; i < new_driver->minor + new_driver->num_minors; ++i) {
err("error registering %s driver", new_driver->name); if (usb_minors[i]) {
return -EINVAL; err("error registering %s driver", new_driver->name);
return -EINVAL;
}
} }
usb_minors[new_driver->minor/16] = new_driver; for (i = new_driver->minor; i < new_driver->minor + new_driver->num_minors; ++i)
usb_minors[i] = new_driver;
} }
info("registered new driver %s", new_driver->name); info("registered new driver %s", new_driver->name);
...@@ -172,10 +177,12 @@ static void usb_drivers_purge(struct usb_driver *driver,struct usb_device *dev) ...@@ -172,10 +177,12 @@ static void usb_drivers_purge(struct usb_driver *driver,struct usb_device *dev)
void usb_deregister(struct usb_driver *driver) void usb_deregister(struct usb_driver *driver)
{ {
struct list_head *tmp; struct list_head *tmp;
int i;
info("deregistering driver %s", driver->name); info("deregistering driver %s", driver->name);
if (driver->fops != NULL) if (driver->fops != NULL)
usb_minors[driver->minor/16] = NULL; for (i = driver->minor; i < driver->minor + driver->num_minors; ++i)
usb_minors[i] = NULL;
/* /*
* first we remove the driver, to be sure it doesn't get used by * first we remove the driver, to be sure it doesn't get used by
...@@ -2517,7 +2524,7 @@ int usb_new_device(struct usb_device *dev) ...@@ -2517,7 +2524,7 @@ int usb_new_device(struct usb_device *dev)
static int usb_open(struct inode * inode, struct file * file) static int usb_open(struct inode * inode, struct file * file)
{ {
int minor = minor(inode->i_rdev); int minor = minor(inode->i_rdev);
struct usb_driver *c = usb_minors[minor/16]; struct usb_driver *c = usb_minors[minor];
int err = -ENODEV; int err = -ENODEV;
struct file_operations *old_fops, *new_fops = NULL; struct file_operations *old_fops, *new_fops = NULL;
......
...@@ -933,6 +933,7 @@ static struct usb_driver mdc800_usb_driver = ...@@ -933,6 +933,7 @@ static struct usb_driver mdc800_usb_driver =
disconnect: mdc800_usb_disconnect, disconnect: mdc800_usb_disconnect,
fops: &mdc800_device_ops, fops: &mdc800_device_ops,
minor: MDC800_DEVICE_MINOR_BASE, minor: MDC800_DEVICE_MINOR_BASE,
num_minors: 1,
id_table: mdc800_table id_table: mdc800_table
}; };
......
...@@ -1100,6 +1100,7 @@ usb_driver scanner_driver = { ...@@ -1100,6 +1100,7 @@ usb_driver scanner_driver = {
disconnect: disconnect_scanner, disconnect: disconnect_scanner,
fops: &usb_scanner_fops, fops: &usb_scanner_fops,
minor: SCN_BASE_MNR, minor: SCN_BASE_MNR,
num_minors: SCN_MAX_MNR,
id_table: NULL, /* This would be scanner_device_ids, but we id_table: NULL, /* This would be scanner_device_ids, but we
need to check every USB device, in case need to check every USB device, in case
we match a user defined vendor/product ID. */ we match a user defined vendor/product ID. */
......
...@@ -678,10 +678,11 @@ static void *hiddev_usbd_probe(struct usb_device *dev, unsigned int ifnum, ...@@ -678,10 +678,11 @@ static void *hiddev_usbd_probe(struct usb_device *dev, unsigned int ifnum,
static /* const */ struct usb_driver hiddev_driver = { static /* const */ struct usb_driver hiddev_driver = {
name: "hiddev", name: "hiddev",
probe: hiddev_usbd_probe, probe: hiddev_usbd_probe,
fops: &hiddev_fops, fops: &hiddev_fops,
minor: HIDDEV_MINOR_BASE minor: HIDDEV_MINOR_BASE,
num_minors: HIDDEV_MINORS,
}; };
int __init hiddev_init(void) int __init hiddev_init(void)
......
...@@ -801,6 +801,7 @@ static struct usb_driver dabusb_driver = ...@@ -801,6 +801,7 @@ static struct usb_driver dabusb_driver =
disconnect: dabusb_disconnect, disconnect: dabusb_disconnect,
fops: &dabusb_fops, fops: &dabusb_fops,
minor: DABUSB_MINOR, minor: DABUSB_MINOR,
num_minors: NRDABUSB,
id_table: dabusb_ids, id_table: dabusb_ids,
}; };
......
...@@ -128,8 +128,6 @@ static struct usb_driver usb_dsbr100_driver = { ...@@ -128,8 +128,6 @@ static struct usb_driver usb_dsbr100_driver = {
name: "dsbr100", name: "dsbr100",
probe: usb_dsbr100_probe, probe: usb_dsbr100_probe,
disconnect: usb_dsbr100_disconnect, disconnect: usb_dsbr100_disconnect,
fops: NULL,
minor: 0,
id_table: usb_dsbr100_table, id_table: usb_dsbr100_table,
}; };
......
...@@ -2138,6 +2138,7 @@ static struct usb_driver auerswald_driver = { ...@@ -2138,6 +2138,7 @@ static struct usb_driver auerswald_driver = {
disconnect: auerswald_disconnect, disconnect: auerswald_disconnect,
fops: &auerswald_fops, fops: &auerswald_fops,
minor: AUER_MINOR_BASE, minor: AUER_MINOR_BASE,
num_minors: AUER_MAX_DEVICES,
id_table: auerswald_ids, id_table: auerswald_ids,
}; };
......
...@@ -517,6 +517,7 @@ static struct usb_driver rio_driver = { ...@@ -517,6 +517,7 @@ static struct usb_driver rio_driver = {
disconnect: disconnect_rio, disconnect: disconnect_rio,
fops: &usb_rio_fops, fops: &usb_rio_fops,
minor: RIO_MINOR, minor: RIO_MINOR,
num_minors: 1,
id_table: rio_table, id_table: rio_table,
}; };
......
...@@ -187,6 +187,7 @@ static struct usb_driver skel_driver = { ...@@ -187,6 +187,7 @@ static struct usb_driver skel_driver = {
disconnect: skel_disconnect, disconnect: skel_disconnect,
fops: &skel_fops, fops: &skel_fops,
minor: USB_SKEL_MINOR_BASE, minor: USB_SKEL_MINOR_BASE,
num_minors: MAX_DEVICES,
id_table: skel_table, id_table: skel_table,
}; };
......
...@@ -493,6 +493,8 @@ struct usb_device_id { ...@@ -493,6 +493,8 @@ struct usb_device_id {
* @minor: Used with fops to simplify creating USB character devices. * @minor: Used with fops to simplify creating USB character devices.
* Such drivers have sixteen character devices, using the USB * Such drivers have sixteen character devices, using the USB
* major number and starting with this minor number. * major number and starting with this minor number.
* @num_minors: Used with minor to specify how many minors are used by
* this driver.
* @ioctl: Used for drivers that want to talk to userspace through * @ioctl: Used for drivers that want to talk to userspace through
* the "usbfs" filesystem. This lets devices provide ways to * the "usbfs" filesystem. This lets devices provide ways to
* expose information to user space regardless of where they * expose information to user space regardless of where they
...@@ -534,6 +536,7 @@ struct usb_driver { ...@@ -534,6 +536,7 @@ struct usb_driver {
struct file_operations *fops; struct file_operations *fops;
int minor; int minor;
int num_minors;
struct semaphore serialize; struct semaphore serialize;
......
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