Re: [PATCH 3/3] gpio: Add reference counting for non-exclusive GPIOs

From: Linus Walleij
Date: Fri Nov 23 2018 - 04:41:13 EST


On Thu, Nov 22, 2018 at 6:30 PM Charles Keepax
<ckeepax@xxxxxxxxxxxxxxxxxxxxx> wrote:

> Currently, a GPIO can be requested multiple times when the
> NONEXCLUSIVE flag is set, however it must still be freed a single
> time. This makes client code rather complex, since multiple drivers
> may request the GPIO but only a single one can free it. Rather than
> manually handling this in each driver add some basic reference
> counting into the core. Currently, this is fairly primitive but
> so is the support for the NONEXCLUSIVE flag and the implementation
> covers those use-cases.
>
> Reported-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
> Signed-off-by: Charles Keepax <ckeepax@xxxxxxxxxxxxxxxxxxxxx>

This patch is not fixing anything right now, correct?

I discussed the notion of pulling reference counting for
nonexclusive GPIOs into gpiolib with Mark but the benefit is
a bit unclear: if the subsystem using nonexeclusive GPIOs
(currently only regulators) would still have to keep its own
reference count or somehow semantically know when
the last user is gone, the point is kind of moot.

I haven't looked closely at the regulators case but I got
the impression that it is more complex than just reference
counting so, currently I don't know if this is such a good
idea.

Anyway I would like to push this until we have cleaned
up with the rest of the series I have boiling, if you don't
mind.

(Patch 1+2 should be fine anyway.)

Yours,
Linus Walleij