Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1564221 > unrolled thread

[PATCH 1/2] hwmon: (lm70) Utilize dev_warn instead of pr_warn

Started byFlorian Fainelli <f.fainelli@gmail.com>
First post2017-01-21 20:30 +0100
Last post2017-01-23 08:20 +0100
Articles 7 — 4 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 1/2] hwmon: (lm70) Utilize dev_warn instead of pr_warn Florian Fainelli <f.fainelli@gmail.com> - 2017-01-21 20:30 +0100
    Re: [PATCH 1/2] hwmon: (lm70) Utilize dev_warn instead of pr_warn Guenter Roeck <linux@roeck-us.net> - 2017-01-21 21:20 +0100
    Re: [PATCH 1/2] hwmon: (lm70) Utilize dev_warn instead of pr_warn Joe Perches <joe@perches.com> - 2017-01-23 07:50 +0100
      Re: [PATCH 1/2] hwmon: (lm70) Utilize dev_warn instead of pr_warn Joe Perches <joe@perches.com> - 2017-01-23 08:00 +0100
        Re: [PATCH 1/2] hwmon: (lm70) Utilize dev_warn instead of pr_warn Julia Lawall <julia.lawall@lip6.fr> - 2017-01-23 13:10 +0100
      Re: [PATCH 1/2] hwmon: (lm70) Utilize dev_warn instead of pr_warn Guenter Roeck <linux@roeck-us.net> - 2017-01-23 08:10 +0100
        Re: [PATCH 1/2] hwmon: (lm70) Utilize dev_warn instead of pr_warn Julia Lawall <julia.lawall@lip6.fr> - 2017-01-23 08:20 +0100

#1564221 — [PATCH 1/2] hwmon: (lm70) Utilize dev_warn instead of pr_warn

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2017-01-21 20:30 +0100
Subject[PATCH 1/2] hwmon: (lm70) Utilize dev_warn instead of pr_warn
Message-ID<t29wl-7O2-9@gated-at.bofh.it>
We have a device reference, utilize it instead of pr_warn().

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/hwmon/lm70.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/lm70.c b/drivers/hwmon/lm70.c
index d6ecd1a4be59..52c5cdd00448 100644
--- a/drivers/hwmon/lm70.c
+++ b/drivers/hwmon/lm70.c
@@ -72,7 +72,8 @@ static ssize_t temp1_input_show(struct device *dev,
 	 */
 	status = spi_write_then_read(spi, NULL, 0, &rxbuf[0], 2);
 	if (status < 0) {
-		pr_warn("spi_write_then_read failed with status %d\n", status);
+		dev_warn(dev, "spi_write_then_read failed with status %d\n",
+			 status);
 		goto out;
 	}
 	raw = (rxbuf[0] << 8) + rxbuf[1];
-- 
2.9.3

[toc] | [next] | [standalone]


#1564230

FromGuenter Roeck <linux@roeck-us.net>
Date2017-01-21 21:20 +0100
Message-ID<t2aiJ-8j7-3@gated-at.bofh.it>
In reply to#1564221
On 01/21/2017 11:20 AM, Florian Fainelli wrote:
> We have a device reference, utilize it instead of pr_warn().
>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---

Applied to -next.

Thanks,
Guenter

[toc] | [prev] | [next] | [standalone]


#1564710

FromJoe Perches <joe@perches.com>
Date2017-01-23 07:50 +0100
Message-ID<t2GBY-32t-13@gated-at.bofh.it>
In reply to#1564221
On Sat, 2017-01-21 at 11:20 -0800, Florian Fainelli wrote:
> We have a device reference, utilize it instead of pr_warn().

There is at least one more hwmon to convert in applesmc.c

Perhaps a coccinelle script?

Two questions for Julia Lawall:

o is there a better way to do this than repeat the blocks
  one for each replacement
o can struct device * dev be made an arbitrary identifier

$ cat dev_printk.cocci
@@
identifier fn;
type T;
@@

T fn ( ..., struct device * dev, ... ) {
<...
-	pr_emerg(
+	dev_emerg(dev,
	...);
...>
}

@@
identifier fn;
type T;
@@

T fn ( ..., struct device * dev, ... ) {
<...
-	pr_crit(
+	dev_crit(dev,
	...);
...>
}

@@
identifier fn;
type T;
@@

T fn ( ..., struct device * dev, ... ) {
<...
-	pr_alert(
+	dev_alert(dev,
	...);
...>
}

@@
identifier fn;
type T;
@@

T fn ( ..., struct device * dev, ... ) {
<...
-	pr_err(
+	dev_err(dev,
	...);
...>
}

@@
identifier fn;
type T;
@@

T fn ( ..., struct device * dev, ... ) {
<...
-	pr_notice(
+	dev_notice(dev,
	...);
...>
}

@@
identifier fn;
type T;
@@

T fn ( ..., struct device * dev, ... ) {
<...
-	pr_warn(
+	dev_warn(dev,
	...);
...>
}

@@
identifier fn;
type T;
@@

T fn ( ..., struct device * dev, ... ) {
<...
-	pr_info(
+	dev_info(dev,
	...);
...>
}

@@
identifier fn;
type T;
@@

T fn ( ..., struct device * dev, ... ) {
<...
-	pr_debug(
+	dev_dbg(dev,
	...);
...>
}

[toc] | [prev] | [next] | [standalone]


#1564713

FromJoe Perches <joe@perches.com>
Date2017-01-23 08:00 +0100
Message-ID<t2GLE-35L-5@gated-at.bofh.it>
In reply to#1564710
On Sun, 2017-01-22 at 22:43 -0800, Joe Perches wrote:
> Two questions for Julia Lawall:
> 
> o is there a better way to do this than repeat the blocks
>   one for each replacement
> o can struct device * dev be made an arbitrary identifier
> 
> $ cat dev_printk.cocci
> @@
> identifier fn;
> type T;
> @@
> 
> T fn ( ..., struct device * dev, ... ) {
> <...
> -	pr_emerg(
> +	dev_emerg(dev,
> 	...);
> ...>
> }

Well, the second question is simple if I would just
think a little before asking...

@@
identifier fn;
identifier dev;
type T;
@@

T fn ( ..., struct device * dev, ... ) {
<...
-	pr_emerg(
+	dev_emerg(dev,
	...);
...>
}

etc...

[toc] | [prev] | [next] | [standalone]


#1564932

FromJulia Lawall <julia.lawall@lip6.fr>
Date2017-01-23 13:10 +0100
Message-ID<t2LBF-6hm-41@gated-at.bofh.it>
In reply to#1564713

On Sun, 22 Jan 2017, Joe Perches wrote:

> On Sun, 2017-01-22 at 22:43 -0800, Joe Perches wrote:
> > Two questions for Julia Lawall:
> >
> > o is there a better way to do this than repeat the blocks
> >   one for each replacement
> > o can struct device * dev be made an arbitrary identifier
> >
> > $ cat dev_printk.cocci
> > @@
> > identifier fn;
> > type T;
> > @@
> >
> > T fn ( ..., struct device * dev, ... ) {
> > <...
> > -	pr_emerg(
> > +	dev_emerg(dev,
> > 	...);
> > ...>
> > }
>
> Well, the second question is simple if I would just
> think a little before asking...
>
> @@
> identifier fn;
> identifier dev;

Yes :)

julia

> type T;
> @@
>
> T fn ( ..., struct device * dev, ... ) {
> <...
> -	pr_emerg(
> +	dev_emerg(dev,
> 	...);
> ...>
> }
>
> etc...
>
>

[toc] | [prev] | [next] | [standalone]


#1564715

FromGuenter Roeck <linux@roeck-us.net>
Date2017-01-23 08:10 +0100
Message-ID<t2GVj-3o8-1@gated-at.bofh.it>
In reply to#1564710
On 01/22/2017 10:43 PM, Joe Perches wrote:
> On Sat, 2017-01-21 at 11:20 -0800, Florian Fainelli wrote:
>> We have a device reference, utilize it instead of pr_warn().
>
> There is at least one more hwmon to convert in applesmc.c
>
> Perhaps a coccinelle script?
>
> Two questions for Julia Lawall:
>
> o is there a better way to do this than repeat the blocks
>   one for each replacement
> o can struct device * dev be made an arbitrary identifier

Definitely yes here; otherwise you only catch the ones named 'dev'.
Did you try "identifier dev;" ?

The type of fn is irrelevant; you don't need to specify it.

There is also the case where 'struct device *dev' is a local variable

fn(...) {
...
struct device *dev = e;
<...
...>
}

or when it isn't but is still available

fn (..., struct \(platform_device\|i2c_device\|spi_device\) *pdev, ...) {
}

>
> $ cat dev_printk.cocci
> @@
> identifier fn;
> type T;
> @@
>
> T fn ( ..., struct device * dev, ... ) {
> <...
> -	pr_emerg(
> +	dev_emerg(dev,
> 	...);
> ...>
> }
>
> @@
> identifier fn;
> type T;
> @@
>
> T fn ( ..., struct device * dev, ... ) {
> <...
> -	pr_crit(
> +	dev_crit(dev,
> 	...);
> ...>
> }
>
> @@
> identifier fn;
> type T;
> @@
>
> T fn ( ..., struct device * dev, ... ) {
> <...
> -	pr_alert(
> +	dev_alert(dev,
> 	...);
> ...>
> }
>
> @@
> identifier fn;
> type T;
> @@
>
> T fn ( ..., struct device * dev, ... ) {
> <...
> -	pr_err(
> +	dev_err(dev,
> 	...);
> ...>
> }
>
> @@
> identifier fn;
> type T;
> @@
>
> T fn ( ..., struct device * dev, ... ) {
> <...
> -	pr_notice(
> +	dev_notice(dev,
> 	...);
> ...>
> }
>
> @@
> identifier fn;
> type T;
> @@
>
> T fn ( ..., struct device * dev, ... ) {
> <...
> -	pr_warn(
> +	dev_warn(dev,
> 	...);
> ...>
> }
>
> @@
> identifier fn;
> type T;
> @@
>
> T fn ( ..., struct device * dev, ... ) {
> <...
> -	pr_info(
> +	dev_info(dev,
> 	...);
> ...>
> }
>
> @@
> identifier fn;
> type T;
> @@
>
> T fn ( ..., struct device * dev, ... ) {
> <...
> -	pr_debug(
> +	dev_dbg(dev,
> 	...);
> ...>
> }
>
>

[toc] | [prev] | [next] | [standalone]


#1564722

FromJulia Lawall <julia.lawall@lip6.fr>
Date2017-01-23 08:20 +0100
Message-ID<t2H50-3rt-19@gated-at.bofh.it>
In reply to#1564715

On Sun, 22 Jan 2017, Guenter Roeck wrote:

> On 01/22/2017 10:43 PM, Joe Perches wrote:
> > On Sat, 2017-01-21 at 11:20 -0800, Florian Fainelli wrote:
> > > We have a device reference, utilize it instead of pr_warn().
> >
> > There is at least one more hwmon to convert in applesmc.c
> >
> > Perhaps a coccinelle script?
> >
> > Two questions for Julia Lawall:
> >
> > o is there a better way to do this than repeat the blocks
> >   one for each replacement
> > o can struct device * dev be made an arbitrary identifier
>
> Definitely yes here; otherwise you only catch the ones named 'dev'.
> Did you try "identifier dev;" ?

Definitely do that.

>
> The type of fn is irrelevant; you don't need to specify it.

Agreed.

> There is also the case where 'struct device *dev' is a local variable
>
> fn(...) {
> ...
> struct device *dev = e;
> <...
> ...>
> }

Here, you don't need the fn(...) { ... } part.  It would also be good to
say:

expression e != NULL;

dev could also be initialized:

@@
struct device *dev;
expression e != NULL;
expression e1;
@@

dev = e;
<...
-
+
...>
? dev = e1; // stop when dev is reinitialized, to avoid a double match

The rules can all be merged together with a disjunction:

(
- pr_emerg
+ dev_emerg
|
- pr_crit
+ dev_crit  // fill in all cases
)
  (
+ dev,
  ...)

julia


> or when it isn't but is still available
>
> fn (..., struct \(platform_device\|i2c_device\|spi_device\) *pdev, ...) {
> }
>
> >
> > $ cat dev_printk.cocci
> > @@
> > identifier fn;
> > type T;
> > @@
> >
> > T fn ( ..., struct device * dev, ... ) {
> > <...
> > -	pr_emerg(
> > +	dev_emerg(dev,
> > 	...);
> > ...>
> > }
> >
> > @@
> > identifier fn;
> > type T;
> > @@
> >
> > T fn ( ..., struct device * dev, ... ) {
> > <...
> > -	pr_crit(
> > +	dev_crit(dev,
> > 	...);
> > ...>
> > }
> >
> > @@
> > identifier fn;
> > type T;
> > @@
> >
> > T fn ( ..., struct device * dev, ... ) {
> > <...
> > -	pr_alert(
> > +	dev_alert(dev,
> > 	...);
> > ...>
> > }
> >
> > @@
> > identifier fn;
> > type T;
> > @@
> >
> > T fn ( ..., struct device * dev, ... ) {
> > <...
> > -	pr_err(
> > +	dev_err(dev,
> > 	...);
> > ...>
> > }
> >
> > @@
> > identifier fn;
> > type T;
> > @@
> >
> > T fn ( ..., struct device * dev, ... ) {
> > <...
> > -	pr_notice(
> > +	dev_notice(dev,
> > 	...);
> > ...>
> > }
> >
> > @@
> > identifier fn;
> > type T;
> > @@
> >
> > T fn ( ..., struct device * dev, ... ) {
> > <...
> > -	pr_warn(
> > +	dev_warn(dev,
> > 	...);
> > ...>
> > }
> >
> > @@
> > identifier fn;
> > type T;
> > @@
> >
> > T fn ( ..., struct device * dev, ... ) {
> > <...
> > -	pr_info(
> > +	dev_info(dev,
> > 	...);
> > ...>
> > }
> >
> > @@
> > identifier fn;
> > type T;
> > @@
> >
> > T fn ( ..., struct device * dev, ... ) {
> > <...
> > -	pr_debug(
> > +	dev_dbg(dev,
> > 	...);
> > ...>
> > }
> >
> >
>
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web