Skip to contentSkip to conversation

core: remove buggy flags sanitization from line-config

PATCH In review Bartosz Golaszewski 3 participants 4 messages Jan 4, 2024 – Jan 5, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index 2749a2a..9302c1b 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
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
---
 lib/line-config.c | 3 ---
 1 file changed, 3 deletions(-)
lib/line-config.c +0 -4
index 2749a2a..9302c1b 100644
@@ -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

Reviewed-by
#2 lore raw
Quoted 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.

For the record, this is fine with me too.

Thanks,
Anne Bezemer

Quoted 32 lines
Quoted 32 lines
---
 lib/line-config.c | 3 ---
 1 file changed, 3 deletions(-)
lib/line-config.c +0 -4
index 2749a2a..9302c1b 100644
@@ -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

#3 lore raw
In reply to Bartosz Golaszewski
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.

---
 lib/line-config.c | 3 ---
 1 file changed, 3 deletions(-)
lib/line-config.c +0 -4
index 2749a2a..9302c1b 100644
@@ -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