diff options
author | Lv Zheng <lv.zheng@intel.com> | 2012-10-30 09:43:26 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2012-11-14 18:16:03 -0500 |
commit | 923d4a45a9d2e350c27b7b7e1c724c19eb921c92 (patch) | |
tree | c92927e1b5af36afacfe007594db60c76ddc10f4 /drivers/acpi/scan.c | |
parent | ccf78040265bfce2aac5766e1ddf4fc3dde36899 (diff) |
ACPI: Add user space interface for identification objects
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>
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r-- | drivers/acpi/scan.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index daa88d527e84..86bfa690bc6f 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -220,6 +220,25 @@ acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *bu | |||
220 | } | 220 | } |
221 | static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL); | 221 | static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL); |
222 | 222 | ||
223 | static ssize_t acpi_device_uid_show(struct device *dev, | ||
224 | struct device_attribute *attr, char *buf) | ||
225 | { | ||
226 | struct acpi_device *acpi_dev = to_acpi_device(dev); | ||
227 | |||
228 | return sprintf(buf, "%s\n", acpi_dev->pnp.unique_id); | ||
229 | } | ||
230 | static DEVICE_ATTR(uid, 0444, acpi_device_uid_show, NULL); | ||
231 | |||
232 | static ssize_t acpi_device_adr_show(struct device *dev, | ||
233 | struct device_attribute *attr, char *buf) | ||
234 | { | ||
235 | struct acpi_device *acpi_dev = to_acpi_device(dev); | ||
236 | |||
237 | return sprintf(buf, "0x%08x\n", | ||
238 | (unsigned int)(acpi_dev->pnp.bus_address)); | ||
239 | } | ||
240 | static DEVICE_ATTR(adr, 0444, acpi_device_adr_show, NULL); | ||
241 | |||
223 | static ssize_t | 242 | static ssize_t |
224 | acpi_device_path_show(struct device *dev, struct device_attribute *attr, char *buf) { | 243 | acpi_device_path_show(struct device *dev, struct device_attribute *attr, char *buf) { |
225 | struct acpi_device *acpi_dev = to_acpi_device(dev); | 244 | struct acpi_device *acpi_dev = to_acpi_device(dev); |
@@ -304,6 +323,11 @@ static int acpi_device_setup_files(struct acpi_device *dev) | |||
304 | goto end; | 323 | goto end; |
305 | } | 324 | } |
306 | 325 | ||
326 | if (dev->flags.bus_address) | ||
327 | result = device_create_file(&dev->dev, &dev_attr_adr); | ||
328 | if (dev->pnp.unique_id) | ||
329 | result = device_create_file(&dev->dev, &dev_attr_uid); | ||
330 | |||
307 | /* | 331 | /* |
308 | * If device has _EJ0, 'eject' file is created that is used to trigger | 332 | * If device has _EJ0, 'eject' file is created that is used to trigger |
309 | * hot-removal function from userland. | 333 | * hot-removal function from userland. |
@@ -335,6 +359,10 @@ static void acpi_device_remove_files(struct acpi_device *dev) | |||
335 | if (ACPI_SUCCESS(status)) | 359 | if (ACPI_SUCCESS(status)) |
336 | device_remove_file(&dev->dev, &dev_attr_eject); | 360 | device_remove_file(&dev->dev, &dev_attr_eject); |
337 | 361 | ||
362 | if (dev->pnp.unique_id) | ||
363 | device_remove_file(&dev->dev, &dev_attr_uid); | ||
364 | if (dev->flags.bus_address) | ||
365 | device_remove_file(&dev->dev, &dev_attr_adr); | ||
338 | device_remove_file(&dev->dev, &dev_attr_modalias); | 366 | device_remove_file(&dev->dev, &dev_attr_modalias); |
339 | device_remove_file(&dev->dev, &dev_attr_hid); | 367 | device_remove_file(&dev->dev, &dev_attr_hid); |
340 | if (dev->handle) | 368 | if (dev->handle) |