From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <ahmad@a3f.at>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2] regulator: fixed: remove duplicate always-on handling
Date: Mon, 11 Jul 2022 11:35:46 +0200 [thread overview]
Message-ID: <20220711093545.GO5208@pengutronix.de> (raw)
In-Reply-To: <20220708061539.1193059-1-ahmad@a3f.at>
On Fri, Jul 08, 2022 at 08:15:40AM +0200, Ahmad Fatoum wrote:
> Regulator core already handles always-on property by enabling always-on
> regulators at registration time, so we can remove duplicate handling in
> the fixed-regulator driver. To avoid regressions due to previously
> unnoticed unbalanced regulator usage, maintain a positive use count
> always like Linux does and additionally warn on violation attempt.
>
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---
> v1 -> v2:
> - prevent use count dipping below 1 due to unbalanced use.
> This should avoid regressions and still warn us if they occur
> ---
> drivers/regulator/core.c | 9 +++++++--
> drivers/regulator/fixed.c | 10 ----------
> 2 files changed, 7 insertions(+), 12 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index af8a0cb4fc3e..1fb344656f38 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -66,6 +66,7 @@ static int regulator_enable_internal(struct regulator_internal *ri)
>
> static int regulator_disable_internal(struct regulator_internal *ri)
> {
> + struct regulator_dev *rdev = ri->rdev;
> int ret;
>
> if (!ri->enable_count)
> @@ -76,10 +77,14 @@ static int regulator_disable_internal(struct regulator_internal *ri)
> return 0;
> }
>
> - if (!ri->rdev->desc->ops->disable)
> + /* Crisis averted, be loud about the unbalanced regulator use */
> + if (WARN_ON(rdev->always_on))
> + return -EPERM;
> +
> + if (!rdev->desc->ops->disable)
> return -ENOSYS;
>
> - ret = ri->rdev->desc->ops->disable(ri->rdev);
> + ret = rdev->desc->ops->disable(rdev);
> if (ret)
> return ret;
>
> diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
> index c5f97d78df40..ec64f39b86c7 100644
> --- a/drivers/regulator/fixed.c
> +++ b/drivers/regulator/fixed.c
> @@ -15,7 +15,6 @@
>
> struct regulator_fixed {
> int gpio;
> - int always_on;
> struct regulator_dev rdev;
> struct regulator_desc rdesc;
> };
> @@ -34,9 +33,6 @@ static int regulator_fixed_disable(struct regulator_dev *rdev)
> {
> struct regulator_fixed *fix = container_of(rdev, struct regulator_fixed, rdev);
>
> - if (fix->always_on)
> - return 0;
> -
> if (!gpio_is_valid(fix->gpio))
> return 0;
>
> @@ -76,12 +72,6 @@ static int regulator_fixed_probe(struct device_d *dev)
> if (!of_property_read_u32(np, "off-on-delay-us", &delay))
> fix->rdesc.off_on_delay = delay;
>
> - if (of_find_property(np, "regulator-always-on", NULL) ||
> - of_find_property(np, "regulator-boot-on", NULL)) {
> - fix->always_on = 1;
> - regulator_fixed_enable(&fix->rdev);
> - }
> -
> ret = of_regulator_register(&fix->rdev, np);
> if (ret)
> goto err;
> --
> 2.34.1
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2022-07-11 9:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-08 6:15 [PATCH v2] regulator: fixed: remove duplicate always-on handling Ahmad Fatoum
2022-07-11 9:35 ` Sascha Hauer [this message]
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=20220711093545.GO5208@pengutronix.de \
--to=sha@pengutronix.de \
--cc=ahmad@a3f.at \
--cc=barebox@lists.infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.