Skip to content

Commit d6179f6

Browse files
Mark TomlinsonBartosz Golaszewski
authored andcommitted
gpio: pca953x: Improve interrupt support
The GPIO drivers with latch interrupt support (typically types starting with PCAL) have interrupt status registers to determine which particular inputs have caused an interrupt. Unfortunately there is no atomic operation to read these registers and clear the interrupt. Clearing the interrupt is done by reading the input registers. The code was reading the interrupt status registers, and then reading the input registers. If an input changed between these two events it was lost. The solution in this patch is to revert to the non-latch version of code, i.e. remembering the previous input status, and looking for the changes. This system results in no more I2C transfers, so is no slower. The latch property of the device still means interrupts will still be noticed if the input changes back to its initial state. Fixes: 44896be ("gpio: pca953x: add PCAL9535 interrupt support for Galileo Gen2") Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20240606033102.2271916-1-mark.tomlinson@alliedtelesis.co.nz Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent 2014c95 commit d6179f6

File tree

1 file changed

+0
-19
lines changed

1 file changed

+0
-19
lines changed

drivers/gpio/gpio-pca953x.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -841,25 +841,6 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, unsigned long *pendin
841841
DECLARE_BITMAP(trigger, MAX_LINE);
842842
int ret;
843843

844-
if (chip->driver_data & PCA_PCAL) {
845-
/* Read the current interrupt status from the device */
846-
ret = pca953x_read_regs(chip, PCAL953X_INT_STAT, trigger);
847-
if (ret)
848-
return false;
849-
850-
/* Check latched inputs and clear interrupt status */
851-
ret = pca953x_read_regs(chip, chip->regs->input, cur_stat);
852-
if (ret)
853-
return false;
854-
855-
/* Apply filter for rising/falling edge selection */
856-
bitmap_replace(new_stat, chip->irq_trig_fall, chip->irq_trig_raise, cur_stat, gc->ngpio);
857-
858-
bitmap_and(pending, new_stat, trigger, gc->ngpio);
859-
860-
return !bitmap_empty(pending, gc->ngpio);
861-
}
862-
863844
ret = pca953x_read_regs(chip, chip->regs->input, cur_stat);
864845
if (ret)
865846
return false;

0 commit comments

Comments
 (0)