All of lore.kernel.org
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, <linux-kernel@vger.kernel.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>
Subject: Re: [PATCH 06/13 v2] regulator: max8973: Let core handle GPIO descriptor
Date: Wed, 5 Dec 2018 13:08:26 +0000	[thread overview]
Message-ID: <20181205130826.GD16508@imbe.wolfsonmicro.main> (raw)
In-Reply-To: <20181201154151.14890-7-linus.walleij@linaro.org>

On Sat, Dec 01, 2018 at 04:41:44PM +0100, Linus Walleij wrote:
> Use the gpiod_get() rather than the devm_* version so that the
> regulator core can handle the lifecycle of these descriptors.
> 
> Fixes: e7d2be696faa ("regulator: max8973: Pass descriptor instead of GPIO number")
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v1->v2:
> - Drop the gpiod_put() on the errorpath after devm_regulator_register()
>   as this will be handled by the regulator core.
> - Fix the second case of devm_gpiod_get()
> - Put a comment in the code so maintainers knows not to
>   use managed resources (devm*)
> ---
> @@ -759,9 +759,13 @@ static int max8973_probe(struct i2c_client *client,
>  		else
>  			gflags = GPIOD_OUT_LOW;
>  		gflags |= GPIOD_FLAGS_BIT_NONEXCLUSIVE;
> -		gpiod = devm_gpiod_get_optional(&client->dev,
> -						"maxim,enable",
> -						gflags);
> +		/*
> +		 * Do not use devm* here: the regulator core takes over the
> +		 * lifecycle management of the GPIO descriptor.
> +		 */
> +		gpiod = gpiod_get_optional(&client->dev,
> +					   "maxim,enable",
> +					   gflags);
>  		if (IS_ERR(gpiod))
>  			return PTR_ERR(gpiod);
>  		if (gpiod) {
> @@ -775,10 +779,13 @@ static int max8973_probe(struct i2c_client *client,
>  		/*
>  		 * We do not let the core switch this regulator on/off,
>  		 * we just leave it on.
> +		 *
> +		 * Do not use devm* here: the regulator core takes over the
> +		 * lifecycle management of the GPIO descriptor.
>  		 */
> -		gpiod = devm_gpiod_get_optional(&client->dev,
> -						"maxim,enable",
> -						GPIOD_OUT_HIGH);
> +		gpiod = gpiod_get_optional(&client->dev,
> +					   "maxim,enable",
> +					   GPIOD_OUT_HIGH);

Need to be careful here this path actually never passes the GPIO
to the regulator core. I suspect you want to leave this one as a
devm_

>  		if (IS_ERR(gpiod))
>  			return PTR_ERR(gpiod);
>  		if (gpiod)
> @@ -798,6 +805,8 @@ static int max8973_probe(struct i2c_client *client,
>  
>  	ret = max8973_init_dcdc(max, pdata);
>  	if (ret < 0) {
> +		if (gpiod)
> +			gpiod_put(gpiod);

And make this use config.ena_gpiod instead.

Thanks,
Charles

  reply	other threads:[~2018-12-05 13:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20181201154428epcas4p3a1a5c9c576027b1c56f8dd1510b32187@epcas4p3.samsung.com>
2018-12-01 15:41 ` [PATCH 00/13 v2] Regulator ena_gpiod fixups Linus Walleij
2018-12-01 15:41   ` [PATCH 01/13 v2] regulator: core: Track dangling GPIO descriptors Linus Walleij
2018-12-01 15:41   ` [PATCH 02/13 v2] regulator: fixed: Let core handle GPIO descriptor Linus Walleij
2018-12-01 15:41   ` [PATCH 03/13 v2] regulator: lm363x: " Linus Walleij
2018-12-01 15:41   ` [PATCH 04/13 v2] regulator: lp8788-ldo: " Linus Walleij
2018-12-01 15:41   ` [PATCH 05/13 v2] regulator: max8952: " Linus Walleij
2018-12-01 15:41   ` [PATCH 06/13 v2] regulator: max8973: " Linus Walleij
2018-12-05 13:08     ` Charles Keepax [this message]
2018-12-01 15:41   ` [PATCH 07/13 v2] gpio: Export gpiod_get_from_of_node() Linus Walleij
2018-12-01 15:41   ` [PATCH 08/13 v2] regulator: max77686: Let core handle GPIO descriptor Linus Walleij
2018-12-01 15:41   ` [PATCH 09/13 v2] gpio: Add devm_gpiod_unhinge() Linus Walleij
2018-12-02 17:02     ` Bartosz Golaszewski
2018-12-01 15:41   ` [PATCH 10/13 v2] regulator: da9211: Hand over GPIO to regulator core Linus Walleij
2018-12-01 15:41   ` [PATCH 11/13 v2] regulator: s5m8767: " Linus Walleij
2018-12-01 15:41   ` [PATCH 12/13 v2] regulator: tps65090: " Linus Walleij
2018-12-01 15:41   ` [PATCH 13/13 v2] regulator: s2mps11: " Linus Walleij
2018-12-03 14:35   ` [PATCH 00/13 v2] Regulator ena_gpiod fixups Marek Szyprowski
2018-12-04  9:31     ` Linus Walleij
2018-12-04 10:33       ` Marek Szyprowski
2018-12-04 12:44         ` Linus Walleij
2018-12-05 14:30           ` Marek Szyprowski
2018-12-05 14:32             ` Linus Walleij

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=20181205130826.GD16508@imbe.wolfsonmicro.main \
    --to=ckeepax@opensource.cirrus.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.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 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.