Skip to content

Commit 09eed5a

Browse files
parakabrgl
authored andcommitted
gpio: mt7621: 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 warnings are now observed for the mt7621 driver: gpio gpiochip0: (1e000600.gpio-bank0): not an immutable chip, please consider fixing it! gpio gpiochip1: (1e000600.gpio-bank1): not an immutable chip, please consider fixing it! gpio gpiochip2: (1e000600.gpio-bank2): not an immutable chip, please consider fixing it! Fix this by making the irqchip in the mt7621 driver immutable. Tested-by: Arınç ÜNAL <[email protected]> Signed-off-by: Sergio Paracuellos <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 94e9bc7 commit 09eed5a

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

drivers/gpio/gpio-mt7621.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ mediatek_gpio_irq_unmask(struct irq_data *d)
112112
unsigned long flags;
113113
u32 rise, fall, high, low;
114114

115+
gpiochip_enable_irq(gc, d->hwirq);
116+
115117
spin_lock_irqsave(&rg->lock, flags);
116118
rise = mtk_gpio_r32(rg, GPIO_REG_REDGE);
117119
fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE);
@@ -143,6 +145,8 @@ mediatek_gpio_irq_mask(struct irq_data *d)
143145
mtk_gpio_w32(rg, GPIO_REG_HLVL, high & ~BIT(pin));
144146
mtk_gpio_w32(rg, GPIO_REG_LLVL, low & ~BIT(pin));
145147
spin_unlock_irqrestore(&rg->lock, flags);
148+
149+
gpiochip_disable_irq(gc, d->hwirq);
146150
}
147151

148152
static int
@@ -204,6 +208,16 @@ mediatek_gpio_xlate(struct gpio_chip *chip,
204208
return gpio % MTK_BANK_WIDTH;
205209
}
206210

211+
static const struct irq_chip mt7621_irq_chip = {
212+
.name = "mt7621-gpio",
213+
.irq_mask_ack = mediatek_gpio_irq_mask,
214+
.irq_mask = mediatek_gpio_irq_mask,
215+
.irq_unmask = mediatek_gpio_irq_unmask,
216+
.irq_set_type = mediatek_gpio_irq_type,
217+
.flags = IRQCHIP_IMMUTABLE,
218+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
219+
};
220+
207221
static int
208222
mediatek_gpio_bank_probe(struct device *dev, int bank)
209223
{
@@ -238,11 +252,6 @@ mediatek_gpio_bank_probe(struct device *dev, int bank)
238252
return -ENOMEM;
239253

240254
rg->chip.offset = bank * MTK_BANK_WIDTH;
241-
rg->irq_chip.name = dev_name(dev);
242-
rg->irq_chip.irq_unmask = mediatek_gpio_irq_unmask;
243-
rg->irq_chip.irq_mask = mediatek_gpio_irq_mask;
244-
rg->irq_chip.irq_mask_ack = mediatek_gpio_irq_mask;
245-
rg->irq_chip.irq_set_type = mediatek_gpio_irq_type;
246255

247256
if (mtk->gpio_irq) {
248257
struct gpio_irq_chip *girq;
@@ -262,7 +271,7 @@ mediatek_gpio_bank_probe(struct device *dev, int bank)
262271
}
263272

264273
girq = &rg->chip.irq;
265-
girq->chip = &rg->irq_chip;
274+
gpio_irq_chip_set_chip(girq, &mt7621_irq_chip);
266275
/* This will let us handle the parent IRQ in the driver */
267276
girq->parent_handler = NULL;
268277
girq->num_parents = 0;

0 commit comments

Comments
 (0)