Commit f6a7053d authored by Linus Walleij's avatar Linus Walleij

gpio: zynq: Pass irqchip when adding gpiochip

We need to convert all old gpio irqchips to pass the irqchip
setup along when adding the gpio_chip. For more info see
drivers/gpio/TODO.

For chained irqchips this is a pretty straight-forward
conversion.

Cc: Michal Simek <michal.simek@xilinx.com>
Cc: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Cc: Thierry Reding <treding@nvidia.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20190809132649.25176-1-linus.walleij@linaro.org
parent f4e9bcc0
...@@ -830,6 +830,7 @@ static int zynq_gpio_probe(struct platform_device *pdev) ...@@ -830,6 +830,7 @@ static int zynq_gpio_probe(struct platform_device *pdev)
int ret, bank_num; int ret, bank_num;
struct zynq_gpio *gpio; struct zynq_gpio *gpio;
struct gpio_chip *chip; struct gpio_chip *chip;
struct gpio_irq_chip *girq;
const struct of_device_id *match; const struct of_device_id *match;
gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
...@@ -885,34 +886,38 @@ static int zynq_gpio_probe(struct platform_device *pdev) ...@@ -885,34 +886,38 @@ static int zynq_gpio_probe(struct platform_device *pdev)
if (ret < 0) if (ret < 0)
goto err_pm_dis; goto err_pm_dis;
/* report a bug if gpio chip registration fails */
ret = gpiochip_add_data(chip, gpio);
if (ret) {
dev_err(&pdev->dev, "Failed to add gpio chip\n");
goto err_pm_put;
}
/* disable interrupts for all banks */ /* disable interrupts for all banks */
for (bank_num = 0; bank_num < gpio->p_data->max_bank; bank_num++) for (bank_num = 0; bank_num < gpio->p_data->max_bank; bank_num++)
writel_relaxed(ZYNQ_GPIO_IXR_DISABLE_ALL, gpio->base_addr + writel_relaxed(ZYNQ_GPIO_IXR_DISABLE_ALL, gpio->base_addr +
ZYNQ_GPIO_INTDIS_OFFSET(bank_num)); ZYNQ_GPIO_INTDIS_OFFSET(bank_num));
ret = gpiochip_irqchip_add(chip, &zynq_gpio_edge_irqchip, 0, /* Set up the GPIO irqchip */
handle_level_irq, IRQ_TYPE_NONE); girq = &chip->irq;
if (ret) { girq->chip = &zynq_gpio_edge_irqchip;
dev_err(&pdev->dev, "Failed to add irq chip\n"); girq->parent_handler = zynq_gpio_irqhandler;
goto err_rm_gpiochip; girq->num_parents = 1;
girq->parents = devm_kcalloc(&pdev->dev, 1,
sizeof(*girq->parents),
GFP_KERNEL);
if (!girq->parents) {
ret = -ENOMEM;
goto err_pm_put;
} }
girq->parents[0] = gpio->irq;
girq->default_type = IRQ_TYPE_NONE;
girq->handler = handle_level_irq;
gpiochip_set_chained_irqchip(chip, &zynq_gpio_edge_irqchip, gpio->irq, /* report a bug if gpio chip registration fails */
zynq_gpio_irqhandler); ret = gpiochip_add_data(chip, gpio);
if (ret) {
dev_err(&pdev->dev, "Failed to add gpio chip\n");
goto err_pm_put;
}
pm_runtime_put(&pdev->dev); pm_runtime_put(&pdev->dev);
return 0; return 0;
err_rm_gpiochip:
gpiochip_remove(chip);
err_pm_put: err_pm_put:
pm_runtime_put(&pdev->dev); pm_runtime_put(&pdev->dev);
err_pm_dis: err_pm_dis:
......
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