Commit 2babc05b authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

USB

cleaned up checking the return value of usb_register_dev()
parent 526e60f8
......@@ -794,6 +794,7 @@ static void *usblp_probe(struct usb_device *dev, unsigned int ifnum,
{
struct usblp *usblp = 0;
int protocol;
int retval;
char name[6];
/* Malloc and start initializing usblp structure so we can use it
......@@ -808,7 +809,12 @@ static void *usblp_probe(struct usb_device *dev, unsigned int ifnum,
init_waitqueue_head(&usblp->wait);
usblp->ifnum = ifnum;
if (usb_register_dev(&usblp_driver, 1, &usblp->minor)) {
retval = usb_register_dev(&usblp_driver, 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++;
......
......@@ -411,6 +411,7 @@ static void* mdc800_usb_probe (struct usb_device *dev ,unsigned int ifnum,
int i,j;
struct usb_interface_descriptor *intf_desc;
int irq_interval=0;
int retval;
dbg ("(mdc800_usb_probe) called.");
......@@ -475,7 +476,11 @@ static void* mdc800_usb_probe (struct usb_device *dev ,unsigned int ifnum,
down (&mdc800->io_lock);
usb_register_dev (&mdc800_usb_driver, 1, &mdc800->minor);
retval = usb_register_dev (&mdc800_usb_driver, 1, &mdc800->minor);
if (retval && (retval != -ENODEV)) {
err ("Not able to get a minor for this device.");
return 0;
}
mdc800->dev=dev;
mdc800->open=0;
......
......@@ -812,6 +812,7 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
int ep_cnt;
int ix;
int scn_minor;
int retval;
char valid_device = 0;
char have_bulk_in, have_bulk_out, have_intr;
......@@ -953,7 +954,13 @@ probe_scanner(struct usb_device *dev, unsigned int ifnum,
down(&scn_mutex);
if (usb_register_dev(&scanner_driver, 1, &scn_minor)) {
retval = usb_register_dev(&scanner_driver, 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;
......
......@@ -606,6 +606,7 @@ int hiddev_connect(struct hid_device *hid)
{
struct hiddev *hiddev;
int minor, i;
int retval;
char devfs_name[16];
for (i = 0; i < hid->maxapplication; i++)
......@@ -615,7 +616,12 @@ int hiddev_connect(struct hid_device *hid)
if (i == hid->maxapplication)
return -1;
if (usb_register_dev (&hiddev_driver, 1, &minor)) {
retval = usb_register_dev (&hiddev_driver, 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");
......
......@@ -727,6 +727,7 @@ static void *dabusb_probe (struct usb_device *usbdev, unsigned int ifnum,
const struct usb_device_id *id)
{
int devnum;
int retval;
pdabusb_t s;
dbg("dabusb: probe: vendor id 0x%x, device id 0x%x ifnum:%d",
......@@ -739,7 +740,10 @@ static void *dabusb_probe (struct usb_device *usbdev, unsigned int ifnum,
if (ifnum != _DABUSB_IF && usbdev->descriptor.idProduct == 0x9999)
return NULL;
if (usb_register_dev (&dabusb_driver, 1, &devnum)) {
retval = usb_register_dev (&dabusb_driver, 1, &devnum);
if (retval) {
if (retval != -ENODEV)
return NULL;
devnum = dabusb_find_struct ();
if (devnum == -1)
return NULL;
......
......@@ -1948,7 +1948,13 @@ static void *auerswald_probe (struct usb_device *usbdev, unsigned int ifnum,
init_waitqueue_head (&cp->bufferwait);
down (&dev_table_mutex);
if (usb_register_dev (&auerswald_driver, 1, &dtindex)) {
ret = usb_register_dev (&auerswald_driver, 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)
......
......@@ -290,6 +290,7 @@ brlvger_probe (struct usb_device *dev, unsigned ifnum,
{
struct brlvger_priv *priv = NULL;
int i;
int retval;
struct usb_endpoint_descriptor *endpoint;
struct usb_interface_descriptor *actifsettings;
/* protects against reentrance: once we've found a free slot
......@@ -315,7 +316,12 @@ brlvger_probe (struct usb_device *dev, unsigned ifnum,
down(&reserve_sem);
if (usb_register_dev(&brlvger_driver, 1, &i)) {
retval = usb_register_dev(&brlvger_driver, 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;
......
......@@ -525,6 +525,7 @@ static void * skel_probe(struct usb_device *udev, unsigned int ifnum, const stru
int minor;
int buffer_size;
int i;
int retval;
char name[10];
......@@ -535,14 +536,20 @@ static void * skel_probe(struct usb_device *udev, unsigned int ifnum, const stru
}
down (&minor_table_mutex);
if (usb_register_dev (&skel_driver, 1, &minor)) {
retval = usb_register_dev (&skel_driver, 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) {
info ("Too many devices plugged in, can not handle this device.");
err ("Too many devices plugged in, can not handle this device.");
goto exit;
}
}
......
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