1
0
Fork 0

gpio: altera: 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 chained irqchips this is a pretty straight-forward
conversion.

Cc: Ley Foon Tan <lftan@altera.com>
Cc: Tien Hock Loh <thloh@altera.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
alistair/sunxi64-5.4-dsi
Linus Walleij 2019-06-25 13:35:32 +02:00
parent 8b29450437
commit 2617790f0f
1 changed files with 24 additions and 30 deletions

View File

@ -238,6 +238,7 @@ static int altera_gpio_probe(struct platform_device *pdev)
struct device_node *node = pdev->dev.of_node; struct device_node *node = pdev->dev.of_node;
int reg, ret; int reg, ret;
struct altera_gpio_chip *altera_gc; struct altera_gpio_chip *altera_gc;
struct gpio_irq_chip *girq;
altera_gc = devm_kzalloc(&pdev->dev, sizeof(*altera_gc), GFP_KERNEL); altera_gc = devm_kzalloc(&pdev->dev, sizeof(*altera_gc), GFP_KERNEL);
if (!altera_gc) if (!altera_gc)
@ -265,24 +266,15 @@ static int altera_gpio_probe(struct platform_device *pdev)
altera_gc->mmchip.gc.owner = THIS_MODULE; altera_gc->mmchip.gc.owner = THIS_MODULE;
altera_gc->mmchip.gc.parent = &pdev->dev; altera_gc->mmchip.gc.parent = &pdev->dev;
ret = of_mm_gpiochip_add_data(node, &altera_gc->mmchip, altera_gc);
if (ret) {
dev_err(&pdev->dev, "Failed adding memory mapped gpiochip\n");
return ret;
}
platform_set_drvdata(pdev, altera_gc);
altera_gc->mapped_irq = platform_get_irq(pdev, 0); altera_gc->mapped_irq = platform_get_irq(pdev, 0);
if (altera_gc->mapped_irq < 0) if (altera_gc->mapped_irq < 0)
goto skip_irq; goto skip_irq;
if (of_property_read_u32(node, "altr,interrupt-type", &reg)) { if (of_property_read_u32(node, "altr,interrupt-type", &reg)) {
ret = -EINVAL;
dev_err(&pdev->dev, dev_err(&pdev->dev,
"altr,interrupt-type value not set in device tree\n"); "altr,interrupt-type value not set in device tree\n");
goto teardown; return -EINVAL;
} }
altera_gc->interrupt_trigger = reg; altera_gc->interrupt_trigger = reg;
@ -293,29 +285,31 @@ static int altera_gpio_probe(struct platform_device *pdev)
altera_gc->irq_chip.irq_startup = altera_gpio_irq_startup; altera_gc->irq_chip.irq_startup = altera_gpio_irq_startup;
altera_gc->irq_chip.irq_shutdown = altera_gpio_irq_mask; altera_gc->irq_chip.irq_shutdown = altera_gpio_irq_mask;
ret = gpiochip_irqchip_add(&altera_gc->mmchip.gc, &altera_gc->irq_chip, girq = &altera_gc->mmchip.gc.irq;
0, handle_bad_irq, IRQ_TYPE_NONE); girq->chip = &altera_gc->irq_chip;
if (altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH)
if (ret) { girq->parent_handler = altera_gpio_irq_leveL_high_handler;
dev_err(&pdev->dev, "could not add irqchip\n"); else
goto teardown; girq->parent_handler = altera_gpio_irq_edge_handler;
} girq->num_parents = 1;
girq->parents = devm_kcalloc(&pdev->dev, 1, sizeof(*girq->parents),
gpiochip_set_chained_irqchip(&altera_gc->mmchip.gc, GFP_KERNEL);
&altera_gc->irq_chip, if (!girq->parents)
altera_gc->mapped_irq, return -ENOMEM;
altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH ? girq->default_type = IRQ_TYPE_NONE;
altera_gpio_irq_leveL_high_handler : girq->handler = handle_bad_irq;
altera_gpio_irq_edge_handler); girq->parents[0] = altera_gc->mapped_irq;
skip_irq: skip_irq:
return 0; ret = of_mm_gpiochip_add_data(node, &altera_gc->mmchip, altera_gc);
teardown: if (ret) {
of_mm_gpiochip_remove(&altera_gc->mmchip); dev_err(&pdev->dev, "Failed adding memory mapped gpiochip\n");
pr_err("%pOF: registration failed with status %d\n", return ret;
node, ret); }
return ret; platform_set_drvdata(pdev, altera_gc);
return 0;
} }
static int altera_gpio_remove(struct platform_device *pdev) static int altera_gpio_remove(struct platform_device *pdev)