Commit 26f8beab authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

USB: Fixups due to the changes in struct usb_device for file_operations and minor number handling

parent 05752c5d
......@@ -372,7 +372,7 @@ static void usblp_cleanup (struct usblp *usblp)
{
devfs_unregister (usblp->devfs);
usblp_table [usblp->minor] = NULL;
usb_deregister_dev (&usblp_driver, 1, usblp->minor);
usb_deregister_dev (1, usblp->minor);
info("usblp%d: removed", usblp->minor);
kfree (usblp->writeurb->transfer_buffer);
......@@ -812,20 +812,10 @@ static void *usblp_probe(struct usb_device *dev, unsigned int ifnum,
init_waitqueue_head(&usblp->wait);
usblp->ifnum = ifnum;
retval = usb_register_dev(&usblp_driver, 1, &usblp->minor);
retval = usb_register_dev(&usblp_fops, USBLP_MINOR_BASE, 1, &usblp->minor);
if (retval) {
if (retval != -ENODEV) {
err("Not able to get a minor for this device.");
goto abort;
}
/* Look for a free usblp_table entry on our own. */
while (usblp_table[usblp->minor]) {
usblp->minor++;
if (usblp->minor >= USBLP_MINORS) {
err("no more free usblp devices");
goto abort;
}
}
err("Not able to get a minor for this device.");
goto abort;
}
usblp->writeurb = usb_alloc_urb(0, GFP_KERNEL);
......@@ -901,7 +891,7 @@ static void *usblp_probe(struct usb_device *dev, unsigned int ifnum,
return usblp;
abort_minor:
usb_deregister_dev (&usblp_driver, 1, usblp->minor);
usb_deregister_dev (1, usblp->minor);
abort:
if (usblp) {
usb_free_urb(usblp->writeurb);
......@@ -1111,9 +1101,6 @@ static struct usb_driver usblp_driver = {
name: "usblp",
probe: usblp_probe,
disconnect: usblp_disconnect,
fops: &usblp_fops,
minor: USBLP_MINOR_BASE,
num_minors: USBLP_MINORS,
id_table: usblp_ids,
};
......
......@@ -401,6 +401,7 @@ static void mdc800_usb_download_notify (struct urb *urb)
***************************************************************************/
static struct usb_driver mdc800_usb_driver;
static struct file_operations mdc800_device_ops;
/*
* Callback to search the Mustek MDC800 on the USB Bus
......@@ -476,7 +477,7 @@ static void* mdc800_usb_probe (struct usb_device *dev ,unsigned int ifnum,
down (&mdc800->io_lock);
retval = usb_register_dev (&mdc800_usb_driver, 1, &mdc800->minor);
retval = usb_register_dev (&mdc800_device_ops, MDC800_DEVICE_MINOR_BASE, 1, &mdc800->minor);
if (retval && (retval != -ENODEV)) {
err ("Not able to get a minor for this device.");
return 0;
......@@ -537,7 +538,7 @@ static void mdc800_usb_disconnect (struct usb_device *dev,void* ptr)
if (mdc800->state == NOT_CONNECTED)
return;
usb_deregister_dev (&mdc800_usb_driver, 1, mdc800->minor);
usb_deregister_dev (1, mdc800->minor);
mdc800->state=NOT_CONNECTED;
......@@ -942,12 +943,10 @@ MODULE_DEVICE_TABLE (usb, mdc800_table);
*/
static struct usb_driver mdc800_usb_driver =
{
owner: THIS_MODULE,
name: "mdc800",
probe: mdc800_usb_probe,
disconnect: mdc800_usb_disconnect,
fops: &mdc800_device_ops,
minor: MDC800_DEVICE_MINOR_BASE,
num_minors: 1,
id_table: mdc800_table
};
......
......@@ -971,17 +971,11 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
down(&scn_mutex);
retval = usb_register_dev(&scanner_driver, 1, &scn_minor);
retval = usb_register_dev(&usb_scanner_fops, SCN_BASE_MNR, 1, &scn_minor);
if (retval) {
if (retval != -ENODEV) {
err ("Not able to get a minor for this device.");
up(&scn_mutex);
return NULL;
}
for (scn_minor = 0; scn_minor < SCN_MAX_MNR; scn_minor++) {
if (!p_scn_table[scn_minor])
break;
}
err ("Not able to get a minor for this device.");
up(&scn_mutex);
return NULL;
}
/* Check to make sure that the last slot isn't already taken */
......@@ -1112,7 +1106,7 @@ disconnect_scanner(struct usb_device *dev, void *ptr)
dbg("disconnect_scanner: De-allocating minor:%d", scn->scn_minor);
devfs_unregister(scn->devfs);
usb_deregister_dev(&scanner_driver, 1, scn->scn_minor);
usb_deregister_dev(1, scn->scn_minor);
p_scn_table[scn->scn_minor] = NULL;
usb_free_urb(scn->scn_irq);
up (&(scn->sem));
......@@ -1125,9 +1119,6 @@ usb_driver scanner_driver = {
name: "usbscanner",
probe: probe_scanner,
disconnect: disconnect_scanner,
fops: &usb_scanner_fops,
minor: SCN_BASE_MNR,
num_minors: SCN_MAX_MNR,
id_table: NULL, /* This would be scanner_device_ids, but we
need to check every USB device, in case
we match a user defined vendor/product ID. */
......
......@@ -193,7 +193,7 @@ static int hiddev_fasync(int fd, struct file *file, int on)
static void hiddev_cleanup(struct hiddev *hiddev)
{
devfs_unregister(hiddev->devfs);
usb_deregister_dev(&hiddev_driver, 1, hiddev->minor);
usb_deregister_dev(1, hiddev->minor);
hiddev_table[hiddev->minor] = NULL;
kfree(hiddev);
}
......@@ -626,21 +626,16 @@ int hiddev_connect(struct hid_device *hid)
if (i == hid->maxapplication)
return -1;
retval = usb_register_dev (&hiddev_driver, 1, &minor);
retval = usb_register_dev (&hiddev_fops, HIDDEV_MINOR_BASE, 1, &minor);
if (retval) {
if (retval != -ENODEV) {
err ("Not able to get a minor for this device.");
return -1;
}
for (minor = 0; minor < HIDDEV_MINORS && hiddev_table[minor]; minor++);
if (minor == HIDDEV_MINORS) {
printk(KERN_ERR "hiddev: no more free hiddev devices\n");
return -1;
}
err ("Not able to get a minor for this device.");
return -1;
}
if (!(hiddev = kmalloc(sizeof(struct hiddev), GFP_KERNEL)))
if (!(hiddev = kmalloc(sizeof(struct hiddev), GFP_KERNEL))) {
usb_deregister_dev (1, minor);
return -1;
}
memset(hiddev, 0, sizeof(struct hiddev));
init_waitqueue_head(&hiddev->wait);
......@@ -708,9 +703,6 @@ static void *hiddev_usbd_probe(struct usb_device *dev, unsigned int ifnum,
static /* const */ struct usb_driver hiddev_driver = {
name: "hiddev",
probe: hiddev_usbd_probe,
fops: &hiddev_fops,
minor: HIDDEV_MINOR_BASE,
num_minors: HIDDEV_MINORS,
};
int __init hiddev_init(void)
......
......@@ -742,14 +742,9 @@ static void *dabusb_probe (struct usb_device *usbdev, unsigned int ifnum,
if (ifnum != _DABUSB_IF && usbdev->descriptor.idProduct == 0x9999)
return NULL;
retval = usb_register_dev (&dabusb_driver, 1, &devnum);
if (retval) {
if (retval != -ENODEV)
return NULL;
devnum = dabusb_find_struct ();
if (devnum == -1)
return NULL;
}
retval = usb_register_dev (&dabusb_fops, DABUSB_MINOR, 1, &devnum);
if (retval)
return NULL;
s = &dabusb[devnum];
......@@ -791,7 +786,7 @@ static void dabusb_disconnect (struct usb_device *usbdev, void *ptr)
dbg("dabusb_disconnect");
usb_deregister_dev (&dabusb_driver, 1, s->devnum);
usb_deregister_dev (1, s->devnum);
s->remove_pending = 1;
wake_up (&s->wait);
if (s->state == _started)
......@@ -814,9 +809,6 @@ static struct usb_driver dabusb_driver =
name: "dabusb",
probe: dabusb_probe,
disconnect: dabusb_disconnect,
fops: &dabusb_fops,
minor: DABUSB_MINOR,
num_minors: NRDABUSB,
id_table: dabusb_ids,
};
......
......@@ -1948,23 +1948,11 @@ static void *auerswald_probe (struct usb_device *usbdev, unsigned int ifnum,
init_waitqueue_head (&cp->bufferwait);
down (&dev_table_mutex);
ret = usb_register_dev (&auerswald_driver, 1, &dtindex);
ret = usb_register_dev (&auerswald_fops, AUER_MINOR_BASE, 1, &dtindex);
if (ret) {
if (ret != -ENODEV) {
err ("Not able to get a minor for this device.");
up (&dev_table_mutex);
goto pfail;
}
/* find a free slot in the device table */
for (dtindex = 0; dtindex < AUER_MAX_DEVICES; ++dtindex) {
if (dev_table[dtindex] == NULL)
break;
}
if ( dtindex >= AUER_MAX_DEVICES) {
err ("more than %d devices plugged in, can not handle this device", AUER_MAX_DEVICES);
up (&dev_table_mutex);
goto pfail;
}
err ("Not able to get a minor for this device.");
up (&dev_table_mutex);
goto pfail;
}
/* Give the device a name */
......@@ -2096,7 +2084,7 @@ static void auerswald_disconnect (struct usb_device *usbdev, void *driver_contex
devfs_unregister (cp->devfs);
/* give back our USB minor number */
usb_deregister_dev (&auerswald_driver, 1, cp->dtindex);
usb_deregister_dev (1, cp->dtindex);
/* Stop the interrupt endpoint */
auerswald_int_release (cp);
......@@ -2153,9 +2141,6 @@ static struct usb_driver auerswald_driver = {
name: "auerswald",
probe: auerswald_probe,
disconnect: auerswald_disconnect,
fops: &auerswald_fops,
minor: AUER_MINOR_BASE,
num_minors: AUER_MAX_DEVICES,
id_table: auerswald_ids,
};
......
......@@ -246,9 +246,6 @@ static struct usb_driver brlvger_driver =
name: "brlvger",
probe: brlvger_probe,
disconnect: brlvger_disconnect,
fops: &brlvger_fops,
minor: BRLVGER_MINOR,
num_minors: MAX_NR_BRLVGER_DEVS,
id_table: brlvger_ids,
};
......@@ -316,21 +313,10 @@ brlvger_probe (struct usb_device *dev, unsigned ifnum,
down(&reserve_sem);
retval = usb_register_dev(&brlvger_driver, 1, &i);
retval = usb_register_dev(&brlvger_fops, BRLVGER_MINOR, 1, &i);
if (retval) {
if (retval != -ENODEV) {
err("Not able to get a minor for this device.");
goto error;
}
for( i = 0; i < MAX_NR_BRLVGER_DEVS; i++ )
if( display_table[i] == NULL )
break;
if( i == MAX_NR_BRLVGER_DEVS ) {
err( "This driver cannot handle more than %d "
"braille displays", MAX_NR_BRLVGER_DEVS);
goto error;
}
err("Not able to get a minor for this device.");
goto error;
}
if( !(priv = kmalloc (sizeof *priv, GFP_KERNEL)) ){
......@@ -431,7 +417,7 @@ brlvger_disconnect(struct usb_device *dev, void *ptr)
info("Display %d disconnecting", priv->subminor);
devfs_unregister(priv->devfs);
usb_deregister_dev(&brlvger_driver, 1, priv->subminor);
usb_deregister_dev(1, priv->subminor);
down(&disconnect_sem);
display_table[priv->subminor] = NULL;
......
......@@ -49,7 +49,11 @@
#define DRIVER_AUTHOR "Cesar Miquel <miquel@df.uba.ar>"
#define DRIVER_DESC "USB Rio 500 driver"
#define RIO_MINOR 64
#ifdef CONFIG_USB_DYNAMIC_MINORS
#define RIO_MINOR 0
#else
#define RIO_MINOR 64
#endif
/* stall/wait timeout for rio */
#define NAK_TIMEOUT (HZ)
......@@ -65,6 +69,7 @@ struct rio_usb_data {
unsigned int ifnum; /* Interface number of the USB device */
int isopen; /* nz if open */
int present; /* Device is present on the bus */
int minor; /* minor number assigned to us */
char *obuf, *ibuf; /* transfer buffers */
char bulk_in_ep, bulk_out_ep; /* Endpoint assignments */
wait_queue_head_t wait_q; /* for timeouts */
......@@ -449,9 +454,16 @@ static void *probe_rio(struct usb_device *dev, unsigned int ifnum,
const struct usb_device_id *id)
{
struct rio_usb_data *rio = &rio_instance;
int retval;
info("USB Rio found at address %d", dev->devnum);
retval = usb_register_dev(&usb_rio_fops, RIO_MINOR, 1, &rio->minor);
if (retval) {
err("Not able to get a minor for this device.");
return NULL;
}
rio->present = 1;
rio->rio_dev = dev;
......@@ -486,6 +498,7 @@ static void disconnect_rio(struct usb_device *dev, void *ptr)
struct rio_usb_data *rio = (struct rio_usb_data *) ptr;
devfs_unregister(rio->devfs);
usb_deregister_dev(1, rio->minor);
down(&(rio->lock));
if (rio->isopen) {
......@@ -515,9 +528,6 @@ static struct usb_driver rio_driver = {
name: "rio500",
probe: probe_rio,
disconnect: disconnect_rio,
fops: &usb_rio_fops,
minor: RIO_MINOR,
num_minors: 1,
id_table: rio_table,
};
......
......@@ -189,9 +189,6 @@ static struct usb_driver skel_driver = {
name: "skeleton",
probe: skel_probe,
disconnect: skel_disconnect,
fops: &skel_fops,
minor: USB_SKEL_MINOR_BASE,
num_minors: MAX_DEVICES,
id_table: skel_table,
};
......@@ -532,29 +529,18 @@ static void * skel_probe(struct usb_device *udev, unsigned int ifnum, const stru
}
down (&minor_table_mutex);
retval = usb_register_dev (&skel_driver, 1, &minor);
retval = usb_register_dev (&skel_fops, USB_SKEL_MINOR_BASE, 1, &minor);
if (retval) {
if (retval != -ENODEV) {
/* something prevented us from registering this driver */
err ("Not able to get a minor for this device.");
goto exit;
}
/* we could not get a dynamic minor, so lets find one of our own */
for (minor = 0; minor < MAX_DEVICES; ++minor) {
if (minor_table[minor] == NULL)
break;
}
if (minor >= MAX_DEVICES) {
err ("Too many devices plugged in, can not handle this device.");
goto exit;
}
/* something prevented us from registering this driver */
err ("Not able to get a minor for this device.");
goto exit;
}
/* allocate memory for our device state and intialize it */
dev = kmalloc (sizeof(struct usb_skel), GFP_KERNEL);
if (dev == NULL) {
err ("Out of memory");
goto exit;
goto exit_minor;
}
memset (dev, 0x00, sizeof (*dev));
minor_table[minor] = dev;
......@@ -628,6 +614,9 @@ static void * skel_probe(struct usb_device *udev, unsigned int ifnum, const stru
skel_delete (dev);
dev = NULL;
exit_minor:
usb_deregister_dev (1, minor);
exit:
up (&minor_table_mutex);
return dev;
......@@ -655,7 +644,7 @@ static void skel_disconnect(struct usb_device *udev, void *ptr)
devfs_unregister (dev->devfs);
/* give back our dynamic minor */
usb_deregister_dev (&skel_driver, 1, minor);
usb_deregister_dev (1, minor);
/* if the device is not opened, then we clean up right now */
if (!dev->open_count) {
......
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