Skip to content

Commit

Permalink
gpiolib: don't bail out if get_direction() fails in gpiochip_add_data()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Closes: https://lore.kernel.org/all/[email protected]/
Reported-by: Marek Szyprowski <[email protected]>
Closes: https://lore.kernel.org/all/[email protected]/
Tested-by: Mark Brown <[email protected]>
Reviewed-by: Mark Brown <[email protected]>
Tested-by: Marek Szyprowski <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Bartosz Golaszewski <[email protected]>
  • Loading branch information
Bartosz Golaszewski committed Feb 20, 2025
1 parent 81570d6 commit 96fa9ec
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,15 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
if (gc->get_direction && gpiochip_line_is_valid(gc, desc_index)) {
ret = gc->get_direction(gc, desc_index);
if (ret < 0)
goto err_cleanup_desc_srcu;
/*
* FIXME: Bail-out here once all GPIO drivers
* are updated to not return errors in
* situations that can be considered normal
* operation.
*/
dev_warn(&gdev->dev,
"%s: get_direction failed: %d\n",
__func__, ret);

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

0 comments on commit 96fa9ec

Please sign in to comment.