Re: [PATCH v1] gpiolib: Respect error code of ->get_direction()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2018-07-03 at 03:38 +0300, Andy Shevchenko wrote:
> In case we try to lock GPIO pin as IRQ when something going wrong
> we print a misleading message.
> 
> Correct this by checking an error code from ->get_direction() in
> gpiochip_lock_as_irq() and printing a corresponding message.
> 

> Note, this doesn't change overall behavior because error code used to
> be recognized as direction output which anyway led to an abortion of
> request.

This paragraph is completely wrong, sorry.
The dir != 0 means input.

Thus it does change behaviour to bail out if we can't get direction.
This needs to be thought of.

> 
> Fixes: 9c10280d85c1 ("gpio: flush direction status in 
> gpiochip_lock_as_irq()")

Certainly it doesn't fix anything for now.

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> Cc: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx>
> ---
>  drivers/gpio/gpiolib.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index c6f77e806cb8..0ff89b3f354b 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -3264,6 +3264,12 @@ int gpiochip_lock_as_irq(struct gpio_chip
> *chip, unsigned int offset)
>  	if (!chip->can_sleep && chip->get_direction) {
>  		int dir = chip->get_direction(chip, offset);
>  
> +		if (dir < 0) {
> +			chip_err(chip, "%s: cannot get GPIO
> direction\n",
> +				 __func__);
> +			return dir;
> +		}
> +
>  		if (dir)
>  			clear_bit(FLAG_IS_OUT, &desc->flags);
>  		else

-- 
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Intel Finland Oy
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux