core: remove buggy flags sanitization from line-config
Subsystems (2)
PATCH 1/1 core: remove buggy flags sanitization from line-config
From: Bartosz Golaszewski <[email protected]>
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.
--- lib/line-config.c | 3 --- 1 file changed, 3 deletions(-)
lib/line-config.c +0 -3
@@ -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 ;
Signature · 1 line
2.40.1
Quoted 8 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
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.
Quoted 32 lines
Reported-by Anne Bezemer <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>--- lib/line-config.c | 3 --- 1 file changed, 3 deletions(-)lib/line-config.c +0
-4@@ -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
J.A. Bezemer
Reviewed-byQuoted 10 lines · Kent Gibson
Quoted 8 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
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.
Quoted 6 lines
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 <[email protected]>
For the record, this is fine with me too.
Thanks,
Anne Bezemer
Quoted 32 lines
Quoted 32 lines
Reported-by Anne Bezemer <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>--- lib/line-config.c | 3 --- 1 file changed, 3 deletions(-)lib/line-config.c +0
-4@@ -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
Quoted 39 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
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 <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>--- lib/line-config.c | 3 --- 1 file changed, 3 deletions(-)lib/line-config.c +0
-4@@ -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 ; --
Quoted 2 lines
2.40.1
Patch applied.
Bart