Skip to content

Commit

Permalink
ACPI / device_sysfs: Add sysfs support for _HRV hardware revision
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Betty Dall authored and Rafael J. Wysocki committed May 4, 2016
1 parent 2b13f01 commit 6283f97
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions drivers/acpi/device_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,21 @@ acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);

static ssize_t
acpi_device_hrv_show(struct device *dev, struct device_attribute *attr,
char *buf) {
struct acpi_device *acpi_dev = to_acpi_device(dev);
acpi_status status;
unsigned long long hrv;

status = acpi_evaluate_integer(acpi_dev->handle, "_HRV", NULL, &hrv);
if (ACPI_FAILURE(status))
return -EIO;

return sprintf(buf, "%llu\n", hrv);
}
static DEVICE_ATTR(hrv, 0444, acpi_device_hrv_show, NULL);

static ssize_t status_show(struct device *dev, struct device_attribute *attr,
char *buf) {
struct acpi_device *acpi_dev = to_acpi_device(dev);
Expand Down Expand Up @@ -541,6 +556,12 @@ int acpi_device_setup_files(struct acpi_device *dev)
goto end;
}

if (acpi_has_method(dev->handle, "_HRV")) {
result = device_create_file(&dev->dev, &dev_attr_hrv);
if (result)
goto end;
}

if (acpi_has_method(dev->handle, "_STA")) {
result = device_create_file(&dev->dev, &dev_attr_status);
if (result)
Expand Down Expand Up @@ -604,6 +625,9 @@ void acpi_device_remove_files(struct acpi_device *dev)
if (acpi_has_method(dev->handle, "_SUN"))
device_remove_file(&dev->dev, &dev_attr_sun);

if (acpi_has_method(dev->handle, "_HRV"))
device_remove_file(&dev->dev, &dev_attr_hrv);

if (dev->pnp.unique_id)
device_remove_file(&dev->dev, &dev_attr_uid);
if (dev->pnp.type.bus_address)
Expand Down

0 comments on commit 6283f97

Please sign in to comment.