pinctrl: stmfx: Use irqchip template
This makes the driver use the irqchip template to assign properties to the gpio_irq_chip instead of using the explicit calls to gpiochip_irqchip_add_nested() and gpiochip_set_nested_irqchip(). The irqchip is instead added while adding the gpiochip. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Cc: Amelie Delaunay <amelie.delaunay@st.com> Cc: Benjamin Gaignard <benjamin.gaignard@st.com> Link: https://lore.kernel.org/r/20200721131814.357182-1-linus.walleij@linaro.org
This commit is contained in:
parent
e81376ebba
commit
1de39b64bf
|
@ -616,6 +616,7 @@ static int stmfx_pinctrl_probe(struct platform_device *pdev)
|
|||
struct stmfx *stmfx = dev_get_drvdata(pdev->dev.parent);
|
||||
struct device_node *np = pdev->dev.of_node;
|
||||
struct stmfx_pinctrl *pctl;
|
||||
struct gpio_irq_chip *girq;
|
||||
int irq, ret;
|
||||
|
||||
pctl = devm_kzalloc(stmfx->dev, sizeof(*pctl), GFP_KERNEL);
|
||||
|
@ -674,6 +675,25 @@ static int stmfx_pinctrl_probe(struct platform_device *pdev)
|
|||
pctl->gpio_chip.can_sleep = true;
|
||||
pctl->gpio_chip.of_node = np;
|
||||
|
||||
pctl->irq_chip.name = dev_name(pctl->dev);
|
||||
pctl->irq_chip.irq_mask = stmfx_pinctrl_irq_mask;
|
||||
pctl->irq_chip.irq_unmask = stmfx_pinctrl_irq_unmask;
|
||||
pctl->irq_chip.irq_set_type = stmfx_pinctrl_irq_set_type;
|
||||
pctl->irq_chip.irq_bus_lock = stmfx_pinctrl_irq_bus_lock;
|
||||
pctl->irq_chip.irq_bus_sync_unlock = stmfx_pinctrl_irq_bus_sync_unlock;
|
||||
pctl->irq_chip.irq_request_resources = stmfx_gpio_irq_request_resources;
|
||||
pctl->irq_chip.irq_release_resources = stmfx_gpio_irq_release_resources;
|
||||
|
||||
girq = &pctl->gpio_chip.irq;
|
||||
girq->chip = &pctl->irq_chip;
|
||||
/* This will let us handle the parent IRQ in the driver */
|
||||
girq->parent_handler = NULL;
|
||||
girq->num_parents = 0;
|
||||
girq->parents = NULL;
|
||||
girq->default_type = IRQ_TYPE_NONE;
|
||||
girq->handler = handle_bad_irq;
|
||||
girq->threaded = true;
|
||||
|
||||
ret = devm_gpiochip_add_data(pctl->dev, &pctl->gpio_chip, pctl);
|
||||
if (ret) {
|
||||
dev_err(pctl->dev, "gpio_chip registration failed\n");
|
||||
|
@ -684,22 +704,6 @@ static int stmfx_pinctrl_probe(struct platform_device *pdev)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
pctl->irq_chip.name = dev_name(pctl->dev);
|
||||
pctl->irq_chip.irq_mask = stmfx_pinctrl_irq_mask;
|
||||
pctl->irq_chip.irq_unmask = stmfx_pinctrl_irq_unmask;
|
||||
pctl->irq_chip.irq_set_type = stmfx_pinctrl_irq_set_type;
|
||||
pctl->irq_chip.irq_bus_lock = stmfx_pinctrl_irq_bus_lock;
|
||||
pctl->irq_chip.irq_bus_sync_unlock = stmfx_pinctrl_irq_bus_sync_unlock;
|
||||
pctl->irq_chip.irq_request_resources = stmfx_gpio_irq_request_resources;
|
||||
pctl->irq_chip.irq_release_resources = stmfx_gpio_irq_release_resources;
|
||||
|
||||
ret = gpiochip_irqchip_add_nested(&pctl->gpio_chip, &pctl->irq_chip,
|
||||
0, handle_bad_irq, IRQ_TYPE_NONE);
|
||||
if (ret) {
|
||||
dev_err(pctl->dev, "cannot add irqchip to gpiochip\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = devm_request_threaded_irq(pctl->dev, irq, NULL,
|
||||
stmfx_pinctrl_irq_thread_fn,
|
||||
IRQF_ONESHOT,
|
||||
|
@ -709,8 +713,6 @@ static int stmfx_pinctrl_probe(struct platform_device *pdev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
gpiochip_set_nested_irqchip(&pctl->gpio_chip, &pctl->irq_chip, irq);
|
||||
|
||||
dev_info(pctl->dev,
|
||||
"%ld GPIOs available\n", hweight_long(pctl->gpio_valid_mask));
|
||||
|
||||
|
|
Loading…
Reference in New Issue