Skip to content

Commit bb7e64e

Browse files
author
Linus Walleij
committed
pinctrl: nsp: Convert to immutable irq_chip
Convert the driver to immutable irq-chip with a bit of intuition. Cc: Marc Zyngier <maz@kernel.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20230403-immutable-irqchips-v1-2-503788a7f6e6@linaro.org
1 parent 2cc4485 commit bb7e64e

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

drivers/pinctrl/bcm/pinctrl-nsp-gpio.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ struct nsp_gpio {
6060
struct device *dev;
6161
void __iomem *base;
6262
void __iomem *io_ctrl;
63-
struct irq_chip irqchip;
6463
struct gpio_chip gc;
6564
struct pinctrl_dev *pctl;
6665
struct pinctrl_desc pctldesc;
@@ -193,6 +192,7 @@ static void nsp_gpio_irq_mask(struct irq_data *d)
193192
raw_spin_lock_irqsave(&chip->lock, flags);
194193
nsp_gpio_irq_set_mask(d, false);
195194
raw_spin_unlock_irqrestore(&chip->lock, flags);
195+
gpiochip_disable_irq(gc, irqd_to_hwirq(d));
196196
}
197197

198198
static void nsp_gpio_irq_unmask(struct irq_data *d)
@@ -201,6 +201,7 @@ static void nsp_gpio_irq_unmask(struct irq_data *d)
201201
struct nsp_gpio *chip = gpiochip_get_data(gc);
202202
unsigned long flags;
203203

204+
gpiochip_enable_irq(gc, irqd_to_hwirq(d));
204205
raw_spin_lock_irqsave(&chip->lock, flags);
205206
nsp_gpio_irq_set_mask(d, true);
206207
raw_spin_unlock_irqrestore(&chip->lock, flags);
@@ -258,6 +259,16 @@ static int nsp_gpio_irq_set_type(struct irq_data *d, unsigned int type)
258259
return 0;
259260
}
260261

262+
static const struct irq_chip nsp_gpio_irq_chip = {
263+
.name = "gpio-a",
264+
.irq_ack = nsp_gpio_irq_ack,
265+
.irq_mask = nsp_gpio_irq_mask,
266+
.irq_unmask = nsp_gpio_irq_unmask,
267+
.irq_set_type = nsp_gpio_irq_set_type,
268+
.flags = IRQCHIP_IMMUTABLE,
269+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
270+
};
271+
261272
static int nsp_gpio_direction_input(struct gpio_chip *gc, unsigned gpio)
262273
{
263274
struct nsp_gpio *chip = gpiochip_get_data(gc);
@@ -650,14 +661,6 @@ static int nsp_gpio_probe(struct platform_device *pdev)
650661
irq = platform_get_irq(pdev, 0);
651662
if (irq > 0) {
652663
struct gpio_irq_chip *girq;
653-
struct irq_chip *irqc;
654-
655-
irqc = &chip->irqchip;
656-
irqc->name = "gpio-a";
657-
irqc->irq_ack = nsp_gpio_irq_ack;
658-
irqc->irq_mask = nsp_gpio_irq_mask;
659-
irqc->irq_unmask = nsp_gpio_irq_unmask;
660-
irqc->irq_set_type = nsp_gpio_irq_set_type;
661664

662665
val = readl(chip->base + NSP_CHIP_A_INT_MASK);
663666
val = val | NSP_CHIP_A_GPIO_INT_BIT;
@@ -673,7 +676,7 @@ static int nsp_gpio_probe(struct platform_device *pdev)
673676
}
674677

675678
girq = &chip->gc.irq;
676-
girq->chip = irqc;
679+
gpio_irq_chip_set_chip(girq, &nsp_gpio_irq_chip);
677680
/* This will let us handle the parent IRQ in the driver */
678681
girq->parent_handler = NULL;
679682
girq->num_parents = 0;

0 commit comments

Comments
 (0)