Skip to content

Commit 1de39b6

Browse files
committed
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 <[email protected]> Cc: Amelie Delaunay <[email protected]> Cc: Benjamin Gaignard <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e81376e commit 1de39b6

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

drivers/pinctrl/pinctrl-stmfx.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ static int stmfx_pinctrl_probe(struct platform_device *pdev)
616616
struct stmfx *stmfx = dev_get_drvdata(pdev->dev.parent);
617617
struct device_node *np = pdev->dev.of_node;
618618
struct stmfx_pinctrl *pctl;
619+
struct gpio_irq_chip *girq;
619620
int irq, ret;
620621

621622
pctl = devm_kzalloc(stmfx->dev, sizeof(*pctl), GFP_KERNEL);
@@ -674,16 +675,6 @@ static int stmfx_pinctrl_probe(struct platform_device *pdev)
674675
pctl->gpio_chip.can_sleep = true;
675676
pctl->gpio_chip.of_node = np;
676677

677-
ret = devm_gpiochip_add_data(pctl->dev, &pctl->gpio_chip, pctl);
678-
if (ret) {
679-
dev_err(pctl->dev, "gpio_chip registration failed\n");
680-
return ret;
681-
}
682-
683-
ret = stmfx_pinctrl_gpio_function_enable(pctl);
684-
if (ret)
685-
return ret;
686-
687678
pctl->irq_chip.name = dev_name(pctl->dev);
688679
pctl->irq_chip.irq_mask = stmfx_pinctrl_irq_mask;
689680
pctl->irq_chip.irq_unmask = stmfx_pinctrl_irq_unmask;
@@ -693,13 +684,26 @@ static int stmfx_pinctrl_probe(struct platform_device *pdev)
693684
pctl->irq_chip.irq_request_resources = stmfx_gpio_irq_request_resources;
694685
pctl->irq_chip.irq_release_resources = stmfx_gpio_irq_release_resources;
695686

696-
ret = gpiochip_irqchip_add_nested(&pctl->gpio_chip, &pctl->irq_chip,
697-
0, handle_bad_irq, IRQ_TYPE_NONE);
687+
girq = &pctl->gpio_chip.irq;
688+
girq->chip = &pctl->irq_chip;
689+
/* This will let us handle the parent IRQ in the driver */
690+
girq->parent_handler = NULL;
691+
girq->num_parents = 0;
692+
girq->parents = NULL;
693+
girq->default_type = IRQ_TYPE_NONE;
694+
girq->handler = handle_bad_irq;
695+
girq->threaded = true;
696+
697+
ret = devm_gpiochip_add_data(pctl->dev, &pctl->gpio_chip, pctl);
698698
if (ret) {
699-
dev_err(pctl->dev, "cannot add irqchip to gpiochip\n");
699+
dev_err(pctl->dev, "gpio_chip registration failed\n");
700700
return ret;
701701
}
702702

703+
ret = stmfx_pinctrl_gpio_function_enable(pctl);
704+
if (ret)
705+
return ret;
706+
703707
ret = devm_request_threaded_irq(pctl->dev, irq, NULL,
704708
stmfx_pinctrl_irq_thread_fn,
705709
IRQF_ONESHOT,
@@ -709,8 +713,6 @@ static int stmfx_pinctrl_probe(struct platform_device *pdev)
709713
return ret;
710714
}
711715

712-
gpiochip_set_nested_irqchip(&pctl->gpio_chip, &pctl->irq_chip, irq);
713-
714716
dev_info(pctl->dev,
715717
"%ld GPIOs available\n", hweight_long(pctl->gpio_valid_mask));
716718

0 commit comments

Comments
 (0)