The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Richard Fitzgerald <rf@opensource.cirrus.com>
Cc: rafael@kernel.org, dakr@kernel.org, linux-kernel@vger.kernel.org,
	patches@opensource.cirrus.com
Subject: Re: [PATCH] driver core: Introduce dev_err_ret() and dev_warn_ret()
Date: Thu, 24 Apr 2025 12:24:51 +0200	[thread overview]
Message-ID: <2025042427-supplier-matchbox-4342@gregkh> (raw)
In-Reply-To: <20250424093839.27451-1-rf@opensource.cirrus.com>

On Thu, Apr 24, 2025 at 10:38:39AM +0100, Richard Fitzgerald wrote:
> Add two helper functions dev_err_ret() and dev_warn_ret(). These are
> like dev_err_probe() and dev_warn_probe() but there is no special
> handling of EPROBE_DEFER.
> 
> Although dev_{err,warn}_probe() could be used outside of probe(), it
> has the disadvantage that if the error code is unexpectedly EPROBE_DEFER
> it would suppress it and also update the deferred probe reason. If code
> receives a EPROBE_DEFER in a situation where it cannot handle it, that
> really should be logged. There is also the potential for confusion when
> seeing a dev_{err,warn}_probe() inside a function that is not actually
> part of probe.
> 
> They have the same advantage of a standard error message format, and
> returning the error value so that code like:
> 
>   if (err) {
>           dev_err(dev, ..., err);
>           return err;
>   }
> 
> can be replaced with
> 
>   if (err)
>           return dev_err_ret(dev, err, ...);
> 
> The simple cases of dev_err_ret() and dev_warn_ret() could have been
> implemented as a trivial inline function to call dev_{err|warn}() and
> then return the passed error value. But it is useful to keep the same
> message format as dev_{err|warn}_probe() and re-using that code avoids
> scattering duplicate format strings around. Also it should slightly
> reduce the size of the error path code in the kernel because the compiler
> does not have to preserve the error code value for the final return.
> 
> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
> ---
>  drivers/base/core.c        | 112 +++++++++++++++++++++++++++++++++----
>  include/linux/dev_printk.h |   3 +
>  2 files changed, 105 insertions(+), 10 deletions(-)

I'd like to see some users of this before we even review it as we don't
know how it would work, or if it would even save any code anywhere else.

thanks,

greg k-h

      reply	other threads:[~2025-04-24 10:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-24  9:38 [PATCH] driver core: Introduce dev_err_ret() and dev_warn_ret() Richard Fitzgerald
2025-04-24 10:24 ` Greg KH [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=2025042427-supplier-matchbox-4342@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=dakr@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=rafael@kernel.org \
    --cc=rf@opensource.cirrus.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox