linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] driver code: print symbolic error code
@ 2020-08-28 16:14 Michał Mirosław
  2020-08-28 18:22 ` Tom Rix
  0 siblings, 1 reply; 3+ messages in thread
From: Michał Mirosław @ 2020-08-28 16:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Andrzej Hajda,
	Andy Shevchenko, Mark Brown
  Cc: linux-kernel

dev_err_probe() prepends the message with an error code. Let's make it
more readable by translating the code to a more recognisable symbol.

Fixes: a787e5400a1c ("driver core: add device probe log helper")
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/base/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index ac1046a382bc..1a4706310b28 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -4237,10 +4237,10 @@ int dev_err_probe(const struct device *dev, int err, const char *fmt, ...)
 	vaf.va = &args;
 
 	if (err != -EPROBE_DEFER) {
-		dev_err(dev, "error %d: %pV", err, &vaf);
+		dev_err(dev, "error %pe: %pV", ERR_PTR(err), &vaf);
 	} else {
 		device_set_deferred_probe_reason(dev, &vaf);
-		dev_dbg(dev, "error %d: %pV", err, &vaf);
+		dev_dbg(dev, "error %pe: %pV", ERR_PTR(err), &vaf);
 	}
 
 	va_end(args);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] driver code: print symbolic error code
  2020-08-28 16:14 [PATCH] driver code: print symbolic error code Michał Mirosław
@ 2020-08-28 18:22 ` Tom Rix
  2020-08-29 10:43   ` Michał Mirosław
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Rix @ 2020-08-28 18:22 UTC (permalink / raw)
  To: Michał Mirosław, Greg Kroah-Hartman, Rafael J. Wysocki,
	Andrzej Hajda, Andy Shevchenko, Mark Brown
  Cc: linux-kernel


On 8/28/20 9:14 AM, Michał Mirosław wrote:
> dev_err_probe() prepends the message with an error code. Let's make it
> more readable by translating the code to a more recognisable symbol.
recognizable
>
> Fixes: a787e5400a1c ("driver core: add device probe log helper")
is this change really to fix a bug?
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
>  drivers/base/core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index ac1046a382bc..1a4706310b28 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -4237,10 +4237,10 @@ int dev_err_probe(const struct device *dev, int err, const char *fmt, ...)
>  	vaf.va = &args;
>  
>  	if (err != -EPROBE_DEFER) {
> -		dev_err(dev, "error %d: %pV", err, &vaf);
> +		dev_err(dev, "error %pe: %pV", ERR_PTR(err), &vaf);
>  	} else {
>  		device_set_deferred_probe_reason(dev, &vaf);
> -		dev_dbg(dev, "error %d: %pV", err, &vaf);
> +		dev_dbg(dev, "error %pe: %pV", ERR_PTR(err), &vaf);

Should just use '-EPROBE_DEFER' directly instead of making printk do it.

or maybe reduce the original if-else to an just an if

if (err == -EPROBE_DEFER)

    device_set_deferred_probe_reason(...

dev_dbg(dev, "error %pe ...

Tom

>  	}
>  
>  	va_end(args);


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] driver code: print symbolic error code
  2020-08-28 18:22 ` Tom Rix
@ 2020-08-29 10:43   ` Michał Mirosław
  0 siblings, 0 replies; 3+ messages in thread
From: Michał Mirosław @ 2020-08-29 10:43 UTC (permalink / raw)
  To: Tom Rix
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Andrzej Hajda,
	Andy Shevchenko, Mark Brown, linux-kernel

On Fri, Aug 28, 2020 at 11:22:25AM -0700, Tom Rix wrote:
> 
> On 8/28/20 9:14 AM, Michał Mirosław wrote:
> > dev_err_probe() prepends the message with an error code. Let's make it
> > more readable by translating the code to a more recognisable symbol.
> recognizable
> >
> > Fixes: a787e5400a1c ("driver core: add device probe log helper")
> is this change really to fix a bug?
[...]

Yes, but this depends on how you define a bug. :-)

Best Regards,
Michał Mirosław

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-29 10:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28 16:14 [PATCH] driver code: print symbolic error code Michał Mirosław
2020-08-28 18:22 ` Tom Rix
2020-08-29 10:43   ` Michał Mirosław

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).