]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ACPI: Add user space interface for identification objects
authorLv Zheng <lv.zheng@intel.com>
Tue, 30 Oct 2012 13:43:26 +0000 (14:43 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 30 Oct 2012 13:43:26 +0000 (14:43 +0100)
ACPI devices are glued with physical devices through _ADR object, ACPI
enumerated devices are identified with _UID object.  Currently we can
observe _HID/_CID through sysfs interfaces (hid/modalias), but there's
no way for us to check _ADR/_UID from user space.  This patch closes
this gap for ACPI developers and users.

[rjw: Modified the subject and changelog slightly.]
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/scan.c

index daa88d527e8463e5a6637d69ab8726795862f5f8..86bfa690bc6fcc51f8f60f3b9b78470e0d28e7d7 100644 (file)
@@ -220,6 +220,25 @@ acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *bu
 }
 static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL);
 
+static ssize_t acpi_device_uid_show(struct device *dev,
+                                   struct device_attribute *attr, char *buf)
+{
+       struct acpi_device *acpi_dev = to_acpi_device(dev);
+
+       return sprintf(buf, "%s\n", acpi_dev->pnp.unique_id);
+}
+static DEVICE_ATTR(uid, 0444, acpi_device_uid_show, NULL);
+
+static ssize_t acpi_device_adr_show(struct device *dev,
+                                   struct device_attribute *attr, char *buf)
+{
+       struct acpi_device *acpi_dev = to_acpi_device(dev);
+
+       return sprintf(buf, "0x%08x\n",
+                      (unsigned int)(acpi_dev->pnp.bus_address));
+}
+static DEVICE_ATTR(adr, 0444, acpi_device_adr_show, NULL);
+
 static ssize_t
 acpi_device_path_show(struct device *dev, struct device_attribute *attr, char *buf) {
        struct acpi_device *acpi_dev = to_acpi_device(dev);
@@ -304,6 +323,11 @@ static int acpi_device_setup_files(struct acpi_device *dev)
                        goto end;
        }
 
+       if (dev->flags.bus_address)
+               result = device_create_file(&dev->dev, &dev_attr_adr);
+       if (dev->pnp.unique_id)
+               result = device_create_file(&dev->dev, &dev_attr_uid);
+
         /*
          * If device has _EJ0, 'eject' file is created that is used to trigger
          * hot-removal function from userland.
@@ -335,6 +359,10 @@ static void acpi_device_remove_files(struct acpi_device *dev)
        if (ACPI_SUCCESS(status))
                device_remove_file(&dev->dev, &dev_attr_eject);
 
+       if (dev->pnp.unique_id)
+               device_remove_file(&dev->dev, &dev_attr_uid);
+       if (dev->flags.bus_address)
+               device_remove_file(&dev->dev, &dev_attr_adr);
        device_remove_file(&dev->dev, &dev_attr_modalias);
        device_remove_file(&dev->dev, &dev_attr_hid);
        if (dev->handle)