gpiolib: don't bail out if get_direction() fails in gpiochip_add_data()
PATCH 1/1 gpiolib: don't bail out if get_direction() fails in gpiochip_add_data()
From: Bartosz Golaszewski <[email protected]>
Since commit 9d846b1aebbe ("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.
--- drivers/gpio/gpiolib.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpio/gpiolib.c +9 -1
@@ -1060,7 +1060,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 {
Signature · 1 line
2.45.2
Quoted 10 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Since commit
9d846b1aebbe("gpiolib: check the return value ofgpio_chip::get_direction()") we check the return value of theget_direction()callback as per its API contract. Some drivers have been observed to fail to register now as they may callget_direction()ingpiochip_add_data()in contexts where it has always silently failed. Until we audit all drivers, replace the bail-out to a kernel log warning.
Quoted 6 lines
Fixes 9d846b1aebbe ("gpiolib: check the return value of gpio_chip::get_direction()")Reported-by Mark Brown <[email protected]>Reported-by Marek Szyprowski <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>
This fixes the issue observed on RPi boards without any changes to gpio/pinctrl driver.
Quoted 15 lines
--- drivers/gpio/gpiolib.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)drivers/gpio/gpiolib.c +2
-1@@ -1060,7 +1060,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
drivers/gpio/gpiolib.c int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, · line 1074
Quoted 10 lines
drivers/gpio/gpiolib.c +7
-0+* 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 {
Best regards
Signature · 2 lines
Marek Szyprowski, PhD Samsung R&D Institute Poland
Quoted 9 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Since commit
9d846b1aebbe("gpiolib: check the return value ofgpio_chip::get_direction()") we check the return value of theget_direction()callback as per its API contract. Some drivers have been observed to fail to register now as they may callget_direction()ingpiochip_add_data()in contexts where it has always silently failed. Until we audit all drivers, replace the bail-out to a kernel log warning.
For at least one of the affected boards:
Bartosz Golaszewski
AppliedFrom: Bartosz Golaszewski <[email protected]>
Quoted 9 lines · Bartosz Golaszewski
Since commit
9d846b1aebbe("gpiolib: check the return value ofgpio_chip::get_direction()") we check the return value of theget_direction()callback as per its API contract. Some drivers have been observed to fail to register now as they may callget_direction()ingpiochip_add_data()in contexts where it has always silently failed. Until we audit all drivers, replace the bail-out to a kernel log warning.[...]
Applied, thanks!
[1/1] gpiolib: don't bail out if get_direction() fails in gpiochip_add_data()
commit: 96fa9ec477ff60bed87e1441fd43e003179f3253
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>