Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+30 -7
+12
Documentation/ABI/testing/sysfs-bus-usb
··· 208 208 such as ACPI. This file will read either "removable" or 209 209 "fixed" if the information is available, and "unknown" 210 210 otherwise. 211 + 212 + What: /sys/bus/usb/devices/.../ltm_capable 213 + Date: July 2012 214 + Contact: Sarah Sharp <sarah.a.sharp@linux.intel.com> 215 + Description: 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.
-7
drivers/usb/core/hub.c
··· 2610 2610 return status; 2611 2611 } 2612 2612 2613 - static 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 - 2620 2613 int usb_disable_ltm(struct usb_device *udev) 2621 2614 { 2622 2615 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
+10
drivers/usb/core/sysfs.c
··· 253 253 } 254 254 static DEVICE_ATTR(removable, S_IRUGO, show_removable, NULL); 255 255 256 + static ssize_t 257 + show_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 + } 263 + static DEVICE_ATTR(ltm_capable, S_IRUGO, show_ltm_capable, NULL); 264 + 256 265 #ifdef CONFIG_PM 257 266 258 267 static ssize_t ··· 658 649 &dev_attr_authorized.attr, 659 650 &dev_attr_remove.attr, 660 651 &dev_attr_removable.attr, 652 + &dev_attr_ltm_capable.attr, 661 653 NULL, 662 654 }; 663 655 static struct attribute_group dev_attr_grp = {
+8
include/linux/usb.h
··· 636 636 extern int usb_disable_ltm(struct usb_device *udev); 637 637 extern void usb_enable_ltm(struct usb_device *udev); 638 638 639 + static 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 649 /* for drivers using iso endpoints */