Skip to content

Commit

Permalink
gpio: sysfs: repair export returning -EPERM on 1st attempt
Browse files Browse the repository at this point in the history
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: 35b5453 ("gpio: remove gpio_lock")
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
  • Loading branch information
Alexander Sverdlin authored and Bartosz Golaszewski committed Mar 8, 2024
1 parent 297dc37 commit 8636f19
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/gpio/gpiolib-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8636f19

Please sign in to comment.