Skip to content

Commit cfc2b00

Browse files
geertubrgl
authored andcommitted
gpio: dwapb: Make the irqchip immutable
Commit 6c846d0 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips. Following this change the following warning is now observed for the dwapb driver: gpio gpiochip0: (50200000.gpio): not an immutable chip, please consider fixing it! Fix this by making the irqchip in the dwapb driver immutable. Signed-off-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent c680c6a commit cfc2b00

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

drivers/gpio/gpio-dwapb.c

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ struct dwapb_context {
9595
#endif
9696

9797
struct dwapb_gpio_port_irqchip {
98-
struct irq_chip irqchip;
9998
unsigned int nr_irqs;
10099
unsigned int irq[DWAPB_MAX_GPIOS];
101100
};
@@ -252,24 +251,30 @@ static void dwapb_irq_mask(struct irq_data *d)
252251
{
253252
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
254253
struct dwapb_gpio *gpio = to_dwapb_gpio(gc);
254+
irq_hw_number_t hwirq = irqd_to_hwirq(d);
255255
unsigned long flags;
256256
u32 val;
257257

258258
raw_spin_lock_irqsave(&gc->bgpio_lock, flags);
259-
val = dwapb_read(gpio, GPIO_INTMASK) | BIT(irqd_to_hwirq(d));
259+
val = dwapb_read(gpio, GPIO_INTMASK) | BIT(hwirq);
260260
dwapb_write(gpio, GPIO_INTMASK, val);
261261
raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
262+
263+
gpiochip_disable_irq(gc, hwirq);
262264
}
263265

264266
static void dwapb_irq_unmask(struct irq_data *d)
265267
{
266268
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
267269
struct dwapb_gpio *gpio = to_dwapb_gpio(gc);
270+
irq_hw_number_t hwirq = irqd_to_hwirq(d);
268271
unsigned long flags;
269272
u32 val;
270273

274+
gpiochip_enable_irq(gc, hwirq);
275+
271276
raw_spin_lock_irqsave(&gc->bgpio_lock, flags);
272-
val = dwapb_read(gpio, GPIO_INTMASK) & ~BIT(irqd_to_hwirq(d));
277+
val = dwapb_read(gpio, GPIO_INTMASK) & ~BIT(hwirq);
273278
dwapb_write(gpio, GPIO_INTMASK, val);
274279
raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
275280
}
@@ -364,8 +369,23 @@ static int dwapb_irq_set_wake(struct irq_data *d, unsigned int enable)
364369

365370
return 0;
366371
}
372+
#else
373+
#define dwapb_irq_set_wake NULL
367374
#endif
368375

376+
static const struct irq_chip dwapb_irq_chip = {
377+
.name = DWAPB_DRIVER_NAME,
378+
.irq_ack = dwapb_irq_ack,
379+
.irq_mask = dwapb_irq_mask,
380+
.irq_unmask = dwapb_irq_unmask,
381+
.irq_set_type = dwapb_irq_set_type,
382+
.irq_enable = dwapb_irq_enable,
383+
.irq_disable = dwapb_irq_disable,
384+
.irq_set_wake = dwapb_irq_set_wake,
385+
.flags = IRQCHIP_IMMUTABLE,
386+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
387+
};
388+
369389
static int dwapb_gpio_set_debounce(struct gpio_chip *gc,
370390
unsigned offset, unsigned debounce)
371391
{
@@ -439,16 +459,6 @@ static void dwapb_configure_irqs(struct dwapb_gpio *gpio,
439459
girq->default_type = IRQ_TYPE_NONE;
440460

441461
port->pirq = pirq;
442-
pirq->irqchip.name = DWAPB_DRIVER_NAME;
443-
pirq->irqchip.irq_ack = dwapb_irq_ack;
444-
pirq->irqchip.irq_mask = dwapb_irq_mask;
445-
pirq->irqchip.irq_unmask = dwapb_irq_unmask;
446-
pirq->irqchip.irq_set_type = dwapb_irq_set_type;
447-
pirq->irqchip.irq_enable = dwapb_irq_enable;
448-
pirq->irqchip.irq_disable = dwapb_irq_disable;
449-
#ifdef CONFIG_PM_SLEEP
450-
pirq->irqchip.irq_set_wake = dwapb_irq_set_wake;
451-
#endif
452462

453463
/*
454464
* Intel ACPI-based platforms mostly have the DesignWare APB GPIO
@@ -475,7 +485,7 @@ static void dwapb_configure_irqs(struct dwapb_gpio *gpio,
475485
girq->parent_handler = dwapb_irq_handler;
476486
}
477487

478-
girq->chip = &pirq->irqchip;
488+
gpio_irq_chip_set_chip(girq, &dwapb_irq_chip);
479489

480490
return;
481491

0 commit comments

Comments
 (0)