aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core/sysfs.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2008-12-05 14:10:34 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-01-07 13:00:08 -0500
commit3b23dd6f8a718e5339de4f7d86ce76a078b5f771 (patch)
tree500a0402d7d8ba9afefc316124c1a6b4b4d575b2 /drivers/usb/core/sysfs.c
parentb9cef6c31913c34fb1065b1d01e04c3b92c59016 (diff)
USB: utilize the bus notifiers
This patch (as1185) makes usbcore take advantage of the bus notifications sent out by the driver core. Now we can create all our device and interface attribute files before the device or interface uevent is broadcast. A side effect is that we no longer create the endpoint "pseudo" devices at the same time as a device or interface is registered -- it seems like a bad idea to try registering an endpoint before the registration of its parent is complete. So the routines for creating and removing endpoint devices have been split out and renamed, and they are called explicitly when needed. A new bitflag is used for keeping track of whether or not the interface's endpoint devices have been created, since (just as with the interface attributes) they vary with the altsetting and hence can be changed at random times. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/core/sysfs.c')
-rw-r--r--drivers/usb/core/sysfs.c22
1 files changed, 1 insertions, 21 deletions
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 0f0ccf640114..4cc2456ef3be 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -629,9 +629,6 @@ int usb_create_sysfs_dev_files(struct usb_device *udev)
629 struct device *dev = &udev->dev; 629 struct device *dev = &udev->dev;
630 int retval; 630 int retval;
631 631
632 /* Unforunately these attributes cannot be created before
633 * the uevent is broadcast.
634 */
635 retval = device_create_bin_file(dev, &dev_bin_attr_descriptors); 632 retval = device_create_bin_file(dev, &dev_bin_attr_descriptors);
636 if (retval) 633 if (retval)
637 goto error; 634 goto error;
@@ -643,11 +640,7 @@ int usb_create_sysfs_dev_files(struct usb_device *udev)
643 retval = add_power_attributes(dev); 640 retval = add_power_attributes(dev);
644 if (retval) 641 if (retval)
645 goto error; 642 goto error;
646 643 return retval;
647 retval = usb_create_ep_files(dev, &udev->ep0, udev);
648 if (retval)
649 goto error;
650 return 0;
651error: 644error:
652 usb_remove_sysfs_dev_files(udev); 645 usb_remove_sysfs_dev_files(udev);
653 return retval; 646 return retval;
@@ -657,7 +650,6 @@ void usb_remove_sysfs_dev_files(struct usb_device *udev)
657{ 650{
658 struct device *dev = &udev->dev; 651 struct device *dev = &udev->dev;
659 652
660 usb_remove_ep_files(&udev->ep0);
661 remove_power_attributes(dev); 653 remove_power_attributes(dev);
662 remove_persist_attributes(dev); 654 remove_persist_attributes(dev);
663 device_remove_bin_file(dev, &dev_bin_attr_descriptors); 655 device_remove_bin_file(dev, &dev_bin_attr_descriptors);
@@ -816,36 +808,24 @@ int usb_create_sysfs_intf_files(struct usb_interface *intf)
816{ 808{
817 struct usb_device *udev = interface_to_usbdev(intf); 809 struct usb_device *udev = interface_to_usbdev(intf);
818 struct usb_host_interface *alt = intf->cur_altsetting; 810 struct usb_host_interface *alt = intf->cur_altsetting;
819 int i;
820 int retval; 811 int retval;
821 812
822 if (intf->sysfs_files_created || intf->unregistering) 813 if (intf->sysfs_files_created || intf->unregistering)
823 return 0; 814 return 0;
824 815
825 /* The interface string may be present in some altsettings
826 * and missing in others. Hence its attribute cannot be created
827 * before the uevent is broadcast.
828 */
829 if (alt->string == NULL) 816 if (alt->string == NULL)
830 alt->string = usb_cache_string(udev, alt->desc.iInterface); 817 alt->string = usb_cache_string(udev, alt->desc.iInterface);
831 if (alt->string) 818 if (alt->string)
832 retval = device_create_file(&intf->dev, &dev_attr_interface); 819 retval = device_create_file(&intf->dev, &dev_attr_interface);
833 for (i = 0; i < alt->desc.bNumEndpoints; ++i)
834 usb_create_ep_files(&intf->dev, &alt->endpoint[i], udev);
835 intf->sysfs_files_created = 1; 820 intf->sysfs_files_created = 1;
836 return 0; 821 return 0;
837} 822}
838 823
839void usb_remove_sysfs_intf_files(struct usb_interface *intf) 824void usb_remove_sysfs_intf_files(struct usb_interface *intf)
840{ 825{
841 struct usb_host_interface *alt = intf->cur_altsetting;
842 int i;
843
844 if (!intf->sysfs_files_created) 826 if (!intf->sysfs_files_created)
845 return; 827 return;
846 828
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); 829 device_remove_file(&intf->dev, &dev_attr_interface);
850 intf->sysfs_files_created = 0; 830 intf->sysfs_files_created = 0;
851} 831}