Commit b680e22f authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by Greg Kroah-Hartman

gpiolib: skip unwanted events, don't convert them to opposite edge

commit df1e76f2 upstream.

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.

Fixes: ad537b82 ("gpiolib: fix filtering out unwanted events")
Signed-off-by: default avatarBartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent be5c6efc
...@@ -703,24 +703,23 @@ static irqreturn_t lineevent_irq_thread(int irq, void *p) ...@@ -703,24 +703,23 @@ static irqreturn_t lineevent_irq_thread(int irq, void *p)
{ {
struct lineevent_state *le = p; struct lineevent_state *le = p;
struct gpioevent_data ge; struct gpioevent_data ge;
int ret; int ret, level;
ge.timestamp = ktime_get_real_ns(); ge.timestamp = ktime_get_real_ns();
level = gpiod_get_value_cansleep(le->desc);
if (le->eflags & GPIOEVENT_REQUEST_RISING_EDGE if (le->eflags & GPIOEVENT_REQUEST_RISING_EDGE
&& le->eflags & GPIOEVENT_REQUEST_FALLING_EDGE) { && le->eflags & GPIOEVENT_REQUEST_FALLING_EDGE) {
int level = gpiod_get_value_cansleep(le->desc);
if (level) if (level)
/* Emit low-to-high event */ /* Emit low-to-high event */
ge.id = GPIOEVENT_EVENT_RISING_EDGE; ge.id = GPIOEVENT_EVENT_RISING_EDGE;
else else
/* Emit high-to-low event */ /* Emit high-to-low event */
ge.id = GPIOEVENT_EVENT_FALLING_EDGE; ge.id = GPIOEVENT_EVENT_FALLING_EDGE;
} else if (le->eflags & GPIOEVENT_REQUEST_RISING_EDGE) { } else if (le->eflags & GPIOEVENT_REQUEST_RISING_EDGE && level) {
/* Emit low-to-high event */ /* Emit low-to-high event */
ge.id = GPIOEVENT_EVENT_RISING_EDGE; ge.id = GPIOEVENT_EVENT_RISING_EDGE;
} else if (le->eflags & GPIOEVENT_REQUEST_FALLING_EDGE) { } else if (le->eflags & GPIOEVENT_REQUEST_FALLING_EDGE && !level) {
/* Emit high-to-low event */ /* Emit high-to-low event */
ge.id = GPIOEVENT_EVENT_FALLING_EDGE; ge.id = GPIOEVENT_EVENT_FALLING_EDGE;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment