Skip to content

Commit 96fa9ec

Browse files
author
Bartosz Golaszewski
committed
gpiolib: don't bail out if get_direction() fails in gpiochip_add_data()
Since commit 9d846b1 ("gpiolib: check the return value of gpio_chip::get_direction()") we check the return value of the get_direction() callback as per its API contract. Some drivers have been observed to fail to register now as they may call get_direction() in gpiochip_add_data() in contexts where it has always silently failed. Until we audit all drivers, replace the bail-out to a kernel log warning. Fixes: 9d846b1 ("gpiolib: check the return value of gpio_chip::get_direction()") Reported-by: Mark Brown <broonie@kernel.org> Closes: https://lore.kernel.org/all/Z7VFB1nST6lbmBIo@finisterre.sirena.org.uk/ Reported-by: Marek Szyprowski <m.szyprowski@samsung.com> Closes: https://lore.kernel.org/all/dfe03f88-407e-4ef1-ad30-42db53bbd4e4@samsung.com/ Tested-by: Mark Brown <broonie@kernel.org> Reviewed-by: Mark Brown <broonie@kernel.org> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> Link: https://lore.kernel.org/r/20250219144356.258635-1-brgl@bgdev.pl Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent 81570d6 commit 96fa9ec

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/gpio/gpiolib.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,15 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
10591059
if (gc->get_direction && gpiochip_line_is_valid(gc, desc_index)) {
10601060
ret = gc->get_direction(gc, desc_index);
10611061
if (ret < 0)
1062-
goto err_cleanup_desc_srcu;
1062+
/*
1063+
* FIXME: Bail-out here once all GPIO drivers
1064+
* are updated to not return errors in
1065+
* situations that can be considered normal
1066+
* operation.
1067+
*/
1068+
dev_warn(&gdev->dev,
1069+
"%s: get_direction failed: %d\n",
1070+
__func__, ret);
10631071

10641072
assign_bit(FLAG_IS_OUT, &desc->flags, !ret);
10651073
} else {

0 commit comments

Comments
 (0)