]> err.no Git - linux-2.6/commitdiff
USB: fix __must_check warnings in drivers/usb/core/
authorGreg Kroah-Hartman <gregkh@suse.de>
Mon, 28 Aug 2006 18:43:25 +0000 (11:43 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 27 Sep 2006 18:58:57 +0000 (11:58 -0700)
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/devio.c
drivers/usb/core/driver.c
drivers/usb/core/endpoint.c
drivers/usb/core/sysfs.c
drivers/usb/core/usb.c
drivers/usb/core/usb.h

index fd345ad810f813c7c6bba3a148575c024f08161f..71bbd25a4ed03a8689fea58944110bcf863ec9a7 100644 (file)
@@ -1359,7 +1359,7 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)
        /* let kernel drivers try to (re)bind to the interface */
        case USBDEVFS_CONNECT:
                usb_unlock_device(ps->dev);
-               bus_rescan_devices(intf->dev.bus);
+               retval = bus_rescan_devices(intf->dev.bus);
                usb_lock_device(ps->dev);
                break;
 
index 0d063c8ca4b46017cde051bf4ae5b77aad7dec01..b10463244413c276846bbdcaebe58a0026ba4cbd 100644 (file)
@@ -49,6 +49,7 @@ static ssize_t store_new_id(struct device_driver *driver,
        u32 idVendor = 0;
        u32 idProduct = 0;
        int fields = 0;
+       int retval = 0;
 
        fields = sscanf(buf, "%x %x", &idVendor, &idProduct);
        if (fields < 2)
@@ -68,10 +69,12 @@ static ssize_t store_new_id(struct device_driver *driver,
        spin_unlock(&usb_drv->dynids.lock);
 
        if (get_driver(driver)) {
-               driver_attach(driver);
+               retval = driver_attach(driver);
                put_driver(driver);
        }
 
+       if (retval)
+               return retval;
        return count;
 }
 static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
@@ -291,6 +294,7 @@ int usb_driver_claim_interface(struct usb_driver *driver,
 {
        struct device *dev = &iface->dev;
        struct usb_device *udev = interface_to_usbdev(iface);
+       int retval = 0;
 
        if (dev->driver)
                return -EBUSY;
@@ -308,9 +312,9 @@ int usb_driver_claim_interface(struct usb_driver *driver,
         * the future device_add() bind it, bypassing probe()
         */
        if (device_is_registered(dev))
-               device_bind_driver(dev);
+               retval = device_bind_driver(dev);
 
-       return 0;
+       return retval;
 }
 EXPORT_SYMBOL(usb_driver_claim_interface);
 
index 247b5a4913a8079491f0104bfe5eaeaf972d8fd1..3ebb90149e93ef7319ae529c22da546032172730 100644 (file)
@@ -207,9 +207,9 @@ static void ep_device_release(struct device *dev)
        kfree(ep_dev);
 }
 
-void usb_create_ep_files(struct device *parent,
-                        struct usb_host_endpoint *endpoint,
-                        struct usb_device *udev)
+int usb_create_ep_files(struct device *parent,
+                       struct usb_host_endpoint *endpoint,
+                       struct usb_device *udev)
 {
        char name[8];
        struct ep_device *ep_dev;
@@ -242,19 +242,33 @@ void usb_create_ep_files(struct device *parent,
        retval = device_register(&ep_dev->dev);
        if (retval)
                goto error;
-       sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
+       retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
+       if (retval)
+               goto error_group;
 
        endpoint->ep_dev = ep_dev;
 
        /* create the symlink to the old-style "ep_XX" directory */
        sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress);
-       sysfs_create_link(&parent->kobj, &endpoint->ep_dev->dev.kobj, name);
-
+       retval = sysfs_create_link(&parent->kobj,
+                                  &endpoint->ep_dev->dev.kobj, name);
+       if (retval)
+               goto error_link;
 exit:
-       return;
+       return retval;
+
+error_link:
+       sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
+
+error_group:
+       device_unregister(&ep_dev->dev);
+       endpoint->ep_dev = NULL;
+       destroy_endpoint_class();
+       return retval;
 error:
        kfree(ep_dev);
-       return;
+       destroy_endpoint_class();
+       return retval;
 }
 
 void usb_remove_ep_files(struct usb_host_endpoint *endpoint)
index cd2286246f6ae811a6ab9b4b6560cc3dd14c9f2a..55d8f575206d6b1dcbfb0338e48a79b735a7ef9d 100644 (file)
@@ -210,19 +210,40 @@ static struct attribute_group dev_attr_grp = {
        .attrs = dev_attrs,
 };
 
-void usb_create_sysfs_dev_files (struct usb_device *udev)
+int usb_create_sysfs_dev_files(struct usb_device *udev)
 {
        struct device *dev = &udev->dev;
+       int retval;
 
-       sysfs_create_group(&dev->kobj, &dev_attr_grp);
+       retval = sysfs_create_group(&dev->kobj, &dev_attr_grp);
+       if (retval)
+               return retval;
 
-       if (udev->manufacturer)
-               device_create_file (dev, &dev_attr_manufacturer);
-       if (udev->product)
-               device_create_file (dev, &dev_attr_product);
-       if (udev->serial)
-               device_create_file (dev, &dev_attr_serial);
-       usb_create_ep_files(dev, &udev->ep0, udev);
+       if (udev->manufacturer) {
+               retval = device_create_file (dev, &dev_attr_manufacturer);
+               if (retval)
+                       goto error;
+       }
+       if (udev->product) {
+               retval = device_create_file (dev, &dev_attr_product);
+               if (retval)
+                       goto error;
+       }
+       if (udev->serial) {
+               retval = device_create_file (dev, &dev_attr_serial);
+               if (retval)
+                       goto error;
+       }
+       retval = usb_create_ep_files(dev, &udev->ep0, udev);
+       if (retval)
+               goto error;
+       return 0;
+error:
+       usb_remove_ep_files(&udev->ep0);
+       device_remove_file(dev, &dev_attr_manufacturer);
+       device_remove_file(dev, &dev_attr_product);
+       device_remove_file(dev, &dev_attr_serial);
+       return retval;
 }
 
 void usb_remove_sysfs_dev_files (struct usb_device *udev)
@@ -339,18 +360,28 @@ static inline void usb_remove_intf_ep_files(struct usb_interface *intf)
                usb_remove_ep_files(&iface_desc->endpoint[i]);
 }
 
-void usb_create_sysfs_intf_files (struct usb_interface *intf)
+int usb_create_sysfs_intf_files(struct usb_interface *intf)
 {
        struct usb_device *udev = interface_to_usbdev(intf);
        struct usb_host_interface *alt = intf->cur_altsetting;
+       int retval;
 
-       sysfs_create_group(&intf->dev.kobj, &intf_attr_grp);
+       retval = sysfs_create_group(&intf->dev.kobj, &intf_attr_grp);
+       if (retval)
+               goto error;
 
        if (alt->string == NULL)
                alt->string = usb_cache_string(udev, alt->desc.iInterface);
        if (alt->string)
-               device_create_file(&intf->dev, &dev_attr_interface);
+               retval = device_create_file(&intf->dev, &dev_attr_interface);
        usb_create_intf_ep_files(intf, udev);
+       return 0;
+error:
+       if (alt->string)
+               device_remove_file(&intf->dev, &dev_attr_interface);
+       sysfs_remove_group(&intf->dev.kobj, &intf_attr_grp);
+       usb_remove_intf_ep_files(intf);
+       return retval;
 }
 
 void usb_remove_sysfs_intf_files (struct usb_interface *intf)
index 6b029cdb8671b8f91d3087597b4d94771c0e592f..60ef4ef0101ae727567ec07bdd82d5b73cbf102e 100644 (file)
@@ -147,11 +147,13 @@ static int __find_interface(struct device * dev, void * data)
 struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor)
 {
        struct find_interface_arg argb;
+       int retval;
 
        argb.minor = minor;
        argb.interface = NULL;
-       driver_for_each_device(&drv->drvwrap.driver, NULL, &argb,
-                       __find_interface);
+       /* eat the error, it will be in argb.interface */
+       retval = driver_for_each_device(&drv->drvwrap.driver, NULL, &argb,
+                                       __find_interface);
        return argb.interface;
 }
 
index e8bc2e48913ab6717471761654f86f1e3c85b363..0c09ecced6e19721be1155623499d85cbec44d1d 100644 (file)
@@ -1,10 +1,10 @@
 /* Functions local to drivers/usb/core/ */
 
-extern void usb_create_sysfs_dev_files (struct usb_device *dev);
+extern int usb_create_sysfs_dev_files (struct usb_device *dev);
 extern void usb_remove_sysfs_dev_files (struct usb_device *dev);
-extern void usb_create_sysfs_intf_files (struct usb_interface *intf);
+extern int usb_create_sysfs_intf_files (struct usb_interface *intf);
 extern void usb_remove_sysfs_intf_files (struct usb_interface *intf);
-extern void usb_create_ep_files(struct device *parent, struct usb_host_endpoint *endpoint,
+extern int usb_create_ep_files(struct device *parent, struct usb_host_endpoint *endpoint,
                                struct usb_device *udev);
 extern void usb_remove_ep_files(struct usb_host_endpoint *endpoint);