Skip to content

Commit 2de1cf1

Browse files
author
Bartosz Golaszewski
committed
gpio: TODO: track the removal of regulator-related workarounds
The GPIOD_FLAGS_BIT_NONEXCLUSIVE flag and devm_gpiod_unhinge() function should be replaced with a better solution. The pwrseq subsystem is a good candidate. GPIOs themselves should remain a unique resource. Add a task for tracking the removal of these deprecated symbols. Acked-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20250401-gpio-todo-remove-nonexclusive-v2-4-7c1380797b0d@linaro.org Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent 3af64f1 commit 2de1cf1

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

drivers/gpio/TODO

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,37 @@ their hardware offsets within the chip.
186186

187187
Encourage users to switch to using them and eventually remove the existing
188188
global export/unexport attribues.
189+
190+
-------------------------------------------------------------------------------
191+
192+
Remove GPIOD_FLAGS_BIT_NONEXCLUSIVE
193+
194+
GPIOs in the linux kernel are meant to be an exclusive resource. This means
195+
that the GPIO descriptors (the software representation of the hardware concept)
196+
are not reference counted and - in general - only one user at a time can
197+
request a GPIO line and control its settings. The consumer API is designed
198+
around full control of the line's state as evidenced by the fact that, for
199+
instance, gpiod_set_value() does indeed drive the line as requested, instead
200+
of bumping an enable counter of some sort.
201+
202+
A problematic use-case for GPIOs is when two consumers want to use the same
203+
descriptor independently. An example of such a user is the regulator subsystem
204+
which may instantiate several struct regulator_dev instances containing
205+
a struct device but using the same enable GPIO line.
206+
207+
A workaround was introduced in the form of the GPIOD_FLAGS_BIT_NONEXCLUSIVE
208+
flag but its implementation is problematic: it does not provide any
209+
synchronization of usage nor did it introduce any enable count meaning the
210+
non-exclusive users of the same descriptor will in fact "fight" for the
211+
control over it. This flag should be removed and replaced with a better
212+
solution, possibly based on the new power sequencing subsystem.
213+
214+
-------------------------------------------------------------------------------
215+
216+
Remove devm_gpiod_unhinge()
217+
218+
devm_gpiod_unhinge() is provided as a way to transfer the ownership of managed
219+
enable GPIOs to the regulator core. Rather than doing that however, we should
220+
make it possible for the regulator subsystem to deal with GPIO resources the
221+
lifetime of which it doesn't control as logically, a GPIO obtained by a caller
222+
should also be freed by it.

0 commit comments

Comments
 (0)