All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali.rohar@gmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Hardware Monitoring <linux-hwmon@vger.kernel.org>,
	Jean Delvare <jdelvare@suse.com>
Subject: Re: [PATCH 23/30] hwmon: (dell-smm-hwmon) Use permission specific SENSOR[_DEVICE]_ATTR variants
Date: Sat, 22 Dec 2018 23:41:33 +0100	[thread overview]
Message-ID: <20181222224133.qpz44b5w7gr4dda3@pali> (raw)
In-Reply-To: <1544479728-30077-24-git-send-email-linux@roeck-us.net>

[-- Attachment #1: Type: text/plain, Size: 6581 bytes --]

On Monday 10 December 2018 14:08:41 Guenter Roeck wrote:
> Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code,
> to improve readbility, and to reduce the chance of inconsistencies.
> 
> Also replace any remaining S_<PERMS> in the driver with octal values.
> 
> The conversion was done automatically with coccinelle. The semantic patches
> and the scripts used to generate this commit log are available at
> https://github.com/groeck/coccinelle-patches/hwmon/.
> 
> This patch does not introduce functional changes. It was verified by
> compiling the old and new files and comparing text and data sizes.
> 
> Cc: "Pali Rohár" <pali.rohar@gmail.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Looks good, add my

Acked-By: Pali Rohár <pali.rohar@gmail.com>

> ---
>  drivers/hwmon/dell-smm-hwmon.c | 68 +++++++++++++++++-------------------------
>  1 file changed, 27 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
> index 367a8a61712c..68c9a6664557 100644
> --- a/drivers/hwmon/dell-smm-hwmon.c
> +++ b/drivers/hwmon/dell-smm-hwmon.c
> @@ -618,7 +618,7 @@ static inline void __exit i8k_exit_procfs(void)
>   * Hwmon interface
>   */
>  
> -static ssize_t i8k_hwmon_show_temp_label(struct device *dev,
> +static ssize_t i8k_hwmon_temp_label_show(struct device *dev,
>  					 struct device_attribute *devattr,
>  					 char *buf)
>  {
> @@ -641,7 +641,7 @@ static ssize_t i8k_hwmon_show_temp_label(struct device *dev,
>  	return sprintf(buf, "%s\n", labels[type]);
>  }
>  
> -static ssize_t i8k_hwmon_show_temp(struct device *dev,
> +static ssize_t i8k_hwmon_temp_show(struct device *dev,
>  				   struct device_attribute *devattr,
>  				   char *buf)
>  {
> @@ -654,7 +654,7 @@ static ssize_t i8k_hwmon_show_temp(struct device *dev,
>  	return sprintf(buf, "%d\n", temp * 1000);
>  }
>  
> -static ssize_t i8k_hwmon_show_fan_label(struct device *dev,
> +static ssize_t i8k_hwmon_fan_label_show(struct device *dev,
>  					struct device_attribute *devattr,
>  					char *buf)
>  {
> @@ -685,9 +685,8 @@ static ssize_t i8k_hwmon_show_fan_label(struct device *dev,
>  	return sprintf(buf, "%s%s\n", (dock ? "Docking " : ""), labels[type]);
>  }
>  
> -static ssize_t i8k_hwmon_show_fan(struct device *dev,
> -				  struct device_attribute *devattr,
> -				  char *buf)
> +static ssize_t i8k_hwmon_fan_show(struct device *dev,
> +				  struct device_attribute *devattr, char *buf)
>  {
>  	int index = to_sensor_dev_attr(devattr)->index;
>  	int fan_speed;
> @@ -698,9 +697,8 @@ static ssize_t i8k_hwmon_show_fan(struct device *dev,
>  	return sprintf(buf, "%d\n", fan_speed);
>  }
>  
> -static ssize_t i8k_hwmon_show_pwm(struct device *dev,
> -				  struct device_attribute *devattr,
> -				  char *buf)
> +static ssize_t i8k_hwmon_pwm_show(struct device *dev,
> +				  struct device_attribute *devattr, char *buf)
>  {
>  	int index = to_sensor_dev_attr(devattr)->index;
>  	int status;
> @@ -711,9 +709,9 @@ static ssize_t i8k_hwmon_show_pwm(struct device *dev,
>  	return sprintf(buf, "%d\n", clamp_val(status * i8k_pwm_mult, 0, 255));
>  }
>  
> -static ssize_t i8k_hwmon_set_pwm(struct device *dev,
> -				 struct device_attribute *attr,
> -				 const char *buf, size_t count)
> +static ssize_t i8k_hwmon_pwm_store(struct device *dev,
> +				   struct device_attribute *attr,
> +				   const char *buf, size_t count)
>  {
>  	int index = to_sensor_dev_attr(attr)->index;
>  	unsigned long val;
> @@ -731,35 +729,23 @@ static ssize_t i8k_hwmon_set_pwm(struct device *dev,
>  	return err < 0 ? -EIO : count;
>  }
>  
> -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 0);
> -static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, i8k_hwmon_show_temp_label, NULL,
> -			  0);
> -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 1);
> -static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, i8k_hwmon_show_temp_label, NULL,
> -			  1);
> -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 2);
> -static SENSOR_DEVICE_ATTR(temp3_label, S_IRUGO, i8k_hwmon_show_temp_label, NULL,
> -			  2);
> -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, i8k_hwmon_show_temp, NULL, 3);
> -static SENSOR_DEVICE_ATTR(temp4_label, S_IRUGO, i8k_hwmon_show_temp_label, NULL,
> -			  3);
> -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, i8k_hwmon_show_fan, NULL, 0);
> -static SENSOR_DEVICE_ATTR(fan1_label, S_IRUGO, i8k_hwmon_show_fan_label, NULL,
> -			  0);
> -static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, i8k_hwmon_show_pwm,
> -			  i8k_hwmon_set_pwm, 0);
> -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, i8k_hwmon_show_fan, NULL,
> -			  1);
> -static SENSOR_DEVICE_ATTR(fan2_label, S_IRUGO, i8k_hwmon_show_fan_label, NULL,
> -			  1);
> -static SENSOR_DEVICE_ATTR(pwm2, S_IRUGO | S_IWUSR, i8k_hwmon_show_pwm,
> -			  i8k_hwmon_set_pwm, 1);
> -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, i8k_hwmon_show_fan, NULL,
> -			  2);
> -static SENSOR_DEVICE_ATTR(fan3_label, S_IRUGO, i8k_hwmon_show_fan_label, NULL,
> -			  2);
> -static SENSOR_DEVICE_ATTR(pwm3, S_IRUGO | S_IWUSR, i8k_hwmon_show_pwm,
> -			  i8k_hwmon_set_pwm, 2);
> +static SENSOR_DEVICE_ATTR_RO(temp1_input, i8k_hwmon_temp, 0);
> +static SENSOR_DEVICE_ATTR_RO(temp1_label, i8k_hwmon_temp_label, 0);
> +static SENSOR_DEVICE_ATTR_RO(temp2_input, i8k_hwmon_temp, 1);
> +static SENSOR_DEVICE_ATTR_RO(temp2_label, i8k_hwmon_temp_label, 1);
> +static SENSOR_DEVICE_ATTR_RO(temp3_input, i8k_hwmon_temp, 2);
> +static SENSOR_DEVICE_ATTR_RO(temp3_label, i8k_hwmon_temp_label, 2);
> +static SENSOR_DEVICE_ATTR_RO(temp4_input, i8k_hwmon_temp, 3);
> +static SENSOR_DEVICE_ATTR_RO(temp4_label, i8k_hwmon_temp_label, 3);
> +static SENSOR_DEVICE_ATTR_RO(fan1_input, i8k_hwmon_fan, 0);
> +static SENSOR_DEVICE_ATTR_RO(fan1_label, i8k_hwmon_fan_label, 0);
> +static SENSOR_DEVICE_ATTR_RW(pwm1, i8k_hwmon_pwm, 0);
> +static SENSOR_DEVICE_ATTR_RO(fan2_input, i8k_hwmon_fan, 1);
> +static SENSOR_DEVICE_ATTR_RO(fan2_label, i8k_hwmon_fan_label, 1);
> +static SENSOR_DEVICE_ATTR_RW(pwm2, i8k_hwmon_pwm, 1);
> +static SENSOR_DEVICE_ATTR_RO(fan3_input, i8k_hwmon_fan, 2);
> +static SENSOR_DEVICE_ATTR_RO(fan3_label, i8k_hwmon_fan_label, 2);
> +static SENSOR_DEVICE_ATTR_RW(pwm3, i8k_hwmon_pwm, 2);
>  
>  static struct attribute *i8k_attrs[] = {
>  	&sensor_dev_attr_temp1_input.dev_attr.attr,	/* 0 */

-- 
Pali Rohár
pali.rohar@gmail.com

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  reply	other threads:[~2018-12-22 22:41 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-10 22:08 [PATCH 00/30] hwmon: Use permission specific SENSOR[_DEVICE]_ATTR variants Guenter Roeck
2018-12-10 22:08 ` [PATCH 01/30] hwmon: (abx500) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 02/30] hwmon: (acpi_power_meter) Replace S_<PERMS> with octal values Guenter Roeck
2018-12-10 22:08 ` [PATCH 03/30] hwmon: (ad7314) Use permission specific SENSOR[_DEVICE]_ATTR variants Guenter Roeck
2018-12-10 22:08 ` [PATCH 04/30] hwmon: (ad7414) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 05/30] hwmon: (ad7418) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 06/30] hwmon: (adc128d818) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 07/30] hwmon: (adcxx) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 08/30] hwmon: (adm1021) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 09/30] hwmon: (ads1015) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 10/30] hwmon: (ads7828) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 11/30] hwmon: (ads7871) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 12/30] hwmon: (adt7462) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 13/30] hwmon: (adt7470) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 14/30] hwmon: (adt7475) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 15/30] hwmon: (adt7x10) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 16/30] hwmon: (amc6821) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 17/30] hwmon: (applesmc) Replace S_<PERMS> with octal values Guenter Roeck
2018-12-10 22:08 ` [PATCH 18/30] hwmon: (aspeed-pwm-tacho) Use permission specific SENSOR[_DEVICE]_ATTR variants Guenter Roeck
2018-12-11  0:21   ` Joel Stanley
2018-12-10 22:08 ` [PATCH 19/30] hwmon: (asus_atk0110) Replace S_<PERMS> with octal values Guenter Roeck
2018-12-10 22:08 ` [PATCH 20/30] hwmon: (coretemp) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 21/30] hwmon: (da9052-hwmon) Use permission specific SENSOR[_DEVICE]_ATTR variants Guenter Roeck
2018-12-11 11:47   ` Steve Twiss
2018-12-11 14:28     ` Guenter Roeck
2018-12-10 22:08 ` [PATCH 22/30] hwmon: (da9055-hwmon) " Guenter Roeck
2018-12-11 11:47   ` Steve Twiss
2018-12-10 22:08 ` [PATCH 23/30] hwmon: (dell-smm-hwmon) " Guenter Roeck
2018-12-22 22:41   ` Pali Rohár [this message]
2018-12-10 22:08 ` [PATCH 24/30] hwmon: (ds1621) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 25/30] hwmon: (ds620) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 26/30] hwmon: (emc1403) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 27/30] hwmon: (emc2103) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 28/30] hwmon: (emc6w201) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 29/30] hwmon: (fschmd) " Guenter Roeck
2018-12-10 22:08 ` [PATCH 30/30] hwmon: (ftsteutates) " Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181222224133.qpz44b5w7gr4dda3@pali \
    --to=pali.rohar@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.