From: Lee Jones <lee.jones@linaro.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: linux-pwm@vger.kernel.org,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Ludovic Desroches <ludovic.desroches@microchip.com>,
Thierry Reding <thierry.reding@gmail.com>,
kernel@pengutronix.de,
Claudiu Beznea <claudiu.beznea@microchip.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] pwm: atmel: Make use of dev_err_probe()
Date: Wed, 12 Aug 2020 09:47:51 +0100 [thread overview]
Message-ID: <20200812084751.GE4354@dell> (raw)
In-Reply-To: <20200812083204.kktnid63j6vefsky@pengutronix.de>
On Wed, 12 Aug 2020, Uwe Kleine-König wrote:
> On Wed, Aug 12, 2020 at 09:20:02AM +0100, Lee Jones wrote:
> > On Wed, 12 Aug 2020, Uwe Kleine-König wrote:
> >
> > > Add an error message for failure points that currently lack a message
> > > and convert dev_err to dev_err_probe() which does the right thing for
> > > -EPROBE_DEFER. Also slightly simplify the error handling.
> > >
> > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > > ---
> > > drivers/pwm/pwm-atmel.c | 24 +++++++++++-------------
> > > 1 file changed, 11 insertions(+), 13 deletions(-)
> > >
> > > diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c
> > > index 6161e7e3e9ac..aa0b36695dc7 100644
> > > --- a/drivers/pwm/pwm-atmel.c
> > > +++ b/drivers/pwm/pwm-atmel.c
> > > @@ -415,17 +415,18 @@ static int atmel_pwm_probe(struct platform_device *pdev)
> > > res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > atmel_pwm->base = devm_ioremap_resource(&pdev->dev, res);
> > > if (IS_ERR(atmel_pwm->base))
> > > - return PTR_ERR(atmel_pwm->base);
> > > + return dev_err_probe(&pdev->dev, PTR_ERR(atmel_pwm->base),
> > > + "Failed to remap register space\n");
> >
> > This is a regression.
> >
> > devm_ioremap_resource() already emits and error message for !-ENOMEM.
> >
> > -ENOMEM cases should fail silently.
>
> ah right. Maybe dev_err_probe() should do this right, too?
Maybe, but you're still adding an unnecessary string to the kernel's
binary. There was a bit push a little while back to cut down on
these.
> > > atmel_pwm->clk = devm_clk_get(&pdev->dev, NULL);
> > > if (IS_ERR(atmel_pwm->clk))
> > > - return PTR_ERR(atmel_pwm->clk);
> > > + return dev_err_probe(&pdev->dev, PTR_ERR(atmel_pwm->clk),
> > > + "Failed to get clock\n");
> >
> > Isn't dev_err_probe() only useful for drivers handling -EPROBE_DEFER?
>
> devm_clk_get() might return -EPROBE_DEFER.
Perhaps, but the author has chosen not to handle it specifically.
It's my understanding that dev_err_probe() was designed to simplify
error handling in .probe() whereas this patch seems to do the polar
opposite.
> > > ret = clk_prepare(atmel_pwm->clk);
> > > - if (ret) {
> > > - dev_err(&pdev->dev, "failed to prepare PWM clock\n");
> > > - return ret;
> > > - }
> > > + if (ret)
> > > + return dev_err_probe(&pdev->dev, ret,
> > > + "Failed to prepare PWM clock\n");
> >
> > As above.
>
> I only checked quickly and didn't find an instance where clk_prepare can
> return -EPROBE_DEFER, but even if it doesn't it works fine.
It's still misleading IMHO. dev_err_probe()'s header details its
reason for existence. This seems to be a square peg in a round hole
scenario.
--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-08-12 8:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-12 8:02 [PATCH] pwm: atmel: Make use of dev_err_probe() Uwe Kleine-König
2020-08-12 8:20 ` Lee Jones
2020-08-12 8:32 ` Uwe Kleine-König
2020-08-12 8:47 ` Alexandre Belloni
2020-08-12 9:25 ` Uwe Kleine-König
2020-08-12 9:34 ` Alexandre Belloni
2020-08-12 9:36 ` Lee Jones
2020-08-12 8:47 ` Lee Jones [this message]
2020-08-12 9:40 ` Uwe Kleine-König
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=20200812084751.GE4354@dell \
--to=lee.jones@linaro.org \
--cc=alexandre.belloni@bootlin.com \
--cc=claudiu.beznea@microchip.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pwm@vger.kernel.org \
--cc=ludovic.desroches@microchip.com \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).