* [libgpiod][PATCH v2] core: fix deselection of output direction when edge detection is selected
@ 2024-01-02 14:52 J.A. Bezemer
2024-01-02 18:27 ` Kent Gibson
2024-01-03 8:46 ` Bartosz Golaszewski
0 siblings, 2 replies; 4+ messages in thread
From: J.A. Bezemer @ 2024-01-02 14:52 UTC (permalink / raw)
To: linux-gpio
Fix deselection of output direction when edge detection is selected in
make_kernel_flags(). Use correct flag to perform deselection rather than
a library enum.
For correct usage, there are no visible side-effects. The wrongly reset
kernel flags are always zero already.
For incorrect usage of edge detection combined with output direction,
both output and input directions would have been requested from the
kernel, causing a confusing error. Such usage will now be sanitized, as
intended, into a working configuration with only input direction.
Signed-off-by: Anne Bezemer <j.a.bezemer@opensourcepartners.nl>
---
lib/line-config.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/line-config.c b/lib/line-config.c
index 2749a2a..9bf7734 100644
--- a/lib/line-config.c
+++ b/lib/line-config.c
@@ -381,18 +381,18 @@ static uint64_t make_kernel_flags(struct gpiod_line_settings *settings)
case GPIOD_LINE_EDGE_FALLING:
flags |= (GPIO_V2_LINE_FLAG_EDGE_FALLING |
GPIO_V2_LINE_FLAG_INPUT);
- flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
+ flags &= ~GPIO_V2_LINE_FLAG_OUTPUT;
break;
case GPIOD_LINE_EDGE_RISING:
flags |= (GPIO_V2_LINE_FLAG_EDGE_RISING |
GPIO_V2_LINE_FLAG_INPUT);
- flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
+ flags &= ~GPIO_V2_LINE_FLAG_OUTPUT;
break;
case GPIOD_LINE_EDGE_BOTH:
flags |= (GPIO_V2_LINE_FLAG_EDGE_FALLING |
GPIO_V2_LINE_FLAG_EDGE_RISING |
GPIO_V2_LINE_FLAG_INPUT);
- flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
+ flags &= ~GPIO_V2_LINE_FLAG_OUTPUT;
break;
default:
break;
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [libgpiod][PATCH v2] core: fix deselection of output direction when edge detection is selected
2024-01-02 14:52 [libgpiod][PATCH v2] core: fix deselection of output direction when edge detection is selected J.A. Bezemer
@ 2024-01-02 18:27 ` Kent Gibson
2024-01-03 8:46 ` Bartosz Golaszewski
1 sibling, 0 replies; 4+ messages in thread
From: Kent Gibson @ 2024-01-02 18:27 UTC (permalink / raw)
To: J.A. Bezemer; +Cc: linux-gpio, brgl
On Tue, Jan 02, 2024 at 03:52:01PM +0100, J.A. Bezemer wrote:
> Fix deselection of output direction when edge detection is selected in
> make_kernel_flags(). Use correct flag to perform deselection rather than
> a library enum.
>
> For correct usage, there are no visible side-effects. The wrongly reset
> kernel flags are always zero already.
>
> For incorrect usage of edge detection combined with output direction,
> both output and input directions would have been requested from the
> kernel, causing a confusing error. Such usage will now be sanitized, as
> intended, into a working configuration with only input direction.
>
> Signed-off-by: Anne Bezemer <j.a.bezemer@opensourcepartners.nl>
That works for me.
Reviewed-by: Kent Gibson <warthog618@gmail.com>
> ---
> lib/line-config.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/lib/line-config.c b/lib/line-config.c
> index 2749a2a..9bf7734 100644
> --- a/lib/line-config.c
> +++ b/lib/line-config.c
> @@ -381,18 +381,18 @@ static uint64_t make_kernel_flags(struct gpiod_line_settings *settings)
> case GPIOD_LINE_EDGE_FALLING:
> flags |= (GPIO_V2_LINE_FLAG_EDGE_FALLING |
> GPIO_V2_LINE_FLAG_INPUT);
> - flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
> + flags &= ~GPIO_V2_LINE_FLAG_OUTPUT;
> break;
> case GPIOD_LINE_EDGE_RISING:
> flags |= (GPIO_V2_LINE_FLAG_EDGE_RISING |
> GPIO_V2_LINE_FLAG_INPUT);
> - flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
> + flags &= ~GPIO_V2_LINE_FLAG_OUTPUT;
> break;
> case GPIOD_LINE_EDGE_BOTH:
> flags |= (GPIO_V2_LINE_FLAG_EDGE_FALLING |
> GPIO_V2_LINE_FLAG_EDGE_RISING |
> GPIO_V2_LINE_FLAG_INPUT);
> - flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
> + flags &= ~GPIO_V2_LINE_FLAG_OUTPUT;
> break;
> default:
> break;
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [libgpiod][PATCH v2] core: fix deselection of output direction when edge detection is selected
2024-01-02 14:52 [libgpiod][PATCH v2] core: fix deselection of output direction when edge detection is selected J.A. Bezemer
2024-01-02 18:27 ` Kent Gibson
@ 2024-01-03 8:46 ` Bartosz Golaszewski
2024-01-03 19:17 ` J.A. Bezemer
1 sibling, 1 reply; 4+ messages in thread
From: Bartosz Golaszewski @ 2024-01-03 8:46 UTC (permalink / raw)
To: J.A. Bezemer; +Cc: linux-gpio
On Tue, Jan 2, 2024 at 3:52 PM J.A. Bezemer
<j.a.bezemer@opensourcepartners.nl> wrote:
>
> Fix deselection of output direction when edge detection is selected in
> make_kernel_flags(). Use correct flag to perform deselection rather than
> a library enum.
>
> For correct usage, there are no visible side-effects. The wrongly reset
> kernel flags are always zero already.
>
> For incorrect usage of edge detection combined with output direction,
> both output and input directions would have been requested from the
> kernel, causing a confusing error. Such usage will now be sanitized, as
> intended, into a working configuration with only input direction.
>
> Signed-off-by: Anne Bezemer <j.a.bezemer@opensourcepartners.nl>
> ---
> lib/line-config.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/lib/line-config.c b/lib/line-config.c
> index 2749a2a..9bf7734 100644
> --- a/lib/line-config.c
> +++ b/lib/line-config.c
> @@ -381,18 +381,18 @@ static uint64_t make_kernel_flags(struct gpiod_line_settings *settings)
> case GPIOD_LINE_EDGE_FALLING:
> flags |= (GPIO_V2_LINE_FLAG_EDGE_FALLING |
> GPIO_V2_LINE_FLAG_INPUT);
> - flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
> + flags &= ~GPIO_V2_LINE_FLAG_OUTPUT;
> break;
> case GPIOD_LINE_EDGE_RISING:
> flags |= (GPIO_V2_LINE_FLAG_EDGE_RISING |
> GPIO_V2_LINE_FLAG_INPUT);
> - flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
> + flags &= ~GPIO_V2_LINE_FLAG_OUTPUT;
> break;
> case GPIOD_LINE_EDGE_BOTH:
> flags |= (GPIO_V2_LINE_FLAG_EDGE_FALLING |
> GPIO_V2_LINE_FLAG_EDGE_RISING |
> GPIO_V2_LINE_FLAG_INPUT);
> - flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
> + flags &= ~GPIO_V2_LINE_FLAG_OUTPUT;
> break;
> default:
> break;
> --
> 2.30.2
>
>
This does not apply on top of current master, could you please verify?
Bart
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [libgpiod][PATCH v2] core: fix deselection of output direction when edge detection is selected
2024-01-03 8:46 ` Bartosz Golaszewski
@ 2024-01-03 19:17 ` J.A. Bezemer
0 siblings, 0 replies; 4+ messages in thread
From: J.A. Bezemer @ 2024-01-03 19:17 UTC (permalink / raw)
To: Bartosz Golaszewski; +Cc: linux-gpio
[-- Attachment #1: Type: TEXT/PLAIN, Size: 2418 bytes --]
On Wed, 3 Jan 2024, Bartosz Golaszewski wrote:
> On Tue, Jan 2, 2024 at 3:52ÿÿPM J.A. Bezemer
> <j.a.bezemer@opensourcepartners.nl> wrote:
> >
> > Fix deselection of output direction when edge detection is selected in
> > make_kernel_flags(). Use correct flag to perform deselection rather than
> > a library enum.
> >
> > For correct usage, there are no visible side-effects. The wrongly reset
> > kernel flags are always zero already.
> >
> > For incorrect usage of edge detection combined with output direction,
> > both output and input directions would have been requested from the
> > kernel, causing a confusing error. Such usage will now be sanitized, as
> > intended, into a working configuration with only input direction.
> >
> > Signed-off-by: Anne Bezemer <j.a.bezemer@opensourcepartners.nl>
> > ---
> > lib/line-config.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/lib/line-config.c b/lib/line-config.c
> > index 2749a2a..9bf7734 100644
> > --- a/lib/line-config.c
> > +++ b/lib/line-config.c
> > @@ -381,18 +381,18 @@ static uint64_t make_kernel_flags(struct gpiod_line_settings *settings)
> > case GPIOD_LINE_EDGE_FALLING:
> > flags |= (GPIO_V2_LINE_FLAG_EDGE_FALLING |
> > GPIO_V2_LINE_FLAG_INPUT);
> > - flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
> > + flags &= ~GPIO_V2_LINE_FLAG_OUTPUT;
> > break;
> > case GPIOD_LINE_EDGE_RISING:
> > flags |= (GPIO_V2_LINE_FLAG_EDGE_RISING |
> > GPIO_V2_LINE_FLAG_INPUT);
> > - flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
> > + flags &= ~GPIO_V2_LINE_FLAG_OUTPUT;
> > break;
> > case GPIOD_LINE_EDGE_BOTH:
> > flags |= (GPIO_V2_LINE_FLAG_EDGE_FALLING |
> > GPIO_V2_LINE_FLAG_EDGE_RISING |
> > GPIO_V2_LINE_FLAG_INPUT);
> > - flags &= ~GPIOD_LINE_DIRECTION_OUTPUT;
> > + flags &= ~GPIO_V2_LINE_FLAG_OUTPUT;
> > break;
> > default:
> > break;
> > --
> > 2.30.2
> >
> >
>
> This does not apply on top of current master, could you please verify?
>
> Bart
Some weird whitespace mangling. Retrying a different way...
Thanks,
Anne Bezemer
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-01-03 19:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-02 14:52 [libgpiod][PATCH v2] core: fix deselection of output direction when edge detection is selected J.A. Bezemer
2024-01-02 18:27 ` Kent Gibson
2024-01-03 8:46 ` Bartosz Golaszewski
2024-01-03 19:17 ` J.A. Bezemer
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.