Skip to content

Commit 8636f19

Browse files
sverdlinBartosz Golaszewski
authored andcommitted
gpio: sysfs: repair export returning -EPERM on 1st attempt
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>
1 parent 297dc37 commit 8636f19

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpio/gpiolib-sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ int gpiod_export(struct gpio_desc *desc, bool direction_may_change)
593593
if (!guard.gc)
594594
return -ENODEV;
595595

596-
if (!test_and_set_bit(FLAG_EXPORT, &desc->flags))
596+
if (test_and_set_bit(FLAG_EXPORT, &desc->flags))
597597
return -EPERM;
598598

599599
gdev = desc->gdev;

0 commit comments

Comments
 (0)