aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core/sysfs.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2011-11-29 04:51:07 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2011-11-29 04:51:07 -0500
commit0d2cd91bf7b1a7cc1d638296111fcc2bcf5c0bb4 (patch)
treed2ca69347816c27f9dc352581f5d0fe76811cd49 /drivers/usb/core/sysfs.c
parent3d95fd6ad8d3cf582a70ed65660017114b6e4065 (diff)
parentcaca6a03d365883564885f2c1da3e88dcf65d139 (diff)
Merge commit 'v3.2-rc3' into next
Diffstat (limited to 'drivers/usb/core/sysfs.c')
-rw-r--r--drivers/usb/core/sysfs.c59
1 files changed, 58 insertions, 1 deletions
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index cf05b97693ea..662c0cf3a3e1 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -412,6 +412,56 @@ set_level(struct device *dev, struct device_attribute *attr,
412 412
413static DEVICE_ATTR(level, S_IRUGO | S_IWUSR, show_level, set_level); 413static DEVICE_ATTR(level, S_IRUGO | S_IWUSR, show_level, set_level);
414 414
415static ssize_t
416show_usb2_hardware_lpm(struct device *dev, struct device_attribute *attr,
417 char *buf)
418{
419 struct usb_device *udev = to_usb_device(dev);
420 const char *p;
421
422 if (udev->usb2_hw_lpm_enabled == 1)
423 p = "enabled";
424 else
425 p = "disabled";
426
427 return sprintf(buf, "%s\n", p);
428}
429
430static ssize_t
431set_usb2_hardware_lpm(struct device *dev, struct device_attribute *attr,
432 const char *buf, size_t count)
433{
434 struct usb_device *udev = to_usb_device(dev);
435 bool value;
436 int ret;
437
438 usb_lock_device(udev);
439
440 ret = strtobool(buf, &value);
441
442 if (!ret)
443 ret = usb_set_usb2_hardware_lpm(udev, value);
444
445 usb_unlock_device(udev);
446
447 if (!ret)
448 return count;
449
450 return ret;
451}
452
453static DEVICE_ATTR(usb2_hardware_lpm, S_IRUGO | S_IWUSR, show_usb2_hardware_lpm,
454 set_usb2_hardware_lpm);
455
456static struct attribute *usb2_hardware_lpm_attr[] = {
457 &dev_attr_usb2_hardware_lpm.attr,
458 NULL,
459};
460static struct attribute_group usb2_hardware_lpm_attr_group = {
461 .name = power_group_name,
462 .attrs = usb2_hardware_lpm_attr,
463};
464
415static struct attribute *power_attrs[] = { 465static struct attribute *power_attrs[] = {
416 &dev_attr_autosuspend.attr, 466 &dev_attr_autosuspend.attr,
417 &dev_attr_level.attr, 467 &dev_attr_level.attr,
@@ -428,13 +478,20 @@ static int add_power_attributes(struct device *dev)
428{ 478{
429 int rc = 0; 479 int rc = 0;
430 480
431 if (is_usb_device(dev)) 481 if (is_usb_device(dev)) {
482 struct usb_device *udev = to_usb_device(dev);
432 rc = sysfs_merge_group(&dev->kobj, &power_attr_group); 483 rc = sysfs_merge_group(&dev->kobj, &power_attr_group);
484 if (udev->usb2_hw_lpm_capable == 1)
485 rc = sysfs_merge_group(&dev->kobj,
486 &usb2_hardware_lpm_attr_group);
487 }
488
433 return rc; 489 return rc;
434} 490}
435 491
436static void remove_power_attributes(struct device *dev) 492static void remove_power_attributes(struct device *dev)
437{ 493{
494 sysfs_unmerge_group(&dev->kobj, &usb2_hardware_lpm_attr_group);
438 sysfs_unmerge_group(&dev->kobj, &power_attr_group); 495 sysfs_unmerge_group(&dev->kobj, &power_attr_group);
439} 496}
440 497