public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Huang Rui <ray.huang@amd.com>
To: Julia Lawall <Julia.Lawall@lip6.fr>
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: Re: [PATCH 65/66] hwmon: (fam15h_power) use permission-specific DEVICE_ATTR variants
Date: Fri, 23 Dec 2016 03:23:17 +0000	[thread overview]
Message-ID: <20161223032316.GA11339@hr-amur2> (raw)
In-Reply-To: <1482408335-3435-66-git-send-email-Julia.Lawall@lip6.fr>

On Thu, Dec 22, 2016 at 01:05:34PM +0100, Julia Lawall wrote:
> 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>
> 

Acked-by: Huang Rui <ray.huang@amd.com>

Thanks,
Rui

> ---
>  drivers/hwmon/fam15h_power.c |   34 ++++++++++++++++------------------
>  1 file changed, 16 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
> index 15aa49d..9545a34 100644
> --- a/drivers/hwmon/fam15h_power.c
> +++ b/drivers/hwmon/fam15h_power.c
> @@ -83,8 +83,8 @@ static bool is_carrizo_or_later(void)
>  	return boot_cpu_data.x86 = 0x15 && boot_cpu_data.x86_model >= 0x60;
>  }
>  
> -static ssize_t show_power(struct device *dev,
> -			  struct device_attribute *attr, char *buf)
> +static ssize_t power1_input_show(struct device *dev,
> +				 struct device_attribute *attr, char *buf)
>  {
>  	u32 val, tdp_limit, running_avg_range;
>  	s32 running_avg_capture;
> @@ -136,16 +136,16 @@ static ssize_t show_power(struct device *dev,
>  	curr_pwr_watts = (curr_pwr_watts * 15625) >> (10 + running_avg_range);
>  	return sprintf(buf, "%u\n", (unsigned int) curr_pwr_watts);
>  }
> -static DEVICE_ATTR(power1_input, S_IRUGO, show_power, NULL);
> +static DEVICE_ATTR_RO(power1_input);
>  
> -static ssize_t show_power_crit(struct device *dev,
> -			       struct device_attribute *attr, char *buf)
> +static ssize_t power1_crit_show(struct device *dev,
> +				struct device_attribute *attr, char *buf)
>  {
>  	struct fam15h_power_data *data = dev_get_drvdata(dev);
>  
>  	return sprintf(buf, "%u\n", data->processor_pwr_watts);
>  }
> -static DEVICE_ATTR(power1_crit, S_IRUGO, show_power_crit, NULL);
> +static DEVICE_ATTR_RO(power1_crit);
>  
>  static void do_read_registers_on_cu(void *_data)
>  {
> @@ -212,9 +212,8 @@ static int read_registers(struct fam15h_power_data *data)
>  	return 0;
>  }
>  
> -static ssize_t acc_show_power(struct device *dev,
> -			      struct device_attribute *attr,
> -			      char *buf)
> +static ssize_t power1_average_show(struct device *dev,
> +				   struct device_attribute *attr, char *buf)
>  {
>  	struct fam15h_power_data *data = dev_get_drvdata(dev);
>  	u64 prev_cu_acc_power[MAX_CUS], prev_ptsc[MAX_CUS],
> @@ -267,20 +266,20 @@ static ssize_t acc_show_power(struct device *dev,
>  
>  	return sprintf(buf, "%llu\n", (unsigned long long)avg_acc);
>  }
> -static DEVICE_ATTR(power1_average, S_IRUGO, acc_show_power, NULL);
> +static DEVICE_ATTR_RO(power1_average);
>  
> -static ssize_t acc_show_power_period(struct device *dev,
> -				     struct device_attribute *attr,
> -				     char *buf)
> +static ssize_t power1_average_interval_show(struct device *dev,
> +					    struct device_attribute *attr,
> +					    char *buf)
>  {
>  	struct fam15h_power_data *data = dev_get_drvdata(dev);
>  
>  	return sprintf(buf, "%lu\n", data->power_period);
>  }
>  
> -static ssize_t acc_set_power_period(struct device *dev,
> -				    struct device_attribute *attr,
> -				    const char *buf, size_t count)
> +static ssize_t power1_average_interval_store(struct device *dev,
> +					     struct device_attribute *attr,
> +					     const char *buf, size_t count)
>  {
>  	struct fam15h_power_data *data = dev_get_drvdata(dev);
>  	unsigned long temp;
> @@ -301,8 +300,7 @@ static ssize_t acc_set_power_period(struct device *dev,
>  
>  	return count;
>  }
> -static DEVICE_ATTR(power1_average_interval, S_IRUGO | S_IWUSR,
> -		   acc_show_power_period, acc_set_power_period);
> +static DEVICE_ATTR_RW(power1_average_interval);
>  
>  static int fam15h_power_init_attrs(struct pci_dev *pdev,
>  				   struct fam15h_power_data *data)
> 

  reply	other threads:[~2016-12-23  3:23 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 ` [PATCH 55/66] hwmon: (pc87360) " Julia Lawall
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 [this message]
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=20161223032316.GA11339@hr-amur2 \
    --to=ray.huang@amd.com \
    --cc=Julia.Lawall@lip6.fr \
    --cc=jdelvare@suse.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