From: Guenter Roeck <linux@roeck-us.net>
To: Matti Vaittinen <mazziesaccount@gmail.com>,
Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
linux-kernel@vger.kernel.org, Aleksander Mazur <deweloper@wp.pl>
Subject: Re: [PATCH] regulator: change stubbed devm_regulator_get_enable to return Ok
Date: Mon, 22 Apr 2024 06:23:40 -0700 [thread overview]
Message-ID: <18d4811a-7c92-4bd7-b44f-aacf3c1f2f65@roeck-us.net> (raw)
In-Reply-To: <ZiYF6d1V1vSPcsJS@drtxq0yyyyyyyyyyyyyby-3.rev.dnainternet.fi>
On 4/21/24 23:38, Matti Vaittinen wrote:
> The devm_regulator_get_enable() should be a 'call and forget' API,
> meaning, when it is used to enable the regulators, the API does not
> provide a handle to do any further control of the regulators. It gives
> no real benefit to return an error from the stub if CONFIG_REGULATOR is
> not set.
>
> On the contrary, returning and error is causing problems to drivers when
> hardware is such it works out just fine with no regulator control.
> Returning an error forces drivers to specifically handle the case where
> CONFIG_REGULATOR is not set, making the mere existence of the stub
> questionalble. Furthermore, the stub of the regulator_enable() seems to
> be returning Ok.
>
Yes, that was the reason why the lm90 driver worked pripr to its conversion
to use devm_regulator_get_enable() if CONFIG_REGULATOR=n.
> Change the stub implementation for the devm_regulator_get_enable() to
> return Ok so drivers do not separately handle the case where the
> CONFIG_REGULATOR is not set.
>
> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
> Reported-by: Aleksander Mazur <deweloper@wp.pl>
> Suggested-by: Guenter Roeck <linux@roeck-us.net>
> Fixes: da279e6965b3 ("regulator: Add devm helpers for get and enable")
>
> ---
> Please find the report by Aleksander from:
> https://lore.kernel.org/all/20240420183427.0d3fda27@mocarz/
>
> This patch has not received testing. It'd be great to hear if this
> solves the issue.
>
> I see the regulator_get_exclusive() and devm_regulator_get_optional()
> returning errors. I thus leave the
> devm_regulator_get_enable_[optional/exclusive]() to do the same while
> wondering if this is the right thing to do, and why...
>
At least one of the callers of devm_regulator_get_enable (exc3000) checks for
-ENODEV and ignores it. I assume we'll see more of those unless this patch
is accepted. Many of the callers of devm_regulator_get_enable_optional()
explicitly check for -ENODEV and ignore it. Others fail if CONFIG_REGULATOR=n.
My plan for affected hwmon drivers is (was ?) to check for -ENODEV and ignore
it to match other drivers.
Returning ERR_PTR(-ENODEV) for [devm_]regulator_get() made sense because
the returned regulator pointer was often used to obtain a voltage or to
do other regulator operations. I don't really see the point of returning
-ENODEV for the _enable APIs if regulator support is disabled.
Anyway, for this patch:
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Thanks,
Guenter
next prev parent reply other threads:[~2024-04-22 13:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-22 6:38 Matti Vaittinen
2024-04-22 13:23 ` Guenter Roeck [this message]
2024-04-23 5:11 ` Matti Vaittinen
2024-04-23 5:34 ` Mark Brown
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=18d4811a-7c92-4bd7-b44f-aacf3c1f2f65@roeck-us.net \
--to=linux@roeck-us.net \
--cc=broonie@kernel.org \
--cc=deweloper@wp.pl \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=mazziesaccount@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®