Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [libgpiod][PATCH] core: remove buggy flags sanitization from line-config
@ 2024-01-04 13:50 Bartosz Golaszewski
  2024-01-04 14:07 ` Kent Gibson
  2024-01-05  8:58 ` Bartosz Golaszewski
  0 siblings, 2 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2024-01-04 13:50 UTC (permalink / raw)
  To: Linus Walleij, Kent Gibson; +Cc: linux-gpio, Bartosz Golaszewski, Anne Bezemer

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

We try to drop potentially set output flags from line config if edge
detection is enabled but we use the library enum instead of the one from
the uAPI. In any case, we should actually loudly complain if user tries
to use the output mode with edge-detection (like we do currently) so just
remove offending lines entirely.

Reported-by: Anne Bezemer <j.a.bezemer@opensourcepartners.nl>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 lib/line-config.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/lib/line-config.c b/lib/line-config.c
index 2749a2a..9302c1b 100644
--- a/lib/line-config.c
+++ b/lib/line-config.c
@@ -381,18 +381,15 @@ 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;
 		break;
 	case GPIOD_LINE_EDGE_RISING:
 		flags |= (GPIO_V2_LINE_FLAG_EDGE_RISING |
 			  GPIO_V2_LINE_FLAG_INPUT);
-		flags &= ~GPIOD_LINE_DIRECTION_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;
 		break;
 	default:
 		break;
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [libgpiod][PATCH] core: remove buggy flags sanitization from line-config
  2024-01-04 13:50 [libgpiod][PATCH] core: remove buggy flags sanitization from line-config Bartosz Golaszewski
@ 2024-01-04 14:07 ` Kent Gibson
  2024-01-04 20:19   ` J.A. Bezemer
  2024-01-05  8:58 ` Bartosz Golaszewski
  1 sibling, 1 reply; 4+ messages in thread
From: Kent Gibson @ 2024-01-04 14:07 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, linux-gpio, Bartosz Golaszewski, Anne Bezemer

On Thu, Jan 04, 2024 at 02:50:58PM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> We try to drop potentially set output flags from line config if edge
> detection is enabled but we use the library enum instead of the one from
> the uAPI. In any case, we should actually loudly complain if user tries
> to use the output mode with edge-detection (like we do currently) so just
> remove offending lines entirely.
>

I don't see any problem with that.
It also explains why we didn't pick it up earlier - it behaves as
expected and has no visible side effects, so this is just tidying up
dead code.

Reviewed-by: Kent Gibson <warthog618@gmail.com>

> Reported-by: Anne Bezemer <j.a.bezemer@opensourcepartners.nl>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>  lib/line-config.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/lib/line-config.c b/lib/line-config.c
> index 2749a2a..9302c1b 100644
> --- a/lib/line-config.c
> +++ b/lib/line-config.c
> @@ -381,18 +381,15 @@ 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;
>  		break;
>  	case GPIOD_LINE_EDGE_RISING:
>  		flags |= (GPIO_V2_LINE_FLAG_EDGE_RISING |
>  			  GPIO_V2_LINE_FLAG_INPUT);
> -		flags &= ~GPIOD_LINE_DIRECTION_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;
>  		break;
>  	default:
>  		break;
> --
> 2.40.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [libgpiod][PATCH] core: remove buggy flags sanitization from line-config
  2024-01-04 14:07 ` Kent Gibson
@ 2024-01-04 20:19   ` J.A. Bezemer
  0 siblings, 0 replies; 4+ messages in thread
From: J.A. Bezemer @ 2024-01-04 20:19 UTC (permalink / raw)
  To: Kent Gibson
  Cc: Bartosz Golaszewski, Linus Walleij, linux-gpio,
	Bartosz Golaszewski

On Thu, 4 Jan 2024, Kent Gibson wrote:
> On Thu, Jan 04, 2024 at 02:50:58PM +0100, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > We try to drop potentially set output flags from line config if edge
> > detection is enabled but we use the library enum instead of the one from
> > the uAPI. In any case, we should actually loudly complain if user tries
> > to use the output mode with edge-detection (like we do currently) so just
> > remove offending lines entirely.
> >
> 
> I don't see any problem with that.
> It also explains why we didn't pick it up earlier - it behaves as
> expected and has no visible side effects, so this is just tidying up
> dead code.
> 
> Reviewed-by: Kent Gibson <warthog618@gmail.com>

For the record, this is fine with me too.

Thanks,
Anne Bezemer

Reviewed-by: Anne Bezemer <j.a.bezemer@opensourcepartners.nl>

> > Reported-by: Anne Bezemer <j.a.bezemer@opensourcepartners.nl>
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > ---
> >  lib/line-config.c | 3 ---
> >  1 file changed, 3 deletions(-)
> >
> > diff --git a/lib/line-config.c b/lib/line-config.c
> > index 2749a2a..9302c1b 100644
> > --- a/lib/line-config.c
> > +++ b/lib/line-config.c
> > @@ -381,18 +381,15 @@ 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;
> >  		break;
> >  	case GPIOD_LINE_EDGE_RISING:
> >  		flags |= (GPIO_V2_LINE_FLAG_EDGE_RISING |
> >  			  GPIO_V2_LINE_FLAG_INPUT);
> > -		flags &= ~GPIOD_LINE_DIRECTION_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;
> >  		break;
> >  	default:
> >  		break;
> > --
> > 2.40.1
> >

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [libgpiod][PATCH] core: remove buggy flags sanitization from line-config
  2024-01-04 13:50 [libgpiod][PATCH] core: remove buggy flags sanitization from line-config Bartosz Golaszewski
  2024-01-04 14:07 ` Kent Gibson
@ 2024-01-05  8:58 ` Bartosz Golaszewski
  1 sibling, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2024-01-05  8:58 UTC (permalink / raw)
  To: Linus Walleij, Kent Gibson; +Cc: linux-gpio, Bartosz Golaszewski, Anne Bezemer

On Thu, Jan 4, 2024 at 2:51 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> We try to drop potentially set output flags from line config if edge
> detection is enabled but we use the library enum instead of the one from
> the uAPI. In any case, we should actually loudly complain if user tries
> to use the output mode with edge-detection (like we do currently) so just
> remove offending lines entirely.
>
> Reported-by: Anne Bezemer <j.a.bezemer@opensourcepartners.nl>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>  lib/line-config.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/lib/line-config.c b/lib/line-config.c
> index 2749a2a..9302c1b 100644
> --- a/lib/line-config.c
> +++ b/lib/line-config.c
> @@ -381,18 +381,15 @@ 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;
>                 break;
>         case GPIOD_LINE_EDGE_RISING:
>                 flags |= (GPIO_V2_LINE_FLAG_EDGE_RISING |
>                           GPIO_V2_LINE_FLAG_INPUT);
> -               flags &= ~GPIOD_LINE_DIRECTION_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;
>                 break;
>         default:
>                 break;
> --
> 2.40.1
>

Patch applied.

Bart

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-05  8:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-04 13:50 [libgpiod][PATCH] core: remove buggy flags sanitization from line-config Bartosz Golaszewski
2024-01-04 14:07 ` Kent Gibson
2024-01-04 20:19   ` J.A. Bezemer
2024-01-05  8:58 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox