Re: [PATCH] eeepc-laptop: remove disp attribute show function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 08, 2014 at 11:12:42PM +0200, Frans Klaver wrote:
> The disp attribute is write-only. This is enforced by mimicking sysfs
> behavior store_sys_acpi() and show_sys_acpi(), but this is not ideal.
> Behaving like sysfs is better left to sysfs.
> 
> Remove the show function from the disp attribute. This ensures userspace
> can only write to disp at all times. While at it, propagate any errors
> produced in store_sys_acpi() and show_sys_acpi(), instead of overriding
> them with -EIO.
> 
> Signed-off-by: Frans Klaver <fransklaver@xxxxxxxxx>
> ---
> 
> This patch applies on top of Paul's "eeepc-laptop: simplify parse_arg()".
> Tested both patches separately, as well as combined. As far as I can see the
> system behaves exactly like before.
> 
>  drivers/platform/x86/eeepc-laptop.c | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
> index 78515b8..03bcbed 100644
> --- a/drivers/platform/x86/eeepc-laptop.c
> +++ b/drivers/platform/x86/eeepc-laptop.c
> @@ -281,7 +281,7 @@ static ssize_t store_sys_acpi(struct device *dev, int cm,
>  		return rv;
>  	value = set_acpi(eeepc, cm, value);
>  	if (value < 0)
> -		return -EIO;
> +		return value;
>  	return count;
>  }
>  
> @@ -291,7 +291,7 @@ static ssize_t show_sys_acpi(struct device *dev, int cm, char *buf)
>  	int value = get_acpi(eeepc, cm);
>  
>  	if (value < 0)
> -		return -EIO;
> +		return value;
>  	return sprintf(buf, "%d\n", value);
>  }
>  
> @@ -318,7 +318,20 @@ static ssize_t show_sys_acpi(struct device *dev, int cm, char *buf)
>  
>  EEEPC_CREATE_DEVICE_ATTR(camera, 0644, CM_ASL_CAMERA);
>  EEEPC_CREATE_DEVICE_ATTR(cardr, 0644, CM_ASL_CARDREADER);
> -EEEPC_CREATE_DEVICE_ATTR(disp, 0200, CM_ASL_DISPLAYSWITCH);
> +
> +static ssize_t store_disp(struct device *dev,
> +			  struct device_attribute *attr,
> +			  const char *buf, size_t count)
> +{
> +	return store_sys_acpi(dev, CM_ASL_DISPLAYSWITCH, buf, count);
> +}
> +
> +static struct device_attribute dev_attr_disp = {
> +	.attr = {
> +		.name = "disp",
> +		.mode = 0200 },
> +	.store  = store_disp,
> +};

DEVICE_ATTR()?

--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux