diff options
author | Fabien Chouteau <fabien.chouteau@barco.com> | 2010-04-23 08:21:26 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-20 16:21:39 -0400 |
commit | f48cf80f93ba974eb3201ab2d0f2c4cef950f3fc (patch) | |
tree | a90ec04a891d1698110372791d01a03d90c6da3f /drivers/usb/gadget | |
parent | 326b4810cc995209e31136af4202ed0414814ed5 (diff) |
USB: Composite framework: Add suspended sysfs entry
This patch adds a sysfs entry (/sys/devices/platform/_UDC_/gadget/suspended) to
show the suspend state of an USB composite gadget.
Signed-off-by: Fabien Chouteau <fabien.chouteau@barco.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/composite.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 5465d8767f9..f9aff1bbcb3 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -898,6 +898,18 @@ static void composite_disconnect(struct usb_gadget *gadget) | |||
898 | 898 | ||
899 | /*-------------------------------------------------------------------------*/ | 899 | /*-------------------------------------------------------------------------*/ |
900 | 900 | ||
901 | static ssize_t composite_show_suspended(struct device *dev, | ||
902 | struct device_attribute *attr, | ||
903 | char *buf) | ||
904 | { | ||
905 | struct usb_gadget *gadget = dev_to_usb_gadget(dev); | ||
906 | struct usb_composite_dev *cdev = get_gadget_data(gadget); | ||
907 | |||
908 | return sprintf(buf, "%d\n", cdev->suspended); | ||
909 | } | ||
910 | |||
911 | static DEVICE_ATTR(suspended, 0444, composite_show_suspended, NULL); | ||
912 | |||
901 | static void /* __init_or_exit */ | 913 | static void /* __init_or_exit */ |
902 | composite_unbind(struct usb_gadget *gadget) | 914 | composite_unbind(struct usb_gadget *gadget) |
903 | { | 915 | { |
@@ -944,6 +956,7 @@ composite_unbind(struct usb_gadget *gadget) | |||
944 | } | 956 | } |
945 | kfree(cdev); | 957 | kfree(cdev); |
946 | set_gadget_data(gadget, NULL); | 958 | set_gadget_data(gadget, NULL); |
959 | device_remove_file(&gadget->dev, &dev_attr_suspended); | ||
947 | composite = NULL; | 960 | composite = NULL; |
948 | } | 961 | } |
949 | 962 | ||
@@ -1036,6 +1049,10 @@ static int __init composite_bind(struct usb_gadget *gadget) | |||
1036 | string_override(composite->strings, | 1049 | string_override(composite->strings, |
1037 | cdev->desc.iSerialNumber, iSerialNumber); | 1050 | cdev->desc.iSerialNumber, iSerialNumber); |
1038 | 1051 | ||
1052 | status = device_create_file(&gadget->dev, &dev_attr_suspended); | ||
1053 | if (status) | ||
1054 | goto fail; | ||
1055 | |||
1039 | INFO(cdev, "%s ready\n", composite->name); | 1056 | INFO(cdev, "%s ready\n", composite->name); |
1040 | return 0; | 1057 | return 0; |
1041 | 1058 | ||
@@ -1064,6 +1081,8 @@ composite_suspend(struct usb_gadget *gadget) | |||
1064 | } | 1081 | } |
1065 | if (composite->suspend) | 1082 | if (composite->suspend) |
1066 | composite->suspend(cdev); | 1083 | composite->suspend(cdev); |
1084 | |||
1085 | cdev->suspended = 1; | ||
1067 | } | 1086 | } |
1068 | 1087 | ||
1069 | static void | 1088 | static void |
@@ -1084,6 +1103,8 @@ composite_resume(struct usb_gadget *gadget) | |||
1084 | f->resume(f); | 1103 | f->resume(f); |
1085 | } | 1104 | } |
1086 | } | 1105 | } |
1106 | |||
1107 | cdev->suspended = 0; | ||
1087 | } | 1108 | } |
1088 | 1109 | ||
1089 | /*-------------------------------------------------------------------------*/ | 1110 | /*-------------------------------------------------------------------------*/ |