Re: [PATCH v2] regulator: wm8994: Don't use devres for enable GPIOs

From: Linus Walleij
Date: Thu Nov 22 2018 - 10:47:36 EST


On Thu, Nov 22, 2018 at 3:19 PM Linus Walleij <linus.walleij@xxxxxxxxxx> wrote:
> On Wed, Nov 21, 2018 at 11:13 AM Charles Keepax
> <ckeepax@xxxxxxxxxxxxxxxxxxxxx> wrote:
>
> > The regulator core takes over managing the lifetime of the enable GPIO
> > once the regulator is registered. As such we shouldn't register the
> > enable GPIO using devm, or it will be freed twice.
> >
> > Reported-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
> > Signed-off-by: Charles Keepax <ckeepax@xxxxxxxxxxxxxxxxxxxxx>
>
> Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>

Oh no this is not the right solution I think.

All drivers passing a descriptor (config->ena_gpiod) do their
own refcounting, including some using a function that has no
non-devm* counterpart.

It is better if we teach the core to not gpiod_put() those.

The other patch series I am floating to get rid of the legacy
GPIO handling from the core will do away with all the
legacy GPIO handling anyway, so let me introduce a bit
of ugliness (that can be backported) and then delete that
ugliness with an updated series v8 of my legacy GPIO
cleanup.

Sorry for the inconvenience.

Will send a patch soon.

Yours,
Linus Walleij