mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-07 07:05:20 +00:00
USB: minor cleanups for sysfs.c
This patch (as858) makes some minor cleanups to sysfs.c in usbcore. Unnecessary tests are removed and a few temp variables are added. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
7ceec1f1d2
commit
aa084f3efe
1 changed files with 12 additions and 24 deletions
|
@ -250,10 +250,7 @@ int usb_create_sysfs_dev_files(struct usb_device *udev)
|
||||||
goto error;
|
goto error;
|
||||||
return 0;
|
return 0;
|
||||||
error:
|
error:
|
||||||
usb_remove_ep_files(&udev->ep0);
|
usb_remove_sysfs_dev_files(udev);
|
||||||
device_remove_file(dev, &dev_attr_manufacturer);
|
|
||||||
device_remove_file(dev, &dev_attr_product);
|
|
||||||
device_remove_file(dev, &dev_attr_serial);
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,14 +259,10 @@ void usb_remove_sysfs_dev_files(struct usb_device *udev)
|
||||||
struct device *dev = &udev->dev;
|
struct device *dev = &udev->dev;
|
||||||
|
|
||||||
usb_remove_ep_files(&udev->ep0);
|
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);
|
||||||
sysfs_remove_group(&dev->kobj, &dev_attr_grp);
|
sysfs_remove_group(&dev->kobj, &dev_attr_grp);
|
||||||
|
|
||||||
if (udev->manufacturer)
|
|
||||||
device_remove_file(dev, &dev_attr_manufacturer);
|
|
||||||
if (udev->product)
|
|
||||||
device_remove_file(dev, &dev_attr_product);
|
|
||||||
if (udev->serial)
|
|
||||||
device_remove_file(dev, &dev_attr_serial);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Interface fields */
|
/* Interface fields */
|
||||||
|
@ -373,33 +366,28 @@ static inline void usb_remove_intf_ep_files(struct usb_interface *intf)
|
||||||
|
|
||||||
int usb_create_sysfs_intf_files(struct usb_interface *intf)
|
int usb_create_sysfs_intf_files(struct usb_interface *intf)
|
||||||
{
|
{
|
||||||
|
struct device *dev = &intf->dev;
|
||||||
struct usb_device *udev = interface_to_usbdev(intf);
|
struct usb_device *udev = interface_to_usbdev(intf);
|
||||||
struct usb_host_interface *alt = intf->cur_altsetting;
|
struct usb_host_interface *alt = intf->cur_altsetting;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
retval = sysfs_create_group(&intf->dev.kobj, &intf_attr_grp);
|
retval = sysfs_create_group(&dev->kobj, &intf_attr_grp);
|
||||||
if (retval)
|
if (retval)
|
||||||
goto error;
|
return retval;
|
||||||
|
|
||||||
if (alt->string == NULL)
|
if (alt->string == NULL)
|
||||||
alt->string = usb_cache_string(udev, alt->desc.iInterface);
|
alt->string = usb_cache_string(udev, alt->desc.iInterface);
|
||||||
if (alt->string)
|
if (alt->string)
|
||||||
retval = device_create_file(&intf->dev, &dev_attr_interface);
|
retval = device_create_file(dev, &dev_attr_interface);
|
||||||
usb_create_intf_ep_files(intf, udev);
|
usb_create_intf_ep_files(intf, udev);
|
||||||
return 0;
|
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)
|
void usb_remove_sysfs_intf_files(struct usb_interface *intf)
|
||||||
{
|
{
|
||||||
usb_remove_intf_ep_files(intf);
|
struct device *dev = &intf->dev;
|
||||||
sysfs_remove_group(&intf->dev.kobj, &intf_attr_grp);
|
|
||||||
|
|
||||||
if (intf->cur_altsetting->string)
|
usb_remove_intf_ep_files(intf);
|
||||||
device_remove_file(&intf->dev, &dev_attr_interface);
|
device_remove_file(dev, &dev_attr_interface);
|
||||||
|
sysfs_remove_group(&dev->kobj, &intf_attr_grp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue