[PATCH v3 4/6] gpio: delay: fix offset propagation in gpio_delay_xlate()

Pranav Sanwal <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <[email protected]>
gpio_delay_xlate() indexed priv->descs[] correctly using
args->args[0], but never propagated that same index into
desc->offset. Since gpio_desc_init() initializes offset to 0 before
xlate() runs, every consumer's returned descriptor ended up with
offset 0 regardless of which index it actually requested.

On boards where gpio-delay wraps more than one real GPIO line, this
caused every consumer past the first to silently collide with the
first consumer's already-claimed offset 0 in dm_gpio_request(), which
returns -EBUSY. The second consumer's real GPIO line was therefore
never toggled.

Fix gpio_delay_xlate() to record the requested index into
desc->offset so each consumer's descriptor is routed to the correct
underlying real GPIO.

Fixes: c866f2f197e2 ("gpio: Add GPIO delay driver")
Signed-off-by: Pranav Sanwal <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
---
 drivers/gpio/gpio-delay.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpio/gpio-delay.c b/drivers/gpio/gpio-delay.c
index 533e7d2f8ef..f6c9c7efb0b 100644
--- a/drivers/gpio/gpio-delay.c
+++ b/drivers/gpio/gpio-delay.c
@@ -77,6 +77,8 @@ static int gpio_delay_xlate(struct udevice *dev, struct gpio_desc *desc,
 	if (args->args[0] >= uc_priv->gpio_count)
 		return -EINVAL;
 
+	desc->offset = args->args[0];
+
 	struct gpio_delay_desc *d = &priv->descs[args->args[0]];
 
 	d->ramp_up_us = args->args[1];
-- 
2.43.7
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.