linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5] create sun sysfs file
@ 2012-10-09  6:49 Yasuaki Ishimatsu
  2012-10-10  8:31 ` Yasuaki Ishimatsu
  2012-10-11  2:52 ` Len Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Yasuaki Ishimatsu @ 2012-10-09  6:49 UTC (permalink / raw)
  To: linux-acpi, linux-kernel, lenb, toshi.kani, liuj97

_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.

Reviewed-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>

---
 Documentation/ABI/testing/sysfs-devices-sun |   14 ++++++++++++++
 drivers/acpi/scan.c                         |   24 ++++++++++++++++++++++++
 include/acpi/acpi_bus.h                     |    1 +
 3 files changed, 39 insertions(+)

Index: linux-3.6/include/acpi/acpi_bus.h
===================================================================
--- linux-3.6.orig/include/acpi/acpi_bus.h	2012-10-09 11:54:17.690072343 +0900
+++ linux-3.6/include/acpi/acpi_bus.h	2012-10-09 14:15:49.207794671 +0900
@@ -208,6 +208,7 @@ struct acpi_device_pnp {
 	struct list_head ids;		/* _HID and _CIDs */
 	acpi_device_name device_name;	/* Driver-determined */
 	acpi_device_class device_class;	/*        "          */
+	unsigned long sun;		/* _SUN */
 };
 
 #define acpi_device_bid(d)	((d)->pnp.bus_id)
Index: linux-3.6/drivers/acpi/scan.c
===================================================================
--- linux-3.6.orig/drivers/acpi/scan.c	2012-10-09 11:54:17.688072343 +0900
+++ linux-3.6/drivers/acpi/scan.c	2012-10-09 14:15:49.211794675 +0900
@@ -232,10 +232,20 @@ end:
 }
 static DEVICE_ATTR(path, 0444, acpi_device_path_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)
 {
 	acpi_status status;
 	acpi_handle temp;
+	unsigned long long sun;
 	int result = 0;
 
 	/*
@@ -257,6 +267,16 @@ static int acpi_device_setup_files(struc
 			goto end;
 	}
 
+	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.
@@ -281,6 +301,10 @@ static void acpi_device_remove_files(str
 	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);
+
 	device_remove_file(&dev->dev, &dev_attr_modalias);
 	device_remove_file(&dev->dev, &dev_attr_hid);
 	if (dev->handle)
Index: linux-3.6/Documentation/ABI/testing/sysfs-devices-sun
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-3.6/Documentation/ABI/testing/sysfs-devices-sun	2012-10-09 15:47:02.333245246 +0900
@@ -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. 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v5] create sun sysfs file
  2012-10-09  6:49 [PATCH v5] create sun sysfs file Yasuaki Ishimatsu
@ 2012-10-10  8:31 ` Yasuaki Ishimatsu
  2012-10-11  2:52 ` Len Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Yasuaki Ishimatsu @ 2012-10-10  8:31 UTC (permalink / raw)
  To: linux-acpi, linux-kernel, lenb; +Cc: toshi.kani, liuj97

Hi Len,

How about v5 patch? 

Thanks,
Yasuaki Ishimatsu

2012/10/09 15:49, Yasuaki Ishimatsu wrote:
> _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.
> 
> Reviewed-by: Toshi Kani <toshi.kani@hp.com>
> Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
> 
> ---
>   Documentation/ABI/testing/sysfs-devices-sun |   14 ++++++++++++++
>   drivers/acpi/scan.c                         |   24 ++++++++++++++++++++++++
>   include/acpi/acpi_bus.h                     |    1 +
>   3 files changed, 39 insertions(+)
> 
> Index: linux-3.6/include/acpi/acpi_bus.h
> ===================================================================
> --- linux-3.6.orig/include/acpi/acpi_bus.h	2012-10-09 11:54:17.690072343 +0900
> +++ linux-3.6/include/acpi/acpi_bus.h	2012-10-09 14:15:49.207794671 +0900
> @@ -208,6 +208,7 @@ struct acpi_device_pnp {
>   	struct list_head ids;		/* _HID and _CIDs */
>   	acpi_device_name device_name;	/* Driver-determined */
>   	acpi_device_class device_class;	/*        "          */
> +	unsigned long sun;		/* _SUN */
>   };
>   
>   #define acpi_device_bid(d)	((d)->pnp.bus_id)
> Index: linux-3.6/drivers/acpi/scan.c
> ===================================================================
> --- linux-3.6.orig/drivers/acpi/scan.c	2012-10-09 11:54:17.688072343 +0900
> +++ linux-3.6/drivers/acpi/scan.c	2012-10-09 14:15:49.211794675 +0900
> @@ -232,10 +232,20 @@ end:
>   }
>   static DEVICE_ATTR(path, 0444, acpi_device_path_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)
>   {
>   	acpi_status status;
>   	acpi_handle temp;
> +	unsigned long long sun;
>   	int result = 0;
>   
>   	/*
> @@ -257,6 +267,16 @@ static int acpi_device_setup_files(struc
>   			goto end;
>   	}
>   
> +	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.
> @@ -281,6 +301,10 @@ static void acpi_device_remove_files(str
>   	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);
> +
>   	device_remove_file(&dev->dev, &dev_attr_modalias);
>   	device_remove_file(&dev->dev, &dev_attr_hid);
>   	if (dev->handle)
> Index: linux-3.6/Documentation/ABI/testing/sysfs-devices-sun
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ linux-3.6/Documentation/ABI/testing/sysfs-devices-sun	2012-10-09 15:47:02.333245246 +0900
> @@ -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.
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v5] create sun sysfs file
  2012-10-09  6:49 [PATCH v5] create sun sysfs file Yasuaki Ishimatsu
  2012-10-10  8:31 ` Yasuaki Ishimatsu
@ 2012-10-11  2:52 ` Len Brown
  2012-11-06  1:27   ` Len Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Len Brown @ 2012-10-11  2:52 UTC (permalink / raw)
  To: Yasuaki Ishimatsu; +Cc: linux-acpi, linux-kernel, toshi.kani, liuj97

v5 applied (with typo fixed).
In the future, it would be better if your patches apply to the latest
upstream kernel.  (_STR made changes in same place as _SUN)

thanks,
Len Brown, Intel Open Source Technology Center


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v5] create sun sysfs file
  2012-10-11  2:52 ` Len Brown
@ 2012-11-06  1:27   ` Len Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Len Brown @ 2012-11-06  1:27 UTC (permalink / raw)
  To: Yasuaki Ishimatsu
  Cc: linux-acpi, linux-kernel, toshi.kani, liuj97, Rafael J. Wysocki

Yasuaki,
Please refresh this patch on top of linux-next and re-send to Rafael.
I've dropped it from my tree.

thanks,
-Len

On 10/10/2012 10:52 PM, Len Brown wrote:
> v5 applied (with typo fixed).
> In the future, it would be better if your patches apply to the latest
> upstream kernel.  (_STR made changes in same place as _SUN)
> 
> thanks,
> Len Brown, Intel Open Source Technology Center
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-11-06  1:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-09  6:49 [PATCH v5] create sun sysfs file Yasuaki Ishimatsu
2012-10-10  8:31 ` Yasuaki Ishimatsu
2012-10-11  2:52 ` Len Brown
2012-11-06  1:27   ` Len Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).