aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSarah Sharp <sarah.a.sharp@linux.intel.com>2012-07-05 20:17:24 -0400
committerSarah Sharp <sarah.a.sharp@linux.intel.com>2012-07-11 07:06:48 -0400
commit024f117c2f3c4bb5df6e6696b709e0f3ed7e5dbb (patch)
tree3ad556877608c58bd7844f82810dfc0d471d4f63
parentf74631e3426474183389e55f703797bd965cd356 (diff)
USB: Add a sysfs file to show LTM capabilities.
USB 3.0 devices can optionally support Latency Tolerance Messaging (LTM). Add a new sysfs file in the device directory to show whether a device is LTM capable. This file will be present for both USB 2.0 and USB 3.0 devices. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
-rw-r--r--Documentation/ABI/testing/sysfs-bus-usb12
-rw-r--r--drivers/usb/core/hub.c7
-rw-r--r--drivers/usb/core/sysfs.c10
-rw-r--r--include/linux/usb.h8
4 files changed, 30 insertions, 7 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-usb b/Documentation/ABI/testing/sysfs-bus-usb
index 6df4e6f57560..5f75f8f7df34 100644
--- a/Documentation/ABI/testing/sysfs-bus-usb
+++ b/Documentation/ABI/testing/sysfs-bus-usb
@@ -208,3 +208,15 @@ Description:
208 such as ACPI. This file will read either "removable" or 208 such as ACPI. This file will read either "removable" or
209 "fixed" if the information is available, and "unknown" 209 "fixed" if the information is available, and "unknown"
210 otherwise. 210 otherwise.
211
212What: /sys/bus/usb/devices/.../ltm_capable
213Date: July 2012
214Contact: Sarah Sharp <sarah.a.sharp@linux.intel.com>
215Description:
216 USB 3.0 devices may optionally support Latency Tolerance
217 Messaging (LTM). They indicate their support by setting a bit
218 in the bmAttributes field of their SuperSpeed BOS descriptors.
219 If that bit is set for the device, ltm_capable will read "yes".
220 If the device doesn't support LTM, the file will read "no".
221 The file will be present for all speeds of USB devices, and will
222 always read "no" for USB 1.1 and USB 2.0 devices.
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index b5bd6bd8fd12..d739f966b5a8 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2610,13 +2610,6 @@ static int check_port_resume_type(struct usb_device *udev,
2610 return status; 2610 return status;
2611} 2611}
2612 2612
2613static bool usb_device_supports_ltm(struct usb_device *udev)
2614{
2615 if (udev->speed != USB_SPEED_SUPER || !udev->bos || !udev->bos->ss_cap)
2616 return false;
2617 return udev->bos->ss_cap->bmAttributes & USB_LTM_SUPPORT;
2618}
2619
2620int usb_disable_ltm(struct usb_device *udev) 2613int usb_disable_ltm(struct usb_device *udev)
2621{ 2614{
2622 struct usb_hcd *hcd = bus_to_hcd(udev->bus); 2615 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 777f03c37725..682e8256b95d 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -253,6 +253,15 @@ show_removable(struct device *dev, struct device_attribute *attr, char *buf)
253} 253}
254static DEVICE_ATTR(removable, S_IRUGO, show_removable, NULL); 254static DEVICE_ATTR(removable, S_IRUGO, show_removable, NULL);
255 255
256static ssize_t
257show_ltm_capable(struct device *dev, struct device_attribute *attr, char *buf)
258{
259 if (usb_device_supports_ltm(to_usb_device(dev)))
260 return sprintf(buf, "%s\n", "yes");
261 return sprintf(buf, "%s\n", "no");
262}
263static DEVICE_ATTR(ltm_capable, S_IRUGO, show_ltm_capable, NULL);
264
256#ifdef CONFIG_PM 265#ifdef CONFIG_PM
257 266
258static ssize_t 267static ssize_t
@@ -649,6 +658,7 @@ static struct attribute *dev_attrs[] = {
649 &dev_attr_authorized.attr, 658 &dev_attr_authorized.attr,
650 &dev_attr_remove.attr, 659 &dev_attr_remove.attr,
651 &dev_attr_removable.attr, 660 &dev_attr_removable.attr,
661 &dev_attr_ltm_capable.attr,
652 NULL, 662 NULL,
653}; 663};
654static struct attribute_group dev_attr_grp = { 664static struct attribute_group dev_attr_grp = {
diff --git a/include/linux/usb.h b/include/linux/usb.h
index f29831bad235..f8506ed0f97b 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -636,6 +636,14 @@ extern void usb_unlocked_enable_lpm(struct usb_device *udev);
636extern int usb_disable_ltm(struct usb_device *udev); 636extern int usb_disable_ltm(struct usb_device *udev);
637extern void usb_enable_ltm(struct usb_device *udev); 637extern void usb_enable_ltm(struct usb_device *udev);
638 638
639static inline bool usb_device_supports_ltm(struct usb_device *udev)
640{
641 if (udev->speed != USB_SPEED_SUPER || !udev->bos || !udev->bos->ss_cap)
642 return false;
643 return udev->bos->ss_cap->bmAttributes & USB_LTM_SUPPORT;
644}
645
646
639/*-------------------------------------------------------------------------*/ 647/*-------------------------------------------------------------------------*/
640 648
641/* for drivers using iso endpoints */ 649/* for drivers using iso endpoints */