Skip to content

Commit 0b22c25

Browse files
andy-shevbrgl
authored andcommitted
gpio: pca953x: Fix direction setting when configure an IRQ
The commit 0f25fda ("gpio: pca953x: Zap ad-hoc reg_direction cache") seems inadvertently made a typo in pca953x_irq_bus_sync_unlock(). When the direction bit is 1 it means input, and the piece of code in question was looking for output ones that should be turned to inputs. Fix direction setting when configure an IRQ by injecting a bitmap complement operation. Fixes: 0f25fda ("gpio: pca953x: Zap ad-hoc reg_direction cache") Depends-on: 35d13d9 ("gpio: pca953x: convert to use bitmap API") Cc: Marek Vasut <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent ba8c90c commit 0b22c25

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/gpio/gpio-pca953x.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,6 @@ static void pca953x_irq_bus_sync_unlock(struct irq_data *d)
696696
DECLARE_BITMAP(reg_direction, MAX_LINE);
697697
int level;
698698

699-
pca953x_read_regs(chip, chip->regs->direction, reg_direction);
700-
701699
if (chip->driver_data & PCA_PCAL) {
702700
/* Enable latch on interrupt-enabled inputs */
703701
pca953x_write_regs(chip, PCAL953X_IN_LATCH, chip->irq_mask);
@@ -708,7 +706,11 @@ static void pca953x_irq_bus_sync_unlock(struct irq_data *d)
708706
pca953x_write_regs(chip, PCAL953X_INT_MASK, irq_mask);
709707
}
710708

709+
/* Switch direction to input if needed */
710+
pca953x_read_regs(chip, chip->regs->direction, reg_direction);
711+
711712
bitmap_or(irq_mask, chip->irq_trig_fall, chip->irq_trig_raise, gc->ngpio);
713+
bitmap_complement(reg_direction, reg_direction, gc->ngpio);
712714
bitmap_and(irq_mask, irq_mask, reg_direction, gc->ngpio);
713715

714716
/* Look for any newly setup interrupt */

0 commit comments

Comments
 (0)