[PATCH] pinctrl: at91: retrieve device id in non dtb probe

Raphaël Poggi poggi.raph at gmail.com
Mon Sep 8 06:07:57 PDT 2014


We need to retrieve the device id in device tree/non device tree case.

Signed-off-by: Raphaël Poggi <poggi.raph at gmail.com>
---
 drivers/pinctrl/pinctrl-at91.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 3dc81c7..d3423d0 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -618,9 +618,14 @@ static int at91_gpio_probe(struct device_d *dev)
 	struct at91_gpio_chip *at91_gpio;
 	struct clk *clk;
 	int ret;
-	int alias_idx = of_alias_get_id(dev->device_node, "gpio");
+	int alias_idx;
 
-	BUG_ON(dev->id > MAX_GPIO_BANKS);
+	if (dev->device_node)
+		alias_idx = of_alias_get_id(dev->device_node, "gpio");
+	else
+		alias_idx = dev->id;
+
+	BUG_ON(alias_idx > MAX_GPIO_BANKS);
 
 	at91_gpio = &gpio_chip[alias_idx];
 
@@ -646,7 +651,7 @@ static int at91_gpio_probe(struct device_d *dev)
 	at91_gpio->chip.ops = &at91_gpio_ops;
 	at91_gpio->chip.ngpio = MAX_NB_GPIO_PER_BANK;
 	at91_gpio->chip.dev = dev;
-	at91_gpio->chip.base = dev->id * MAX_NB_GPIO_PER_BANK;
+	at91_gpio->chip.base = alias_idx * MAX_NB_GPIO_PER_BANK;
 
 	ret = gpiochip_add(&at91_gpio->chip);
 	if (ret) {
-- 
2.1.0




More information about the barebox mailing list