Skip to content

Commit 485037a

Browse files
Aidan MacDonaldbroonie
authored andcommitted
regmap-irq: Fix a bug in regmap_irq_enable() for type_in_mask chips
When enabling a type_in_mask irq, the type_buf contents must be AND'd with the mask of the IRQ we're enabling to avoid enabling other IRQs by accident, which can happen if several type_in_mask irqs share a mask register. Fixes: bc998a7 ("regmap: irq: handle HW using separate rising/falling edge interrupts") Signed-off-by: Aidan MacDonald <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 2a16692 commit 485037a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/base/regmap/regmap-irq.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ static void regmap_irq_enable(struct irq_data *data)
252252
struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data);
253253
struct regmap *map = d->map;
254254
const struct regmap_irq *irq_data = irq_to_regmap_irq(d, data->hwirq);
255+
unsigned int reg = irq_data->reg_offset / map->reg_stride;
255256
unsigned int mask, type;
256257

257258
type = irq_data->type.type_falling_val | irq_data->type.type_rising_val;
@@ -268,14 +269,14 @@ static void regmap_irq_enable(struct irq_data *data)
268269
* at the corresponding offset in regmap_irq_set_type().
269270
*/
270271
if (d->chip->type_in_mask && type)
271-
mask = d->type_buf[irq_data->reg_offset / map->reg_stride];
272+
mask = d->type_buf[reg] & irq_data->mask;
272273
else
273274
mask = irq_data->mask;
274275

275276
if (d->chip->clear_on_unmask)
276277
d->clear_status = true;
277278

278-
d->mask_buf[irq_data->reg_offset / map->reg_stride] &= ~mask;
279+
d->mask_buf[reg] &= ~mask;
279280
}
280281

281282
static void regmap_irq_disable(struct irq_data *data)

0 commit comments

Comments
 (0)