diff options
author | Sarah Sharp <sarah.a.sharp@linux.intel.com> | 2008-10-06 17:45:46 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-10-17 17:41:03 -0400 |
commit | 49e7cc84a86784ef2ab4e651f1824093be8f5b2b (patch) | |
tree | 0bd664b1df6cd48382bcb51771ca3eac362697ee /drivers/usb | |
parent | eafe5b99f2135488b21cf17a262c54997c44f784 (diff) |
USB: Export if an interface driver supports autosuspend.
Create a new sysfs file per interface named supports_autosuspend. This
file returns true if an interface driver's .supports_autosuspend flag is
set. It also returns true if the interface is unclaimed (since the USB
core will autosuspend a device if an interface is not claimed).
This new sysfs file will be useful for user space scripts to test whether
a USB device correctly auto-suspends.
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: Oliver Neukum <oliver@neukum.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/core/sysfs.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 5e1f5d55bf04..f66fba11fbd5 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -743,6 +743,29 @@ static ssize_t show_modalias(struct device *dev, | |||
743 | } | 743 | } |
744 | static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); | 744 | static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); |
745 | 745 | ||
746 | static ssize_t show_supports_autosuspend(struct device *dev, | ||
747 | struct device_attribute *attr, char *buf) | ||
748 | { | ||
749 | struct usb_interface *intf; | ||
750 | struct usb_device *udev; | ||
751 | int ret; | ||
752 | |||
753 | intf = to_usb_interface(dev); | ||
754 | udev = interface_to_usbdev(intf); | ||
755 | |||
756 | usb_lock_device(udev); | ||
757 | /* Devices will be autosuspended even when an interface isn't claimed */ | ||
758 | if (!intf->dev.driver || | ||
759 | to_usb_driver(intf->dev.driver)->supports_autosuspend) | ||
760 | ret = sprintf(buf, "%u\n", 1); | ||
761 | else | ||
762 | ret = sprintf(buf, "%u\n", 0); | ||
763 | usb_unlock_device(udev); | ||
764 | |||
765 | return ret; | ||
766 | } | ||
767 | static DEVICE_ATTR(supports_autosuspend, S_IRUGO, show_supports_autosuspend, NULL); | ||
768 | |||
746 | static struct attribute *intf_attrs[] = { | 769 | static struct attribute *intf_attrs[] = { |
747 | &dev_attr_bInterfaceNumber.attr, | 770 | &dev_attr_bInterfaceNumber.attr, |
748 | &dev_attr_bAlternateSetting.attr, | 771 | &dev_attr_bAlternateSetting.attr, |
@@ -751,6 +774,7 @@ static struct attribute *intf_attrs[] = { | |||
751 | &dev_attr_bInterfaceSubClass.attr, | 774 | &dev_attr_bInterfaceSubClass.attr, |
752 | &dev_attr_bInterfaceProtocol.attr, | 775 | &dev_attr_bInterfaceProtocol.attr, |
753 | &dev_attr_modalias.attr, | 776 | &dev_attr_modalias.attr, |
777 | &dev_attr_supports_autosuspend.attr, | ||
754 | NULL, | 778 | NULL, |
755 | }; | 779 | }; |
756 | static struct attribute_group intf_attr_grp = { | 780 | static struct attribute_group intf_attr_grp = { |