]> Git Repo - J-linux.git/commitdiff
gpio: sysfs: repair export returning -EPERM on 1st attempt
authorAlexander Sverdlin <[email protected]>
Thu, 7 Mar 2024 21:43:16 +0000 (22:43 +0100)
committerBartosz Golaszewski <[email protected]>
Fri, 8 Mar 2024 09:32:00 +0000 (10:32 +0100)
It would make sense to return -EPERM if the bit was already set (already
used), not if it was cleared. Before this fix pins can only be exported on
the 2nd attempt:

$ echo 522 > /sys/class/gpio/export
sh: write error: Operation not permitted
$ echo 522 > /sys/class/gpio/export

Fixes: 35b545332b80 ("gpio: remove gpio_lock")
Signed-off-by: Alexander Sverdlin <[email protected]>
Signed-off-by: Bartosz Golaszewski <[email protected]>
drivers/gpio/gpiolib-sysfs.c

index 67fc09a57f267bdc3c7257e7a75cfdc7f2315966..6853ecd98bcb8c5e4a8e3ebaa9448684b0057ad2 100644 (file)
@@ -593,7 +593,7 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change)
        if (!guard.gc)
                return -ENODEV;
 
-       if (!test_and_set_bit(FLAG_EXPORT, &desc->flags))
+       if (test_and_set_bit(FLAG_EXPORT, &desc->flags))
                return -EPERM;
 
        gdev = desc->gdev;
This page took 0.058185 seconds and 4 git commands to generate.