Commit 834e1678 authored by Pramod Gurav's avatar Pramod Gurav Committed by Linus Walleij

pinctrl: at91: Fix error handling while doing gpiochio_irqchip_add

This patch removes a call to panic function when gpiochio_irqchip_add
fails and just returns the error to the calling function.
Same return value is used to handle the error case and adds a lable
to release resources on error.
The error message has been improved to indicate failure to add irqchip
to gpiochip.

This also changes first argument to function at91_gpio_of_irq_setup from
struct device_node to struct platform_device. Because The device_node
argument was anyway not being used. Passed pdev so that on failure dev_err
can use &pdev->dev and log can be associated with proper device.

CC: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
CC: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarPramod Gurav <pramod.gurav@smartplayin.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 70e41974
...@@ -1605,7 +1605,7 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc) ...@@ -1605,7 +1605,7 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
/* now it may re-trigger */ /* now it may re-trigger */
} }
static int at91_gpio_of_irq_setup(struct device_node *node, static int at91_gpio_of_irq_setup(struct platform_device *pdev,
struct at91_gpio_chip *at91_gpio) struct at91_gpio_chip *at91_gpio)
{ {
struct at91_gpio_chip *prev = NULL; struct at91_gpio_chip *prev = NULL;
...@@ -1630,9 +1630,11 @@ static int at91_gpio_of_irq_setup(struct device_node *node, ...@@ -1630,9 +1630,11 @@ static int at91_gpio_of_irq_setup(struct device_node *node,
0, 0,
handle_edge_irq, handle_edge_irq,
IRQ_TYPE_EDGE_BOTH); IRQ_TYPE_EDGE_BOTH);
if (ret) if (ret) {
panic("at91_gpio.%d: couldn't allocate irq domain (DT).\n", dev_err(&pdev->dev, "at91_gpio.%d: Couldn't add irqchip to gpiochip.\n",
at91_gpio->pioc_idx); at91_gpio->pioc_idx);
return ret;
}
/* Setup chained handler */ /* Setup chained handler */
if (at91_gpio->pioc_idx) if (at91_gpio->pioc_idx)
...@@ -1800,12 +1802,16 @@ static int at91_gpio_probe(struct platform_device *pdev) ...@@ -1800,12 +1802,16 @@ static int at91_gpio_probe(struct platform_device *pdev)
at91_gpio_probe_fixup(); at91_gpio_probe_fixup();
at91_gpio_of_irq_setup(np, at91_chip); ret = at91_gpio_of_irq_setup(pdev, at91_chip);
if (ret)
goto irq_setup_err;
dev_info(&pdev->dev, "at address %p\n", at91_chip->regbase); dev_info(&pdev->dev, "at address %p\n", at91_chip->regbase);
return 0; return 0;
irq_setup_err:
gpiochip_remove(chip);
gpiochip_add_err: gpiochip_add_err:
clk_disable(at91_chip->clock); clk_disable(at91_chip->clock);
clk_enable_err: clk_enable_err:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment