[PATCH v2 2/6] gpio: Return -EPROBE_DEFER on gpio_get_num()

Sebastian Hesselbarth sebastian.hesselbarth at gmail.com
Tue Apr 14 15:53:16 PDT 2015


GPIO drivers can be registered quite late in registration process
causing dependant devices to fail probing. If we know gpio_get_num
will be called with a non-NULL device, return -EPROBE_DEFER instead
of -ENODEV to allow re-probing later.

Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth at gmail.com>
---
Changelog:
v1->v2:
- none

Cc: barebox at lists.infradead.org
---
 drivers/gpio/gpiolib.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 611e41ea5606..1f57c76ec16d 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -292,12 +292,15 @@ int gpio_get_num(struct device_d *dev, int gpio)
 {
 	struct gpio_chip *chip;
 
+	if (!dev)
+		return -ENODEV;
+
 	list_for_each_entry(chip, &chip_list, list) {
 		if (chip->dev == dev)
 			return chip->base + gpio;
 	}
 
-	return -ENODEV;
+	return -EPROBE_DEFER;
 }
 
 #ifdef CONFIG_CMD_GPIO
-- 
2.1.0




More information about the barebox mailing list