diff options
author | Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> | 2014-01-10 19:00:05 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-01-10 19:53:13 -0500 |
commit | c713cd7f2d799c50a0721bf51d178ea9567215dd (patch) | |
tree | d41b010703bca8b680054570511a4e88180d2fad | |
parent | d1badf8d4323cfc9325b06651bdfcf7df09f1f0e (diff) |
ACPI / scan: ACPI device object sysfs attribute for _STA evaluation
This patch adds a "status" attribute for an ACPI device. This status
attribute shows the value of the _STA object. The _STA object returns
current status of an ACPI device: enabled, disabled, functioning,
present.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
[rjw: Subject and changelog]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/acpi/scan.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 32b340171d41..c0f57ff15024 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -602,6 +602,20 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr, | |||
602 | } | 602 | } |
603 | static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL); | 603 | static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL); |
604 | 604 | ||
605 | static ssize_t status_show(struct device *dev, struct device_attribute *attr, | ||
606 | char *buf) { | ||
607 | struct acpi_device *acpi_dev = to_acpi_device(dev); | ||
608 | acpi_status status; | ||
609 | unsigned long long sta; | ||
610 | |||
611 | status = acpi_evaluate_integer(acpi_dev->handle, "_STA", NULL, &sta); | ||
612 | if (ACPI_FAILURE(status)) | ||
613 | return -ENODEV; | ||
614 | |||
615 | return sprintf(buf, "%llu\n", sta); | ||
616 | } | ||
617 | static DEVICE_ATTR_RO(status); | ||
618 | |||
605 | static int acpi_device_setup_files(struct acpi_device *dev) | 619 | static int acpi_device_setup_files(struct acpi_device *dev) |
606 | { | 620 | { |
607 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | 621 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; |
@@ -657,6 +671,12 @@ static int acpi_device_setup_files(struct acpi_device *dev) | |||
657 | dev->pnp.sun = (unsigned long)-1; | 671 | dev->pnp.sun = (unsigned long)-1; |
658 | } | 672 | } |
659 | 673 | ||
674 | if (acpi_has_method(dev->handle, "_STA")) { | ||
675 | result = device_create_file(&dev->dev, &dev_attr_status); | ||
676 | if (result) | ||
677 | goto end; | ||
678 | } | ||
679 | |||
660 | /* | 680 | /* |
661 | * If device has _EJ0, 'eject' file is created that is used to trigger | 681 | * If device has _EJ0, 'eject' file is created that is used to trigger |
662 | * hot-removal function from userland. | 682 | * hot-removal function from userland. |
@@ -712,6 +732,8 @@ static void acpi_device_remove_files(struct acpi_device *dev) | |||
712 | device_remove_file(&dev->dev, &dev_attr_adr); | 732 | device_remove_file(&dev->dev, &dev_attr_adr); |
713 | device_remove_file(&dev->dev, &dev_attr_modalias); | 733 | device_remove_file(&dev->dev, &dev_attr_modalias); |
714 | device_remove_file(&dev->dev, &dev_attr_hid); | 734 | device_remove_file(&dev->dev, &dev_attr_hid); |
735 | if (acpi_has_method(dev->handle, "_STA")) | ||
736 | device_remove_file(&dev->dev, &dev_attr_status); | ||
715 | if (dev->handle) | 737 | if (dev->handle) |
716 | device_remove_file(&dev->dev, &dev_attr_path); | 738 | device_remove_file(&dev->dev, &dev_attr_path); |
717 | } | 739 | } |