All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Marcelo Schmitt" <marcelo.schmitt1@gmail.com>,
	"David Lechner" <dlechner@baylibre.com>,
	"Salah Triki" <salah.triki@gmail.com>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Marcelo Schmitt" <marcelo.schmitt@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] iio: adc: ad4170-4: Use ERR_PTR() with %pe to improve error logging
Date: Fri, 8 Aug 2025 15:43:51 +0100	[thread overview]
Message-ID: <20250808154351.000054da@huawei.com> (raw)
In-Reply-To: <CAHp75VfWsyj6q1dYK2dL7Mp3W=98SMGJT=ner3k6ty_NFVYM+Q@mail.gmail.com>

On Fri, 8 Aug 2025 14:30:53 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Fri, Aug 8, 2025 at 2:07 PM Marcelo Schmitt
> <marcelo.schmitt1@gmail.com> wrote:
> > On 08/07, David Lechner wrote:  
> > > On 8/7/25 4:02 PM, Andy Shevchenko wrote:  
> > > > On Thu, Aug 7, 2025 at 11:01 PM Andy Shevchenko
> > > > <andy.shevchenko@gmail.com> wrote:  
> > > >> On Thu, Aug 7, 2025 at 6:03 PM David Lechner <dlechner@baylibre.com> wrote:  
> > > >>> On 8/7/25 3:05 AM, Salah Triki wrote:  
> 
> ...
> 
> > > >>>>       ret = __ad4170_read_sample(indio_dev, chan, val);
> > > >>>>       if (ret) {
> > > >>>> -             dev_err(dev, "failed to read sample: %d\n", ret);
> > > >>>> +             dev_err(dev, "failed to read sample: %pe\n", ERR_PTR(ret));
> > > >>>>
> > > >>>>               ret2 = ad4170_set_channel_enable(st, chan->address, false);
> > > >>>>               if (ret2)
> > > >>>> -                     dev_err(dev, "failed to disable channel: %d\n", ret2);
> > > >>>> +                     dev_err(dev, "failed to disable channel: %pe\n", ERR_PTR(ret2));
> > > >>>>
> > > >>>>               return ret;
> > > >>>>       }  
> > > >>>
> > > >>> Interesting, I didn't know we had this format specifier. But I think
> > > >>> this is something we would want to do kernel-wide or not at all to stay
> > > >>> consistent.  
> > > >>
> > > >> I'm sorry but I didn't follow. This is a kernel-wide format specifier.  
> > >
> > > I meant that it would be strange to make this change just in one
> > > driver and not do the same everywhere else.  
> >
> > Casting error values to pointers is already being done by many IIO drivers
> > if we consider the use of dev_err_probe().
> > __dev_probe_failed() does the casting from within dev_err_probe()
> > https://elixir.bootlin.com/linux/v6.15.9/source/drivers/base/core.c#L5026  
> 
> This is a manipulation. The dev_err_probe() and __dev_probe_failed()
> are parts of the core where we specifically bend the rules for all in
> one place just for a reason to avoid this spreading (and avoid
> creating specific APIs).
> 
> > Thus, I think this patch makes the error messaging from ad4170
> > more consistent and, because of that, I also see this as a good change.
> >
> > Reviewed-by: Marcelo Schmitt <marcelo.schmitt@analog.com>  
> 
> Thanks for the review...
> 
> > Though, I'm also totally fine if maintainers prefer not to take this change for
> > whatever reason.  
> 
> ...but the below still stays...
> 
> > > > And to be clear: I am not in favour of this change exactly due to a
> > > > bit weird (for the reader) castings just for the sake of use of %pe.  
> 

Agreed.  To me having this cast broadly used in drivers is just too weird.

I'd prefer we dig down a little further and use what %pe is using directly.

#include <linux/errname.h>

printk(... %s\n", errname(ret));

It's not much used so far though but there is precedence via a wrapper
in bcachefs. We'd probably want to select CONFIG_SYMBOLIC_ERRNAME for IIO
though (rather than every driver).

Jonathan




      reply	other threads:[~2025-08-08 14:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-07  8:05 [PATCH v2] iio: adc: ad4170-4: Use ERR_PTR() with %pe to improve error logging Salah Triki
2025-08-07 16:02 ` David Lechner
2025-08-07 21:01   ` Andy Shevchenko
2025-08-07 21:02     ` Andy Shevchenko
2025-08-07 21:14       ` David Lechner
2025-08-07 21:20         ` Andy Shevchenko
2025-08-08 12:07         ` Marcelo Schmitt
2025-08-08 12:30           ` Andy Shevchenko
2025-08-08 14:43             ` Jonathan Cameron [this message]

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=20250808154351.000054da@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.schmitt1@gmail.com \
    --cc=marcelo.schmitt@analog.com \
    --cc=nuno.sa@analog.com \
    --cc=salah.triki@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.