linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <Julia.Lawall@lip6.fr>
To: Jim Cromie <jim.cromie@gmail.com>
Cc: kernel-janitors@vger.kernel.org, Jean Delvare <jdelvare@suse.com>,
	Guenter Roeck <linux@roeck-us.net>,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 55/66] hwmon: (pc87360) use permission-specific DEVICE_ATTR variants
Date: Thu, 22 Dec 2016 13:05:24 +0100	[thread overview]
Message-ID: <1482408335-3435-56-git-send-email-Julia.Lawall@lip6.fr> (raw)
In-Reply-To: <1482408335-3435-1-git-send-email-Julia.Lawall@lip6.fr>

Use DEVICE_ATTR_RO etc. for read only attributes etc.  This simplifies the
source code, improves readbility, and reduces the chance of
inconsistencies.

The semantic patch for the RO case, in the case where the show function
already has the expected name, is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@ro@
declarer name DEVICE_ATTR;
identifier x,x_show;
@@

DEVICE_ATTR(x, \(0444\|S_IRUGO\), x_show, NULL);

@script:ocaml@
x << ro.x;
x_show << ro.x_show;
@@

if not (x^"_show" = x_show) then Coccilib.include_match false

@@
declarer name DEVICE_ATTR_RO;
identifier ro.x,ro.x_show;
@@

- DEVICE_ATTR(x, \(0444\|S_IRUGO\), x_show, NULL);
+ DEVICE_ATTR_RO(x);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/hwmon/pc87360.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c
index d50fbf9..7e36977 100644
--- a/drivers/hwmon/pc87360.c
+++ b/drivers/hwmon/pc87360.c
@@ -589,22 +589,22 @@ static ssize_t show_in_max_alarm(struct device *dev,
 	&in_min_alarm[X].dev_attr.attr,	\
 	&in_max_alarm[X].dev_attr.attr
 
-static ssize_t show_vid(struct device *dev, struct device_attribute *attr,
-			char *buf)
+static ssize_t cpu0_vid_show(struct device *dev,
+			     struct device_attribute *attr, char *buf)
 {
 	struct pc87360_data *data = pc87360_update_device(dev);
 	return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm));
 }
-static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
+static DEVICE_ATTR_RO(cpu0_vid);
 
-static ssize_t show_vrm(struct device *dev, struct device_attribute *attr,
+static ssize_t vrm_show(struct device *dev, struct device_attribute *attr,
 			char *buf)
 {
 	struct pc87360_data *data = dev_get_drvdata(dev);
 	return sprintf(buf, "%u\n", data->vrm);
 }
-static ssize_t set_vrm(struct device *dev, struct device_attribute *attr,
-		       const char *buf, size_t count)
+static ssize_t vrm_store(struct device *dev, struct device_attribute *attr,
+			 const char *buf, size_t count)
 {
 	struct pc87360_data *data = dev_get_drvdata(dev);
 	unsigned long val;
@@ -620,15 +620,15 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr,
 	data->vrm = val;
 	return count;
 }
-static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
+static DEVICE_ATTR_RW(vrm);
 
-static ssize_t show_in_alarms(struct device *dev,
+static ssize_t alarms_in_show(struct device *dev,
 			      struct device_attribute *attr, char *buf)
 {
 	struct pc87360_data *data = pc87360_update_device(dev);
 	return sprintf(buf, "%u\n", data->in_alarms);
 }
-static DEVICE_ATTR(alarms_in, S_IRUGO, show_in_alarms, NULL);
+static DEVICE_ATTR_RO(alarms_in);
 
 static struct attribute *pc8736x_vin_attr_array[] = {
 	VIN_UNIT_ATTRS(0),
@@ -1006,14 +1006,14 @@ static ssize_t set_temp_crit(struct device *dev,
 		    show_temp_crit, set_temp_crit, 2),
 };
 
-static ssize_t show_temp_alarms(struct device *dev,
+static ssize_t alarms_temp_show(struct device *dev,
 				struct device_attribute *attr, char *buf)
 {
 	struct pc87360_data *data = pc87360_update_device(dev);
 	return sprintf(buf, "%u\n", data->temp_alarms);
 }
 
-static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL);
+static DEVICE_ATTR_RO(alarms_temp);
 
 /*
  * show_temp_min/max_alarm() reads data from the per-channel status
@@ -1106,14 +1106,14 @@ static ssize_t show_temp_fault(struct device *dev,
 	{ .attrs = pc8736x_temp_attr[2] }
 };
 
-static ssize_t show_name(struct device *dev,
+static ssize_t name_show(struct device *dev,
 			struct device_attribute *devattr, char *buf)
 {
 	struct pc87360_data *data = dev_get_drvdata(dev);
 	return sprintf(buf, "%s\n", data->name);
 }
 
-static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
+static DEVICE_ATTR_RO(name);
 
 /*
  * Device detection, registration and update

  parent reply	other threads:[~2016-12-22 12:32 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-22 12:04 [PATCH 00/66] use permission-specific DEVICE_ATTR variants Julia Lawall
2016-12-22 12:04 ` [PATCH 01/66] hwmon: (adm1021) " Julia Lawall
2016-12-22 12:04 ` [PATCH 02/66] hwmon: (adm1026) " Julia Lawall
2016-12-22 12:04 ` [PATCH 03/66] hwmon: (adm1031) " Julia Lawall
2016-12-22 12:04 ` [PATCH 04/66] hwmon: (adm9240) " Julia Lawall
2016-12-22 12:04 ` [PATCH 05/66] hwmon: (adt7470) " Julia Lawall
2016-12-22 12:04 ` [PATCH 06/66] hwmon: (adt7x10) " Julia Lawall
2016-12-22 12:04 ` [PATCH 07/66] hwmon: (asb100) " Julia Lawall
2016-12-22 12:04 ` [PATCH 08/66] hwmon: (atxp1) " Julia Lawall
2016-12-22 12:04 ` [PATCH 09/66] hwmon: (ds1621) " Julia Lawall
2016-12-22 12:04 ` [PATCH 10/66] hwmon: (f71882fg) " Julia Lawall
2016-12-22 12:04 ` [PATCH 11/66] hwmon: (fschmd) " Julia Lawall
2016-12-22 12:04 ` [PATCH 12/66] hwmon: (g760a) " Julia Lawall
2016-12-22 12:04 ` [PATCH 13/66] hwmon: (g762) " Julia Lawall
2016-12-22 12:04 ` [PATCH 14/66] hwmon: (gl520sm) " Julia Lawall
2016-12-22 12:04 ` [PATCH 15/66] hwmon: (gpio-fan) " Julia Lawall
2016-12-22 12:04 ` [PATCH 16/66] hwmon: (core) " Julia Lawall
2016-12-22 12:04 ` [PATCH 17/66] hwmon: (i5500_temp) " Julia Lawall
2016-12-22 12:04 ` [PATCH 18/66] hwmon: (i5k_amb) " Julia Lawall
2016-12-22 12:04 ` [PATCH 19/66] hwmon: (jz4740) " Julia Lawall
2016-12-22 12:04 ` [PATCH 20/66] hwmon: (lm63) " Julia Lawall
2016-12-22 12:04 ` [PATCH 21/66] hwmon: (lm70) " Julia Lawall
2016-12-22 12:04 ` [PATCH 22/66] hwmon: (lm80) " Julia Lawall
2016-12-22 12:04 ` [PATCH 23/66] hwmon: (lm85) " Julia Lawall
2016-12-22 12:04 ` [PATCH 24/66] hwmon: (lm87) " Julia Lawall
2016-12-22 12:04 ` [PATCH 25/66] hwmon: (lm92) " Julia Lawall
2016-12-22 12:04 ` [PATCH 26/66] hwmon: (lm93) " Julia Lawall
2016-12-22 12:04 ` [PATCH 27/66] hwmon: (max1111) " Julia Lawall
2016-12-22 12:04 ` [PATCH 28/66] hwmon: (max1619) " Julia Lawall
2016-12-22 12:04 ` [PATCH 29/66] hwmon: (max197) " Julia Lawall
2016-12-22 12:04 ` [PATCH 30/66] hwmon: (mc13783-adc) " Julia Lawall
2016-12-22 12:05 ` [PATCH 31/66] hwmon: (mcp3021) " Julia Lawall
2016-12-22 12:05 ` [PATCH 32/66] hwmon: (nct6683) " Julia Lawall
2016-12-22 12:05 ` [PATCH 33/66] hwmon: (nsa320) " Julia Lawall
2016-12-22 12:05 ` [PATCH 34/66] hwmon: (pcf8591) " Julia Lawall
2016-12-22 12:05 ` [PATCH 35/66] hwmon: (sht15) " Julia Lawall
2016-12-22 12:05 ` [PATCH 36/66] hwmon: (sis5595) " Julia Lawall
2016-12-22 12:05 ` [PATCH 37/66] hwmon: (smsc47m1) " Julia Lawall
2016-12-22 12:05 ` [PATCH 38/66] hwmon: (smsc47m192) " Julia Lawall
2016-12-22 12:05 ` [PATCH 39/66] hwmon: (via-cputemp) " Julia Lawall
2016-12-22 12:05 ` [PATCH 40/66] hwmon: (via686a) " Julia Lawall
2016-12-22 12:05 ` [PATCH 41/66] hwmon: (w83627ehf) " Julia Lawall
2016-12-22 12:05 ` [PATCH 42/66] hwmon: (w83627hf) " Julia Lawall
2016-12-22 12:05 ` [PATCH 43/66] hwmon: (w83781d) " Julia Lawall
2016-12-22 12:05 ` [PATCH 44/66] hwmon: (w83792d) " Julia Lawall
2016-12-22 12:05 ` [PATCH 45/66] hwmon: (w83791d) " Julia Lawall
2016-12-22 12:05 ` [PATCH 46/66] hwmon: (pc87427) " Julia Lawall
2016-12-22 12:05 ` [PATCH 47/66] hwmon: (f71805f) " Julia Lawall
2016-12-22 12:05 ` [PATCH 48/66] hwmon: (w83793) " Julia Lawall
2016-12-22 12:05 ` [PATCH 49/66] hwmon: (vt8231) " Julia Lawall
2016-12-22 12:05 ` [PATCH 50/66] hwmon: (k10temp) " Julia Lawall
2016-12-22 12:05 ` [PATCH 51/66] hwmon: (dme1737) " Julia Lawall
2016-12-22 12:05 ` [PATCH 52/66] hwmon: (it87) " Julia Lawall
2016-12-22 12:05 ` [PATCH 53/66] hwmon: (lm90) " Julia Lawall
2016-12-22 12:05 ` [PATCH 54/66] hwmon: (nct6775) " Julia Lawall
2016-12-22 12:05 ` Julia Lawall [this message]
2016-12-22 12:05 ` [PATCH 56/66] hwmon: (lm78) " Julia Lawall
2016-12-22 12:05 ` [PATCH 57/66] hwmon: (sch5627) " Julia Lawall
2016-12-22 12:05 ` [PATCH 58/66] hwmon: (k8temp) " Julia Lawall
2016-12-22 12:05 ` [PATCH 59/66] hwmon: (adm1025) " Julia Lawall
2016-12-22 12:05 ` [PATCH 60/66] hwmon: (lm83) " Julia Lawall
2016-12-22 12:05 ` [PATCH 61/66] hwmon: (emc2103) " Julia Lawall
2016-12-22 12:05 ` [PATCH 62/66] hwmon: (max6650) " Julia Lawall
2016-12-22 12:05 ` [PATCH 63/66] hwmon: (lm95234) " Julia Lawall
2016-12-22 12:05 ` [PATCH 64/66] hwmon: (adt7475) " Julia Lawall
2016-12-22 12:05 ` [PATCH 65/66] hwmon: (fam15h_power) " Julia Lawall
2016-12-23  3:23   ` Huang Rui
2016-12-22 12:05 ` [PATCH 66/66] hwmon: (tmp401) " Julia Lawall
2016-12-23  2:38 ` [PATCH 00/66] " Guenter Roeck
2016-12-23  6:39   ` Julia Lawall
2016-12-23 13:03   ` Julia Lawall

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=1482408335-3435-56-git-send-email-Julia.Lawall@lip6.fr \
    --to=julia.lawall@lip6.fr \
    --cc=jdelvare@suse.com \
    --cc=jim.cromie@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@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 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).