This series improves diagnosability of GPIO offset collisions and fixes
three related bugs in the gpio-delay driver that were uncovered while
debugging such a collision.
Patch 1 logs, at dev_dbg() level, which label already holds a GPIO
offset when a new request collides with it, from within
dm_gpio_request() itself, so a collision can be root-caused from the
uclass layer when actively debugging.
Patch 2 adds the same diagnostic to the "gpio" command, at printf()
level. -EBUSY from gpio_request() is a normal, expected result there (a
pin already owned by a driver or hog), so the command already tolerates
it silently; this patch only prints which label holds the pin on that
already-tolerated path.
Patch 3 fixes gpio_delay_probe()/gpio_delay_xlate() to size and
validate against the driver's actual GPIO count (from its "gpios"
property) instead of a hardcoded 32, correctly sizing the claimed/name
tracking arrays and matching the pattern used by the generic uclass
xlate implementation.
Patch 4 fixes gpio_delay_xlate() to propagate the requested index into
desc->offset. Previously every consumer's descriptor came back with
offset 0 regardless of which index was requested, so on boards where
gpio-delay wraps more than one real GPIO line, every consumer past the
first silently collided with the first consumer's already-claimed
offset 0 and was never toggled. This was the root cause behind the
series; the other patches are diagnostic and robustness fixes found
along the way.
Patch 5 adds a .remove hook to gpio-delay to release the real GPIOs it
wraps. The driver requests them via gpio_request_by_name_nodev(), which
strdup()s a label into the wrapped device's own uc_priv->name[]; with
no .remove, those requests and labels were never released on teardown.
Patches 3-5 are tagged Fixes: c866f2f197e2 ("gpio: Add GPIO delay
driver").
Changes in v2:
- Patch 1: downgraded from dev_warn() to dev_dbg(), since -EBUSY is a
normal/expected result for some callers (e.g. cmd/gpio.c, and sandbox
tests that deliberately exercise this path), and warning there fired
on legitimate operations, not just misconfiguration (Simon)
- New patch 2: moved the user-facing diagnostic into the "gpio" command
instead, where -EBUSY is already known to be expected (Simon)
- New patch 5: additional related fix found while further exercising
the driver
Pranav Sanwal (5):
gpio: uclass: log when a gpio offset is already claimed
gpio: cmd: warn when a gpio offset is already claimed
gpio: delay: set gpio_count and validate index against it
gpio: delay: fix offset propagation in gpio_delay_xlate()
gpio: delay: free wrapped real GPIOs on remove
cmd/gpio.c | 11 +++++++++--
drivers/gpio/gpio-delay.c | 23 ++++++++++++++++++++++-
drivers/gpio/gpio-uclass.c | 5 ++++-
3 files changed, 35 insertions(+), 4 deletions(-)
--
2.43.7