diff mbox

[v2] create sun sysfs file

Message ID 5012051A.4050706@jp.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yasuaki Ishimatsu July 27, 2012, 3:03 a.m. UTC
Even if a device has _SUN method, there is no way to know the slot unique-ID.
Thus the patch creates "sun" file in sysfs so that we can recognize it.


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

Comments

Toshi Kani July 27, 2012, 10:25 p.m. UTC | #1
On Fri, 2012-07-27 at 12:03 +0900, Yasuaki Ishimatsu wrote:
> Even if a device has _SUN method, there is no way to know the slot unique-ID.
> Thus the patch creates "sun" file in sysfs so that we can recognize it.

Hi Yasuaki,

Thanks for the update.  This version looks good to me.
Did you forget to add your Signed-off?


> Index: linux-3.5/include/acpi/acpi_bus.h
> ===================================================================
> --- linux-3.5.orig/include/acpi/acpi_bus.h	2012-07-22 05:58:29.000000000 +0900
> +++ linux-3.5/include/acpi/acpi_bus.h	2012-07-27 10:05:13.860598455 +0900
> @@ -209,6 +209,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.5/drivers/acpi/scan.c
> ===================================================================
> --- linux-3.5.orig/drivers/acpi/scan.c	2012-07-22 05:58:29.000000000 +0900
> +++ linux-3.5/drivers/acpi/scan.c	2012-07-27 10:17:55.670550879 +0900
> @@ -192,10 +192,21 @@ 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);
> +	int result;
> +
> +	result = sprintf(buf, "%lu\n", acpi_dev->pnp.sun);
> +	return result;
> +}
> +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;
>  
>  	/*
> @@ -217,6 +228,14 @@ 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;
> +	}
> +

I'd suggest we add the else condition below to invalidate the field when
_SUN does not exist.

	else {
		dev->pnp.sun = (unsigned long)-1;
	}


Thanks,
-Toshi

>          /*
>           * If device has _EJ0, 'eject' file is created that is used to trigger
>           * hot-removal function from userland.
> @@ -241,6 +260,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)
> 


--
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
Yasuaki Ishimatsu July 30, 2012, 12:51 a.m. UTC | #2
Hi Toshi,

2012/07/28 7:25, Toshi Kani wrote:
> On Fri, 2012-07-27 at 12:03 +0900, Yasuaki Ishimatsu wrote:
>> Even if a device has _SUN method, there is no way to know the slot unique-ID.
>> Thus the patch creates "sun" file in sysfs so that we can recognize it.
>
> Hi Yasuaki,
>
> Thanks for the update.  This version looks good to me.
> Did you forget to add your Signed-off?
>
>
>> Index: linux-3.5/include/acpi/acpi_bus.h
>> ===================================================================
>> --- linux-3.5.orig/include/acpi/acpi_bus.h	2012-07-22 05:58:29.000000000 +0900
>> +++ linux-3.5/include/acpi/acpi_bus.h	2012-07-27 10:05:13.860598455 +0900
>> @@ -209,6 +209,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.5/drivers/acpi/scan.c
>> ===================================================================
>> --- linux-3.5.orig/drivers/acpi/scan.c	2012-07-22 05:58:29.000000000 +0900
>> +++ linux-3.5/drivers/acpi/scan.c	2012-07-27 10:17:55.670550879 +0900
>> @@ -192,10 +192,21 @@ 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);
>> +	int result;
>> +
>> +	result = sprintf(buf, "%lu\n", acpi_dev->pnp.sun);
>> +	return result;
>> +}
>> +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;
>>
>>   	/*
>> @@ -217,6 +228,14 @@ 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;
>> +	}
>> +
>

> I'd suggest we add the else condition below to invalidate the field when
> _SUN does not exist.
>
> 	else {
> 		dev->pnp.sun = (unsigned long)-1;
> 	}
>

I'll update it soon.

Thanks,
Yasuaki Ishimatsu
  
>
> Thanks,
> -Toshi
>
>>           /*
>>            * If device has _EJ0, 'eject' file is created that is used to trigger
>>            * hot-removal function from userland.
>> @@ -241,6 +260,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)
>>
>
>


--
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
diff mbox

Patch

Index: linux-3.5/include/acpi/acpi_bus.h
===================================================================
--- linux-3.5.orig/include/acpi/acpi_bus.h	2012-07-22 05:58:29.000000000 +0900
+++ linux-3.5/include/acpi/acpi_bus.h	2012-07-27 10:05:13.860598455 +0900
@@ -209,6 +209,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.5/drivers/acpi/scan.c
===================================================================
--- linux-3.5.orig/drivers/acpi/scan.c	2012-07-22 05:58:29.000000000 +0900
+++ linux-3.5/drivers/acpi/scan.c	2012-07-27 10:17:55.670550879 +0900
@@ -192,10 +192,21 @@  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);
+	int result;
+
+	result = sprintf(buf, "%lu\n", acpi_dev->pnp.sun);
+	return result;
+}
+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;
 
 	/*
@@ -217,6 +228,14 @@  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;
+	}
+
         /*
          * If device has _EJ0, 'eject' file is created that is used to trigger
          * hot-removal function from userland.
@@ -241,6 +260,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)