diff options
author | Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com> | 2012-11-15 20:56:59 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2012-11-15 20:56:59 -0500 |
commit | bb74ac23b10820d8722c3e1f4add9ef59e703f63 (patch) | |
tree | 14b9d4af4c2bfcad532d40b936392e444d100462 /drivers/acpi/scan.c | |
parent | 61d8eff14417fb6d6c5d57e4f0f7925e9e99fce3 (diff) |
ACPI: create _SUN sysfs file
_SUN method provides the slot unique-ID in the ACPI namespace. And The value
is written in Advanced Configuration and Power Interface Specification as
follows:
"The _SUN value is required to be unique among the slots ofthe same type.
It is also recommended that this number match the slot number printed on
the physical slot whenever possible."
So if we can know the value, we can identify the physical position of the
slot in the system.
The patch creates "sun" file in sysfs for identifying physical position
of the slot.
Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Reviewed-by: Toshi Kani <toshi.kani@hp.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 | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 9d43532d69b1..d0b38ab47ab5 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -283,11 +283,21 @@ static ssize_t description_show(struct device *dev, | |||
283 | } | 283 | } |
284 | static DEVICE_ATTR(description, 0444, description_show, NULL); | 284 | static DEVICE_ATTR(description, 0444, description_show, NULL); |
285 | 285 | ||
286 | static ssize_t | ||
287 | acpi_device_sun_show(struct device *dev, struct device_attribute *attr, | ||
288 | char *buf) { | ||
289 | struct acpi_device *acpi_dev = to_acpi_device(dev); | ||
290 | |||
291 | return sprintf(buf, "%lu\n", acpi_dev->pnp.sun); | ||
292 | } | ||
293 | static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL); | ||
294 | |||
286 | static int acpi_device_setup_files(struct acpi_device *dev) | 295 | static int acpi_device_setup_files(struct acpi_device *dev) |
287 | { | 296 | { |
288 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | 297 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; |
289 | acpi_status status; | 298 | acpi_status status; |
290 | acpi_handle temp; | 299 | acpi_handle temp; |
300 | unsigned long long sun; | ||
291 | int result = 0; | 301 | int result = 0; |
292 | 302 | ||
293 | /* | 303 | /* |
@@ -329,6 +339,16 @@ static int acpi_device_setup_files(struct acpi_device *dev) | |||
329 | if (dev->pnp.unique_id) | 339 | if (dev->pnp.unique_id) |
330 | result = device_create_file(&dev->dev, &dev_attr_uid); | 340 | result = device_create_file(&dev->dev, &dev_attr_uid); |
331 | 341 | ||
342 | status = acpi_evaluate_integer(dev->handle, "_SUN", NULL, &sun); | ||
343 | if (ACPI_SUCCESS(status)) { | ||
344 | dev->pnp.sun = (unsigned long)sun; | ||
345 | result = device_create_file(&dev->dev, &dev_attr_sun); | ||
346 | if (result) | ||
347 | goto end; | ||
348 | } else { | ||
349 | dev->pnp.sun = (unsigned long)-1; | ||
350 | } | ||
351 | |||
332 | /* | 352 | /* |
333 | * If device has _EJ0, 'eject' file is created that is used to trigger | 353 | * If device has _EJ0, 'eject' file is created that is used to trigger |
334 | * hot-removal function from userland. | 354 | * hot-removal function from userland. |
@@ -360,6 +380,10 @@ static void acpi_device_remove_files(struct acpi_device *dev) | |||
360 | if (ACPI_SUCCESS(status)) | 380 | if (ACPI_SUCCESS(status)) |
361 | device_remove_file(&dev->dev, &dev_attr_eject); | 381 | device_remove_file(&dev->dev, &dev_attr_eject); |
362 | 382 | ||
383 | status = acpi_get_handle(dev->handle, "_SUN", &temp); | ||
384 | if (ACPI_SUCCESS(status)) | ||
385 | device_remove_file(&dev->dev, &dev_attr_sun); | ||
386 | |||
363 | if (dev->pnp.unique_id) | 387 | if (dev->pnp.unique_id) |
364 | device_remove_file(&dev->dev, &dev_attr_uid); | 388 | device_remove_file(&dev->dev, &dev_attr_uid); |
365 | if (dev->flags.bus_address) | 389 | if (dev->flags.bus_address) |