Re: [PATCH] eeprom: at24: Limit gpio calls to when wp_gpio is defined

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

 



pt., 5 lip 2019 o 19:31 Claus H. Stovgaard <cst@xxxxxxxxxxxx> napisał(a):
>
> Calling gpiod_set_value_cansleep with no GPIO driver associated result in
> the WARN_ON error from consumer.h. So change to only call
> gpiod_set_value_cansleep when wp_gpio is defined.
>
> Signed-off-by: Claus H. Stovgaard <cst@xxxxxxxxxxxx>
> ---
>  drivers/misc/eeprom/at24.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
> index 35bf247..d17e982 100644
> --- a/drivers/misc/eeprom/at24.c
> +++ b/drivers/misc/eeprom/at24.c
> @@ -458,12 +458,14 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count)
>          * from this host, but not from other I2C masters.
>          */
>         mutex_lock(&at24->lock);
> -       gpiod_set_value_cansleep(at24->wp_gpio, 0);
> +       if (at24->wp_gpio)
> +               gpiod_set_value_cansleep(at24->wp_gpio, 0);
>
>         while (count) {
>                 ret = at24_regmap_write(at24, buf, off, count);
>                 if (ret < 0) {
> -                       gpiod_set_value_cansleep(at24->wp_gpio, 1);
> +                       if (at24->wp_gpio)
> +                               gpiod_set_value_cansleep(at24->wp_gpio, 1);
>                         mutex_unlock(&at24->lock);
>                         pm_runtime_put(dev);
>                         return ret;
> @@ -473,7 +475,8 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count)
>                 count -= ret;
>         }
>
> -       gpiod_set_value_cansleep(at24->wp_gpio, 1);
> +       if (at24->wp_gpio)
> +               gpiod_set_value_cansleep(at24->wp_gpio, 1);
>         mutex_unlock(&at24->lock);
>
>         pm_runtime_put(dev);
> --
> 2.7.4
>

Hi Claus,

gpiod_set_value_cansleep() doesn't complain if the passed descriptor
is NULL - it just quietly returns. Could you give me some more info on
how you trigger this warning?

Bart




[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux