aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBetty Dall <betty.dall@hpe.com>2016-04-30 12:03:37 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-05-04 17:47:31 -0400
commit6283f97d5fbfdd1e31694d7f6000eb728cdfba77 (patch)
tree94aaf61a8cd41f9779103adf9d7b6e309358cd60
parent2b13f01b90fc07334911b424709901bb88517746 (diff)
ACPI / device_sysfs: Add sysfs support for _HRV hardware revision
The ACPI _HRV object on the device is used to supply Linux with the device's hardware revision. This is an optional object. Add sysfs support for the _HRV object if it exists on the device. This change allows users to easily find the hardware version of non-PCI hardware by looking at the sysfs 'hrv' file. It is most useful for non-PCI devices because lspci can list the hardware version for PCI devices. Signed-off-by: Betty Dall <betty.dall@hpe.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/device_sysfs.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index b9afb47db7ed..49cc0cbff0b8 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -473,6 +473,21 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
473} 473}
474static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL); 474static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
475 475
476static ssize_t
477acpi_device_hrv_show(struct device *dev, struct device_attribute *attr,
478 char *buf) {
479 struct acpi_device *acpi_dev = to_acpi_device(dev);
480 acpi_status status;
481 unsigned long long hrv;
482
483 status = acpi_evaluate_integer(acpi_dev->handle, "_HRV", NULL, &hrv);
484 if (ACPI_FAILURE(status))
485 return -EIO;
486
487 return sprintf(buf, "%llu\n", hrv);
488}
489static DEVICE_ATTR(hrv, 0444, acpi_device_hrv_show, NULL);
490
476static ssize_t status_show(struct device *dev, struct device_attribute *attr, 491static ssize_t status_show(struct device *dev, struct device_attribute *attr,
477 char *buf) { 492 char *buf) {
478 struct acpi_device *acpi_dev = to_acpi_device(dev); 493 struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -541,6 +556,12 @@ int acpi_device_setup_files(struct acpi_device *dev)
541 goto end; 556 goto end;
542 } 557 }
543 558
559 if (acpi_has_method(dev->handle, "_HRV")) {
560 result = device_create_file(&dev->dev, &dev_attr_hrv);
561 if (result)
562 goto end;
563 }
564
544 if (acpi_has_method(dev->handle, "_STA")) { 565 if (acpi_has_method(dev->handle, "_STA")) {
545 result = device_create_file(&dev->dev, &dev_attr_status); 566 result = device_create_file(&dev->dev, &dev_attr_status);
546 if (result) 567 if (result)
@@ -604,6 +625,9 @@ void acpi_device_remove_files(struct acpi_device *dev)
604 if (acpi_has_method(dev->handle, "_SUN")) 625 if (acpi_has_method(dev->handle, "_SUN"))
605 device_remove_file(&dev->dev, &dev_attr_sun); 626 device_remove_file(&dev->dev, &dev_attr_sun);
606 627
628 if (acpi_has_method(dev->handle, "_HRV"))
629 device_remove_file(&dev->dev, &dev_attr_hrv);
630
607 if (dev->pnp.unique_id) 631 if (dev->pnp.unique_id)
608 device_remove_file(&dev->dev, &dev_attr_uid); 632 device_remove_file(&dev->dev, &dev_attr_uid);
609 if (dev->pnp.type.bus_address) 633 if (dev->pnp.type.bus_address)