From: Johan Hovold <johan@kernel.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: Re: [PATCH] gnss: Use devm_regulator_get_enable_optional()
Date: Tue, 20 Jun 2023 10:57:45 +0200 [thread overview]
Message-ID: <ZJFqCQ8bbBoX3l1g@hovoldconsulting.com> (raw)
In-Reply-To: <62effa7aa1a2023a77709e6416c57d9cb79a5ccc.1686995765.git.christophe.jaillet@wanadoo.fr>
On Sat, Jun 17, 2023 at 11:57:09AM +0200, Christophe JAILLET wrote:
> Use devm_regulator_get_enable_optional() instead of hand writing it. It
> saves some line of code.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Note that regulator_disable() is now called after gnss_serial_free() in
> the error handling path of the probe and in the remove function, but it
> looks harmless to me.
Yeah, that bit should be fine.
> ---
> drivers/gnss/mtk.c | 26 ++++----------------------
> 1 file changed, 4 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gnss/mtk.c b/drivers/gnss/mtk.c
> index c62b1211f4fe..d3d31295d4e0 100644
> --- a/drivers/gnss/mtk.c
> +++ b/drivers/gnss/mtk.c
> @@ -17,7 +17,6 @@
> #include "serial.h"
>
> struct mtk_data {
> - struct regulator *vbackup;
> struct regulator *vcc;
> };
>
> @@ -87,30 +86,16 @@ static int mtk_probe(struct serdev_device *serdev)
> goto err_free_gserial;
> }
>
> - data->vbackup = devm_regulator_get_optional(&serdev->dev, "vbackup");
> - if (IS_ERR(data->vbackup)) {
> - ret = PTR_ERR(data->vbackup);
> - if (ret == -ENODEV)
> - data->vbackup = NULL;
> - else
> - goto err_free_gserial;
> - }
> -
> - if (data->vbackup) {
> - ret = regulator_enable(data->vbackup);
> - if (ret)
> - goto err_free_gserial;
> - }
> + ret = devm_regulator_get_enable_optional(&serdev->dev, "vbackup");
> + if (ret)
> + goto err_free_gserial;
But this breaks the driver as the new helper still returns -ENODEV when
the optional is resource is not present.
Wolfram already suggested using this new helper here:
https://lore.kernel.org/lkml/20230523064310.3005-3-wsa+renesas@sang-engineering.com
and also got the error handling right even if that patch will require a
respin for other reasons.
As I mentioned in my reply to Wolfram, I'm generally sceptical of
helpers like this one, but in this case where there are no dependencies
on other resources I guess it's ok.
Johan
next prev parent reply other threads:[~2023-06-20 8:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-17 9:57 Christophe JAILLET
2023-06-19 10:20 ` AngeloGioacchino Del Regno
2023-06-20 8:57 ` Johan Hovold [this message]
2023-06-20 17:16 ` Christophe JAILLET
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=ZJFqCQ8bbBoX3l1g@hovoldconsulting.com \
--to=johan@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=broonie@kernel.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@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®