aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/core/sysfs.c35
1 files changed, 9 insertions, 26 deletions
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 4fb65fdc9dc3..8c65fa75b5c2 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -812,32 +812,11 @@ struct attribute_group *usb_interface_groups[] = {
812 NULL 812 NULL
813}; 813};
814 814
815static inline void usb_create_intf_ep_files(struct usb_interface *intf,
816 struct usb_device *udev)
817{
818 struct usb_host_interface *iface_desc;
819 int i;
820
821 iface_desc = intf->cur_altsetting;
822 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i)
823 usb_create_ep_files(&intf->dev, &iface_desc->endpoint[i],
824 udev);
825}
826
827static inline void usb_remove_intf_ep_files(struct usb_interface *intf)
828{
829 struct usb_host_interface *iface_desc;
830 int i;
831
832 iface_desc = intf->cur_altsetting;
833 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i)
834 usb_remove_ep_files(&iface_desc->endpoint[i]);
835}
836
837int usb_create_sysfs_intf_files(struct usb_interface *intf) 815int usb_create_sysfs_intf_files(struct usb_interface *intf)
838{ 816{
839 struct usb_device *udev = interface_to_usbdev(intf); 817 struct usb_device *udev = interface_to_usbdev(intf);
840 struct usb_host_interface *alt = intf->cur_altsetting; 818 struct usb_host_interface *alt = intf->cur_altsetting;
819 int i;
841 int retval; 820 int retval;
842 821
843 if (intf->sysfs_files_created || intf->unregistering) 822 if (intf->sysfs_files_created || intf->unregistering)
@@ -851,18 +830,22 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
851 alt->string = usb_cache_string(udev, alt->desc.iInterface); 830 alt->string = usb_cache_string(udev, alt->desc.iInterface);
852 if (alt->string) 831 if (alt->string)
853 retval = device_create_file(&intf->dev, &dev_attr_interface); 832 retval = device_create_file(&intf->dev, &dev_attr_interface);
854 usb_create_intf_ep_files(intf, udev); 833 for (i = 0; i < alt->desc.bNumEndpoints; ++i)
834 usb_create_ep_files(&intf->dev, &alt->endpoint[i], udev);
855 intf->sysfs_files_created = 1; 835 intf->sysfs_files_created = 1;
856 return 0; 836 return 0;
857} 837}
858 838
859void usb_remove_sysfs_intf_files(struct usb_interface *intf) 839void usb_remove_sysfs_intf_files(struct usb_interface *intf)
860{ 840{
861 struct device *dev = &intf->dev; 841 struct usb_host_interface *alt = intf->cur_altsetting;
842 int i;
862 843
863 if (!intf->sysfs_files_created) 844 if (!intf->sysfs_files_created)
864 return; 845 return;
865 usb_remove_intf_ep_files(intf); 846
866 device_remove_file(dev, &dev_attr_interface); 847 for (i = 0; i < alt->desc.bNumEndpoints; ++i)
848 usb_remove_ep_files(&alt->endpoint[i]);
849 device_remove_file(&intf->dev, &dev_attr_interface);
867 intf->sysfs_files_created = 0; 850 intf->sysfs_files_created = 0;
868} 851}