Skip to contentSkip to conversation

gpio: cdev: don't report GPIOs requested as interrupts as used

PATCH Applied Bartosz Golaszewski 3 participants 5 messages Oct 31, 2024 – Nov 4, 2024

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

PATCH 1/1 gpio: cdev: don't report GPIOs requested as interrupts as used

From: Bartosz Golaszewski <[email protected]>

GPIOs used as shared irqs can still be requested by user-space (or kernel drivers for that matter) yet we report them as used over the chardev ABI. Drop the test for FLAG_USED_AS_IRQ from gpio_desc_to_lineinfo().

---
 drivers/gpio/gpiolib-cdev.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpio/gpiolib-cdev.c +0 -1
index 0ec162b0ea04..629e9372fd57 100644
@@ -2275,7 +2275,6 @@ static void gpio_desc_to_lineinfo(struct gpio_desc *desc,
 	 */
 	if (test_bit(FLAG_REQUESTED, &dflags) ||
 	    test_bit(FLAG_IS_HOGGED, &dflags) ||
-	    test_bit(FLAG_USED_AS_IRQ, &dflags) ||
 	    test_bit(FLAG_EXPORT, &dflags) ||
 	    test_bit(FLAG_SYSFS, &dflags) ||
 	    !gpiochip_line_is_valid(guard.gc, info->offset)) {
Signature · 1 line
2.45.2
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

GPIOs used as shared irqs can still be requested by user-space (or kernel drivers for that matter) yet we report them as used over the chardev ABI. Drop the test for FLAG_USED_AS_IRQ from gpio_desc_to_lineinfo().

Quoted 19 lines
---
 drivers/gpio/gpiolib-cdev.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpio/gpiolib-cdev.c +0 -2
index 0ec162b0ea04..629e9372fd57 100644
@@ -2275,7 +2275,6 @@ static void gpio_desc_to_lineinfo(struct gpio_desc *desc,
 	 */
 	if (test_bit(FLAG_REQUESTED, &dflags) ||
 	    test_bit(FLAG_IS_HOGGED, &dflags) ||
-	    test_bit(FLAG_USED_AS_IRQ, &dflags) ||
 	    test_bit(FLAG_EXPORT, &dflags) ||
 	    test_bit(FLAG_SYSFS, &dflags) ||
 	    !gpiochip_line_is_valid(guard.gc, info->offset)) {
--

2.45.2

Reviewed-by on v1 1/1
#2 lore raw
In reply to Bartosz Golaszewski
Quoted 8 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

GPIOs used as shared irqs can still be requested by user-space (or kernel drivers for that matter) yet we report them as used over the chardev ABI. Drop the test for FLAG_USED_AS_IRQ from gpio_desc_to_lineinfo().

I think at the time this was added to not let userspace meddle with such GPIO lines since they were used for "something" in the kernel. (Userspace as second-class citizen.)

But I guess this is fine:

Yours,
Linus Walleij

#3 lore raw
Quoted 10 lines · Linus Walleij
Quoted 7 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

GPIOs used as shared irqs can still be requested by user-space (or kernel drivers for that matter) yet we report them as used over the chardev ABI. Drop the test for FLAG_USED_AS_IRQ from gpio_desc_to_lineinfo().

Quoted 6 lines
Quoted 1 line

I think at the time this was added to not let userspace meddle with such GPIO lines since they were used for "something" in the kernel. (Userspace as second-class citizen.)

Well, it wouldn't prohibit it. It would just report it misleadingly. Since we'll guard the fixed input direction, I think we should be fine.

Bartosz

Quoted 5 lines

But I guess this is fine:

Yours,
Linus Walleij

author Applied
#4 lore raw
In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Quoted 6 lines · Bartosz Golaszewski

GPIOs used as shared irqs can still be requested by user-space (or kernel drivers for that matter) yet we report them as used over the chardev ABI. Drop the test for FLAG_USED_AS_IRQ from gpio_desc_to_lineinfo().

Applied, thanks!

[1/1] gpio: cdev: don't report GPIOs requested as interrupts as used

      commit: dae01ec714fbbf3a71947668cb61cee4cc320647

Best regards,

Signature · 1 line
Bartosz Golaszewski <[email protected]>