On Wed, 2025-02-19 at 09:38 +0100, Marek Szyprowski wrote: > Hi Bartosz, > > On 10.02.2025 11:51, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> > > > > As per the API contract - gpio_chip::get_direction() may fail and return > > a negative error number. However, we treat it as if it always returned 0 > > or 1. Check the return value of the callback and propagate the error > > number up the stack. > > > > Cc: stable@xxxxxxxxxxxxxxx > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> > > --- > > drivers/gpio/gpiolib.c | 44 +++++++++++++++++++++++++++++--------------- > > 1 file changed, 29 insertions(+), 15 deletions(-) > > > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > > index 679ed764cb14..5d3774dc748b 100644 > > --- a/drivers/gpio/gpiolib.c > > +++ b/drivers/gpio/gpiolib.c > > @@ -1057,8 +1057,11 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, > > desc->gdev = gdev; > > > > if (gc->get_direction && gpiochip_line_is_valid(gc, desc_index)) { > > - assign_bit(FLAG_IS_OUT, > > - &desc->flags, !gc->get_direction(gc, desc_index)); > > + ret = gc->get_direction(gc, desc_index); > > + if (ret < 0) > > + goto err_cleanup_desc_srcu; > > + > > + assign_bit(FLAG_IS_OUT, &desc->flags, !ret); > > } else { > > assign_bit(FLAG_IS_OUT, > > &desc->flags, !gc->direction_input); > > This change breaks bcm2835 pincontrol/gpio driver (and probably others) > in next-20250218. The problem is that some gpio lines are initially > configured as alternate function (i.e. uart) and .get_direction returns > -EINVAL for them, what in turn causes the whole gpio chip fail to > register. Here is the log with WARN_ON() added to line > drivers/pinctrl/bcm/pinctrl-bcm2835.c:350 from Raspberry Pi 4B: Same issue with STM32 pinctrl. I will send out shortly a patch, similar to https://lore.kernel.org/all/20250219102750.38519-1-brgl@xxxxxxxx/ Regards, Antonio