linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Cc: Jean Delvare <jdelvare@suse.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Guillaume Ligneul <guillaume.ligneul@gmail.com>
Subject: [PATCH 16/29] hwmon: (lm73) Use permission specific SENSOR[_DEVICE]_ATTR variants
Date: Thu, 17 Jan 2019 13:13:36 -0800	[thread overview]
Message-ID: <1547759629-23007-17-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1547759629-23007-1-git-send-email-linux@roeck-us.net>

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: Guillaume Ligneul <guillaume.ligneul@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/lm73.c | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/hwmon/lm73.c b/drivers/hwmon/lm73.c
index 9653bb870a47..d1d728aa31d2 100644
--- a/drivers/hwmon/lm73.c
+++ b/drivers/hwmon/lm73.c
@@ -62,8 +62,8 @@ struct lm73_data {
 
 /*-----------------------------------------------------------------------*/
 
-static ssize_t set_temp(struct device *dev, struct device_attribute *da,
-			const char *buf, size_t count)
+static ssize_t temp_store(struct device *dev, struct device_attribute *da,
+			  const char *buf, size_t count)
 {
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
 	struct lm73_data *data = dev_get_drvdata(dev);
@@ -81,7 +81,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
 	return (err < 0) ? err : count;
 }
 
-static ssize_t show_temp(struct device *dev, struct device_attribute *da,
+static ssize_t temp_show(struct device *dev, struct device_attribute *da,
 			 char *buf)
 {
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
@@ -98,8 +98,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *da,
 	return scnprintf(buf, PAGE_SIZE, "%d\n", temp);
 }
 
-static ssize_t set_convrate(struct device *dev, struct device_attribute *da,
-			    const char *buf, size_t count)
+static ssize_t convrate_store(struct device *dev, struct device_attribute *da,
+			      const char *buf, size_t count)
 {
 	struct lm73_data *data = dev_get_drvdata(dev);
 	unsigned long convrate;
@@ -133,7 +133,7 @@ static ssize_t set_convrate(struct device *dev, struct device_attribute *da,
 	return count;
 }
 
-static ssize_t show_convrate(struct device *dev, struct device_attribute *da,
+static ssize_t convrate_show(struct device *dev, struct device_attribute *da,
 			     char *buf)
 {
 	struct lm73_data *data = dev_get_drvdata(dev);
@@ -143,7 +143,7 @@ static ssize_t show_convrate(struct device *dev, struct device_attribute *da,
 	return scnprintf(buf, PAGE_SIZE, "%hu\n", lm73_convrates[res]);
 }
 
-static ssize_t show_maxmin_alarm(struct device *dev,
+static ssize_t maxmin_alarm_show(struct device *dev,
 				 struct device_attribute *da, char *buf)
 {
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
@@ -168,18 +168,14 @@ static ssize_t show_maxmin_alarm(struct device *dev,
 
 /* sysfs attributes for hwmon */
 
-static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO,
-			show_temp, set_temp, LM73_REG_MAX);
-static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO,
-			show_temp, set_temp, LM73_REG_MIN);
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO,
-			show_temp, NULL, LM73_REG_INPUT);
-static SENSOR_DEVICE_ATTR(update_interval, S_IWUSR | S_IRUGO,
-			show_convrate, set_convrate, 0);
-static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO,
-			show_maxmin_alarm, NULL, LM73_CTRL_HI_SHIFT);
-static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO,
-			show_maxmin_alarm, NULL, LM73_CTRL_LO_SHIFT);
+static SENSOR_DEVICE_ATTR_RW(temp1_max, temp, LM73_REG_MAX);
+static SENSOR_DEVICE_ATTR_RW(temp1_min, temp, LM73_REG_MIN);
+static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, LM73_REG_INPUT);
+static SENSOR_DEVICE_ATTR_RW(update_interval, convrate, 0);
+static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, maxmin_alarm,
+			     LM73_CTRL_HI_SHIFT);
+static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, maxmin_alarm,
+			     LM73_CTRL_LO_SHIFT);
 
 static struct attribute *lm73_attrs[] = {
 	&sensor_dev_attr_temp1_input.dev_attr.attr,
-- 
2.7.4


  parent reply	other threads:[~2019-01-17 21:14 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-17 21:13 [PATCH 00/29] hwmon: Use permission specific SENSOR[_DEVICE]_ATTR Guenter Roeck
2019-01-17 21:13 ` [PATCH 01/29] hwmon: (gl518sm) Use permission specific SENSOR[_DEVICE]_ATTR variants Guenter Roeck
2019-01-17 21:13 ` [PATCH 02/29] hwmon: (gl520sm) " Guenter Roeck
2019-01-17 21:13 ` [PATCH 03/29] hwmon: (gpio-fan) Replace S_<PERMS> with octal values Guenter Roeck
2019-01-17 21:13 ` [PATCH 04/29] hwmon: (hih6130) Use permission specific SENSOR[_DEVICE]_ATTR variants Guenter Roeck
2019-01-17 21:13 ` [PATCH 05/29] hwmon: (hwmon) Replace S_<PERMS> with octal values Guenter Roeck
2019-01-17 21:13 ` [PATCH 06/29] hwmon: (i5500_temp) Use permission specific SENSOR[_DEVICE]_ATTR variants Guenter Roeck
2019-01-17 21:13 ` [PATCH 07/29] hwmon: (i5k_amb) Replace S_<PERMS> with octal values Guenter Roeck
2019-01-17 21:13 ` [PATCH 08/29] hwmon: (ibmaem) Use permission specific SENSOR[_DEVICE]_ATTR variants Guenter Roeck
2019-01-17 21:13 ` [PATCH 09/29] hwmon: (ibmpex) " Guenter Roeck
2019-01-17 21:13 ` [PATCH 10/29] hwmon: (iio_hwmon) Replace S_<PERMS> with octal values Guenter Roeck
2019-01-17 21:13 ` [PATCH 11/29] hwmon: (ina209) Use permission specific SENSOR[_DEVICE]_ATTR variants Guenter Roeck
2019-01-17 21:13 ` [PATCH 12/29] hwmon: (ina3221) " Guenter Roeck
2019-01-17 21:13 ` [PATCH 13/29] hwmon: (jc42) Replace S_<PERMS> with octal values Guenter Roeck
2019-01-17 21:13 ` [PATCH 14/29] hwmon: (k8temp) Use permission specific SENSOR[_DEVICE]_ATTR variants Guenter Roeck
2019-01-17 21:13 ` [PATCH 15/29] hwmon: (lineage-pem) " Guenter Roeck
2019-01-17 21:13 ` Guenter Roeck [this message]
2019-01-17 21:13 ` [PATCH 17/29] hwmon: (lm75) Replace S_<PERMS> with octal values Guenter Roeck
2019-01-17 21:13 ` [PATCH 18/29] hwmon: (lm77) Use permission specific SENSOR[_DEVICE]_ATTR variants Guenter Roeck
2019-01-17 21:13 ` [PATCH 19/29] hwmon: (lm80) " Guenter Roeck
2019-01-17 21:13 ` [PATCH 20/29] hwmon: (lm83) " Guenter Roeck
2019-01-17 21:13 ` [PATCH 21/29] hwmon: (lm90) Replace S_<PERMS> with octal values Guenter Roeck
2019-01-17 21:13 ` [PATCH 22/29] hwmon: (lm92) Use permission specific SENSOR[_DEVICE]_ATTR variants Guenter Roeck
2019-01-17 21:13 ` [PATCH 23/29] hwmon: (lm93) " Guenter Roeck
2019-01-17 21:13 ` [PATCH 24/29] hwmon: (lm95241) Replace S_<PERMS> with octal values Guenter Roeck
2019-01-17 21:13 ` [PATCH 25/29] hwmon: (lm95245) " Guenter Roeck
2019-01-17 21:13 ` [PATCH 26/29] hwmon: (ltc2990) Use permission specific SENSOR[_DEVICE]_ATTR variants Guenter Roeck
2019-01-17 21:13 ` [PATCH 27/29] hwmon: (ltc4151) " Guenter Roeck
2019-01-17 21:13 ` [PATCH 28/29] hwmon: (ltc4222) " Guenter Roeck
2019-01-17 21:13 ` [PATCH 29/29] hwmon: (ltc4245) Replace S_<PERMS> with octal values 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=1547759629-23007-17-git-send-email-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=guillaume.ligneul@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    /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 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).