lkml.org 
[lkml]   [2019]   [Jul]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] gpiolib: fix incorrect IRQ requesting of an active-low lineevent
pt., 5 lip 2019 o 12:35 <Michael.Wu@vatics.com> napisał(a):
>
> Hi Bartosz,
>
> For example, there is a button which drives level to be low when it is pushed, and drivers level to be high when it is released.
> We want to catch the event when the button is pushed.
>
> In user space we configure a line event with the following code:
>
> req.handleflags = GPIOHANDLE_REQUEST_INPUT;
> req.eventflags = GPIOEVENT_REQUEST_FALLING_EDGE;
>
> and we hope to get "falling" events by reading the device node:
>
> while (1) {
> read(fd, &dat,sizeof(dat));
> if (dat.id == 0) {
> printf("button pushed\n");
> }
> }
>
> Run the same logic on another board which the polarity of the button is inverted. The button drives level to be high when it is pushed.
> For the inverted level case, we have to add flag GPIOHANDLE_REQUEST_ACTIVE_LOW:
>
> req.handleflags = GPIOHANDLE_REQUEST_INPUT | GPIOHANDLE_REQUEST_ACTIVE_LOW;
> req.eventflags = GPIOEVENT_REQUEST_FALLING_EDGE;
>
> At the result, there are no any events been caught when the button is pushed.
> By the way, button releasing will emit a "falling" event.
>
>
> Sincerely,
>
> Michael Wu

First: please don't top-post on the mailing list.

Second: have you even built the version you sent? Because I'm getting this:

drivers/gpio/gpiolib.c: In function ‘lineevent_create’:
drivers/gpio/gpiolib.c:963:4: error: ‘IRQ_TRIGGER_RISING’ undeclared
(first use in this function)
IRQ_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
^~~~~~~~~~~~~~~~~~

And third: after fixing the define, this indeed looks like a bug and
I'll need to add a test for that to libgpiod once it's upstream.
Strange we didn't catch it before.

Please send a fixed version and add a Cc tag for stable. Nice catch!

Best regards
Bartosz Golaszewski

\
 
 \ /
  Last update: 2019-07-05 14:51    [W:0.051 / U:0.408 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site