]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
USB: Add a sysfs file to show LTM capabilities.
authorSarah Sharp <sarah.a.sharp@linux.intel.com>
Fri, 6 Jul 2012 00:17:24 +0000 (17:17 -0700)
committerSarah Sharp <sarah.a.sharp@linux.intel.com>
Wed, 11 Jul 2012 11:06:48 +0000 (07:06 -0400)
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>
Documentation/ABI/testing/sysfs-bus-usb
drivers/usb/core/hub.c
drivers/usb/core/sysfs.c
include/linux/usb.h

index 6df4e6f575609047487a499e7289ff4fa6b0c5d0..5f75f8f7df341380d8bef013ad445ae509083916 100644 (file)
@@ -208,3 +208,15 @@ Description:
                such as ACPI. This file will read either "removable" or
                "fixed" if the information is available, and "unknown"
                otherwise.
+
+What:          /sys/bus/usb/devices/.../ltm_capable
+Date:          July 2012
+Contact:       Sarah Sharp <sarah.a.sharp@linux.intel.com>
+Description:
+               USB 3.0 devices may optionally support Latency Tolerance
+               Messaging (LTM).  They indicate their support by setting a bit
+               in the bmAttributes field of their SuperSpeed BOS descriptors.
+               If that bit is set for the device, ltm_capable will read "yes".
+               If the device doesn't support LTM, the file will read "no".
+               The file will be present for all speeds of USB devices, and will
+               always read "no" for USB 1.1 and USB 2.0 devices.
index b5bd6bd8fd12ac41e382f97d0948955c36933dc9..d739f966b5a8629b2baa9dce9200340fedf76ff1 100644 (file)
@@ -2610,13 +2610,6 @@ static int check_port_resume_type(struct usb_device *udev,
        return status;
 }
 
-static bool usb_device_supports_ltm(struct usb_device *udev)
-{
-       if (udev->speed != USB_SPEED_SUPER || !udev->bos || !udev->bos->ss_cap)
-               return false;
-       return udev->bos->ss_cap->bmAttributes & USB_LTM_SUPPORT;
-}
-
 int usb_disable_ltm(struct usb_device *udev)
 {
        struct usb_hcd *hcd = bus_to_hcd(udev->bus);
index 777f03c3772506526e69c4d1e14eab2f61dfd274..682e8256b95da719d3e5d2aeea019cc59c25520f 100644 (file)
@@ -253,6 +253,15 @@ show_removable(struct device *dev, struct device_attribute *attr, char *buf)
 }
 static DEVICE_ATTR(removable, S_IRUGO, show_removable, NULL);
 
+static ssize_t
+show_ltm_capable(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       if (usb_device_supports_ltm(to_usb_device(dev)))
+               return sprintf(buf, "%s\n", "yes");
+       return sprintf(buf, "%s\n", "no");
+}
+static DEVICE_ATTR(ltm_capable, S_IRUGO, show_ltm_capable, NULL);
+
 #ifdef CONFIG_PM
 
 static ssize_t
@@ -649,6 +658,7 @@ static struct attribute *dev_attrs[] = {
        &dev_attr_authorized.attr,
        &dev_attr_remove.attr,
        &dev_attr_removable.attr,
+       &dev_attr_ltm_capable.attr,
        NULL,
 };
 static struct attribute_group dev_attr_grp = {
index f29831bad235dc25b4b7c5473a43924cfb685fcb..f8506ed0f97bd8dd55e3d0f10f805f718bde160e 100644 (file)
@@ -636,6 +636,14 @@ extern void usb_unlocked_enable_lpm(struct usb_device *udev);
 extern int usb_disable_ltm(struct usb_device *udev);
 extern void usb_enable_ltm(struct usb_device *udev);
 
+static inline bool usb_device_supports_ltm(struct usb_device *udev)
+{
+       if (udev->speed != USB_SPEED_SUPER || !udev->bos || !udev->bos->ss_cap)
+               return false;
+       return udev->bos->ss_cap->bmAttributes & USB_LTM_SUPPORT;
+}
+
+
 /*-------------------------------------------------------------------------*/
 
 /* for drivers using iso endpoints */