Skip to content

Commit df1e76f

Browse files
brgllinusw
authored andcommitted
gpiolib: skip unwanted events, don't convert them to opposite edge
The previous fix for filtering out of unwatched events was not entirely correct. Instead of skipping the events we don't want, they are now interpreted as events with opposing edge. In order to fix it: always read the GPIO line value on interrupt and only emit the event if it corresponds with the event type we requested. Cc: stable@vger.kernel.org Fixes: ad537b8 ("gpiolib: fix filtering out unwanted events") Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent a589e21 commit df1e76f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

drivers/gpio/gpiolib.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -704,24 +704,23 @@ static irqreturn_t lineevent_irq_thread(int irq, void *p)
704704
{
705705
struct lineevent_state *le = p;
706706
struct gpioevent_data ge;
707-
int ret;
707+
int ret, level;
708708

709709
ge.timestamp = ktime_get_real_ns();
710+
level = gpiod_get_value_cansleep(le->desc);
710711

711712
if (le->eflags & GPIOEVENT_REQUEST_RISING_EDGE
712713
&& le->eflags & GPIOEVENT_REQUEST_FALLING_EDGE) {
713-
int level = gpiod_get_value_cansleep(le->desc);
714-
715714
if (level)
716715
/* Emit low-to-high event */
717716
ge.id = GPIOEVENT_EVENT_RISING_EDGE;
718717
else
719718
/* Emit high-to-low event */
720719
ge.id = GPIOEVENT_EVENT_FALLING_EDGE;
721-
} else if (le->eflags & GPIOEVENT_REQUEST_RISING_EDGE) {
720+
} else if (le->eflags & GPIOEVENT_REQUEST_RISING_EDGE && level) {
722721
/* Emit low-to-high event */
723722
ge.id = GPIOEVENT_EVENT_RISING_EDGE;
724-
} else if (le->eflags & GPIOEVENT_REQUEST_FALLING_EDGE) {
723+
} else if (le->eflags & GPIOEVENT_REQUEST_FALLING_EDGE && !level) {
725724
/* Emit high-to-low event */
726725
ge.id = GPIOEVENT_EVENT_FALLING_EDGE;
727726
} else {

0 commit comments

Comments
 (0)