diff options
author | Mathias Nyman <mathias.nyman@linux.intel.com> | 2013-05-23 10:14:31 -0400 |
---|---|---|
committer | Sarah Sharp <sarah.a.sharp@linux.intel.com> | 2013-06-05 19:48:40 -0400 |
commit | 17f34867e98d2fb0c03918faab79efb989fa134b (patch) | |
tree | 1ea3f266473f6d6aa7fec9a646e04158941d0a06 /drivers/usb/core/sysfs.c | |
parent | a558ccdcc71c7770c5e80c926a31cfe8a3892a09 (diff) |
usb: add usb2 Link PM variables to sysfs and usb_device
Adds abitilty to tune L1 timeout (inactivity timer for usb2 link sleep)
and BESL (best effort service latency)via sysfs.
This also adds a new usb2_lpm_parameters structure with those variables to
struct usb_device.
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Diffstat (limited to 'drivers/usb/core/sysfs.c')
-rw-r--r-- | drivers/usb/core/sysfs.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index aa38db44818a..d9284b998bd7 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -497,8 +497,62 @@ set_usb2_hardware_lpm(struct device *dev, struct device_attribute *attr, | |||
497 | static DEVICE_ATTR(usb2_hardware_lpm, S_IRUGO | S_IWUSR, show_usb2_hardware_lpm, | 497 | static DEVICE_ATTR(usb2_hardware_lpm, S_IRUGO | S_IWUSR, show_usb2_hardware_lpm, |
498 | set_usb2_hardware_lpm); | 498 | set_usb2_hardware_lpm); |
499 | 499 | ||
500 | static ssize_t | ||
501 | show_usb2_lpm_l1_timeout(struct device *dev, struct device_attribute *attr, | ||
502 | char *buf) | ||
503 | { | ||
504 | struct usb_device *udev = to_usb_device(dev); | ||
505 | return sprintf(buf, "%d\n", udev->l1_params.timeout); | ||
506 | } | ||
507 | |||
508 | static ssize_t | ||
509 | set_usb2_lpm_l1_timeout(struct device *dev, struct device_attribute *attr, | ||
510 | const char *buf, size_t count) | ||
511 | { | ||
512 | struct usb_device *udev = to_usb_device(dev); | ||
513 | u16 timeout; | ||
514 | |||
515 | if (kstrtou16(buf, 0, &timeout)) | ||
516 | return -EINVAL; | ||
517 | |||
518 | udev->l1_params.timeout = timeout; | ||
519 | |||
520 | return count; | ||
521 | } | ||
522 | |||
523 | static DEVICE_ATTR(usb2_lpm_l1_timeout, S_IRUGO | S_IWUSR, | ||
524 | show_usb2_lpm_l1_timeout, set_usb2_lpm_l1_timeout); | ||
525 | |||
526 | static ssize_t | ||
527 | show_usb2_lpm_besl(struct device *dev, struct device_attribute *attr, | ||
528 | char *buf) | ||
529 | { | ||
530 | struct usb_device *udev = to_usb_device(dev); | ||
531 | return sprintf(buf, "%d\n", udev->l1_params.besl); | ||
532 | } | ||
533 | |||
534 | static ssize_t | ||
535 | set_usb2_lpm_besl(struct device *dev, struct device_attribute *attr, | ||
536 | const char *buf, size_t count) | ||
537 | { | ||
538 | struct usb_device *udev = to_usb_device(dev); | ||
539 | u8 besl; | ||
540 | |||
541 | if (kstrtou8(buf, 0, &besl) || besl > 15) | ||
542 | return -EINVAL; | ||
543 | |||
544 | udev->l1_params.besl = besl; | ||
545 | |||
546 | return count; | ||
547 | } | ||
548 | |||
549 | static DEVICE_ATTR(usb2_lpm_besl, S_IRUGO | S_IWUSR, | ||
550 | show_usb2_lpm_besl, set_usb2_lpm_besl); | ||
551 | |||
500 | static struct attribute *usb2_hardware_lpm_attr[] = { | 552 | static struct attribute *usb2_hardware_lpm_attr[] = { |
501 | &dev_attr_usb2_hardware_lpm.attr, | 553 | &dev_attr_usb2_hardware_lpm.attr, |
554 | &dev_attr_usb2_lpm_l1_timeout.attr, | ||
555 | &dev_attr_usb2_lpm_besl.attr, | ||
502 | NULL, | 556 | NULL, |
503 | }; | 557 | }; |
504 | static struct attribute_group usb2_hardware_lpm_attr_group = { | 558 | static struct attribute_group usb2_hardware_lpm_attr_group = { |