Re: [RFC PATCH] checkpatch: Check check for places where dev_err_probe() would likely be better than dev_err()

From: Linus Walleij
Date: Wed Sep 14 2022 - 06:24:19 EST


On Sun, Sep 11, 2022 at 3:21 PM Christophe JAILLET
<christophe.jaillet@xxxxxxxxxx> wrote:
> 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@xxxxxxxxxx>
> > ---
> > 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 :)

Needless to say I am a big fan of this patch!
Acked-by: Linus Walleij <linus.walleij@xxxxxxxxxx>

Yours,
Linus Walleij