]> rtime.felk.cvut.cz Git - linux-imx.git/commitdiff
ACPI: create _SUN sysfs file
authorYasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Fri, 16 Nov 2012 01:56:59 +0000 (02:56 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 16 Nov 2012 01:56:59 +0000 (02:56 +0100)
_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>
Documentation/ABI/testing/sysfs-devices-sun [new file with mode: 0644]
drivers/acpi/scan.c
include/acpi/acpi_bus.h

diff --git a/Documentation/ABI/testing/sysfs-devices-sun b/Documentation/ABI/testing/sysfs-devices-sun
new file mode 100644 (file)
index 0000000..86be984
--- /dev/null
@@ -0,0 +1,14 @@
+Whatt:         /sys/devices/.../sun
+Date:          October 2012
+Contact:       Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
+Description:
+               The file contains a Slot-unique ID which provided by the _SUN
+               method in the ACPI namespace. The value is written in Advanced
+               Configuration and Power Interface Specification as follows:
+
+               "The _SUN value is required to be unique among the slots of
+               the same type. It is also recommended that this number match
+               the slot number printed on the physical slot whenever possible."
+
+               So reading the sysfs file, we can identify a physical position
+               of the slot in the system.
index 9d43532d69b171e0a063a9b4585e5bf532023319..d0b38ab47ab5a98c691d71338b7923ac0dc9ed7b 100644 (file)
@@ -283,11 +283,21 @@ static ssize_t description_show(struct device *dev,
 }
 static DEVICE_ATTR(description, 0444, description_show, NULL);
 
+static ssize_t
+acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
+                    char *buf) {
+       struct acpi_device *acpi_dev = to_acpi_device(dev);
+
+       return sprintf(buf, "%lu\n", acpi_dev->pnp.sun);
+}
+static DEVICE_ATTR(sun, 0444, acpi_device_sun_show, NULL);
+
 static int acpi_device_setup_files(struct acpi_device *dev)
 {
        struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
        acpi_status status;
        acpi_handle temp;
+       unsigned long long sun;
        int result = 0;
 
        /*
@@ -329,6 +339,16 @@ static int acpi_device_setup_files(struct acpi_device *dev)
        if (dev->pnp.unique_id)
                result = device_create_file(&dev->dev, &dev_attr_uid);
 
+       status = acpi_evaluate_integer(dev->handle, "_SUN", NULL, &sun);
+       if (ACPI_SUCCESS(status)) {
+               dev->pnp.sun = (unsigned long)sun;
+               result = device_create_file(&dev->dev, &dev_attr_sun);
+               if (result)
+                       goto end;
+       } else {
+               dev->pnp.sun = (unsigned long)-1;
+       }
+
         /*
          * If device has _EJ0, 'eject' file is created that is used to trigger
          * hot-removal function from userland.
@@ -360,6 +380,10 @@ static void acpi_device_remove_files(struct acpi_device *dev)
        if (ACPI_SUCCESS(status))
                device_remove_file(&dev->dev, &dev_attr_eject);
 
+       status = acpi_get_handle(dev->handle, "_SUN", &temp);
+       if (ACPI_SUCCESS(status))
+               device_remove_file(&dev->dev, &dev_attr_sun);
+
        if (dev->pnp.unique_id)
                device_remove_file(&dev->dev, &dev_attr_uid);
        if (dev->flags.bus_address)
index e8b2877aea3371007f66df87f272a7a6bd68c91c..6f385e5909dbdc995d1049e35c4dd90269c5d1b3 100644 (file)
@@ -179,6 +179,7 @@ struct acpi_device_pnp {
        acpi_device_name device_name;   /* Driver-determined */
        acpi_device_class device_class; /*        "          */
        union acpi_object *str_obj;     /* unicode string for _STR method */
+       unsigned long sun;              /* _SUN */
 };
 
 #define acpi_device_bid(d)     ((d)->pnp.bus_id)