From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>,
Dwaipayan Ray <dwaipayanray1@gmail.com>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>,
"linus.walleij@linaro.org" <linus.walleij@linaro.org>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [RFC PATCH] checkpatch: Check check for places where dev_err_probe() would likely be better than dev_err()
Date: Sun, 11 Sep 2022 15:21:54 +0200 [thread overview]
Message-ID: <fac99d27-2e28-3c08-4cf3-c97afec99b77@wanadoo.fr> (raw)
In-Reply-To: <3cdc2e776dea77b07c75694ba1410bd21e8ed749.1662902045.git.christophe.jaillet@wanadoo.fr>
Le 11/09/2022 à 15:15, Christophe JAILLET a écrit :
> Some functions are known to potentially return -EPROBE_DEFER. In such a
> case, it is likely that dev_err_probe() is a better choice than err_err().
>
> dev_err_probe():
> - is usually less verbose
> - generates smaller .o files
> - handles -EPROBE_DEFER so that logs are not spammed
> - automatically log the error code in a human readable way
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> This patch is only a PoC to see if there is some interest in such a new
> check.
> The hard coded '5 lines of context' has been chosen because a typical
> pattern is:
>
> clk = devm_clk_get(dev, "clk_lcd");
> if (IS_ERR(clk) {
> dev_err(dev, "Error meesage\n");
> return PTR_ERR(clk);
> }
(adding Linus Walleij)
I forgot to say that this patch is a try to address the comment from
Linus Walleij at [1].
It would not help "fixing a gazillion dev_err_probe()", but it could
help not having more to fix later :)
CJ
[1]:
https://lore.kernel.org/all/CACRpkdZEcTD1A3tR=d4fDF89ECMDfchVPW921v6X6ARiPXHEMQ@mail.gmail.com/
> ---
> scripts/checkpatch.pl | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 2737e4ced574..88365749ed2e 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2625,6 +2625,9 @@ sub process {
> my $last_blank_line = 0;
> my $last_coalesced_string_linenr = -1;
>
> + my $last_function_that_return_defer = "";
> + my $last_function_that_return_defer_linenr = 0;
> +
> our @report = ();
> our $cnt_lines = 0;
> our $cnt_error = 0;
> @@ -7459,6 +7462,17 @@ sub process {
> WARN("DUPLICATED_SYSCTL_CONST",
> "duplicated sysctl range checking value '$1', consider using the shared one in include/linux/sysctl.h\n" . $herecurr);
> }
> +
> +# check for places where dev_err_probe() would likely be better than dev_err()
> + if ($line =~ /((?:devm_)?clk_get)s*\(/) {
> + $last_function_that_return_defer = $1;
> + $last_function_that_return_defer_linenr = $linenr;
> + }
> + if ($last_function_that_return_defer_linenr >= ($linenr - 5) &&
> + $line =~ /dev_err[^_]/) {
> + WARN("LIKELY_DEV_ERR_PROBE",
> + "dev_err_probe() is likely a better choice than err_err() after a " . $last_function_that_return_defer . "() call\n" . $herecurr);
> + }
> }
>
> # If we have no input at all, then there is nothing to report on
next prev parent reply other threads:[~2022-09-11 13:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-11 13:15 Christophe JAILLET
2022-09-11 13:21 ` Christophe JAILLET [this message]
2022-09-14 10:23 ` Linus Walleij
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=fac99d27-2e28-3c08-4cf3-c97afec99b77@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=apw@canonical.com \
--cc=dwaipayanray1@gmail.com \
--cc=joe@perches.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®