|
@@ -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)
|