gpio: syscon: do not use raw "set" callback in syscon_gpio_dir_out

Message ID 1504104641-8369-1-git-send-email-vladimir.murzin@arm.com
State New
Headers show
Series
  • gpio: syscon: do not use raw "set" callback in syscon_gpio_dir_out
Related show

Commit Message

Vladimir Murzin Aug. 30, 2017, 2:50 p.m.
"set" callback is optional and can be NULL, instead use chip->set
which always points at proper callback function.

Fixes 2c341d62eb4b ("gpio: syscon: add soc specific callback to assign output value")

Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
---
 drivers/gpio/gpio-syscon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Linus Walleij Sept. 21, 2017, 11:23 a.m. | #1
I really need Alexander Shiyan to look at this patch.

The way i percieve it, .set is NULL if the chip does not
support output.

We should print the right error messages and bail out
if the user is anyway trying to set a line like that.

Yours,
Linus Walleij

On Wed, Aug 30, 2017 at 4:50 PM, Vladimir Murzin
<vladimir.murzin@arm.com> wrote:

> "set" callback is optional and can be NULL, instead use chip->set
> which always points at proper callback function.
>
> Fixes 2c341d62eb4b ("gpio: syscon: add soc specific callback to assign output value")
>
> Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
> ---
>  drivers/gpio/gpio-syscon.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-syscon.c b/drivers/gpio/gpio-syscon.c
> index 537cec7..cf88a0b 100644
> --- a/drivers/gpio/gpio-syscon.c
> +++ b/drivers/gpio/gpio-syscon.c
> @@ -122,7 +122,7 @@ static int syscon_gpio_dir_out(struct gpio_chip *chip, unsigned offset, int val)
>                                    BIT(offs % SYSCON_REG_BITS));
>         }
>
> -       priv->data->set(chip, offset, val);
> +       chip->set(chip, offset, val);
>
>         return 0;
>  }
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexander Shiyan Sept. 21, 2017, 11:56 a.m. | #2
>Четверг, 21 сентября 2017, 14:23 +03:00 от Linus Walleij <linus.walleij@linaro.org>:
>
>I really need Alexander Shiyan to look at this patch.
>
>The way i percieve it, .set is NULL if the chip does not
>support output.
>
>We should print the right error messages and bail out
>if the user is anyway trying to set a line like that.

Hello.

Using "chip->set", instead of "priv->data->set", is more proper way on my opinion.
However, if the driver is not configured for output, the any errors should not occur in any case.

>On Wed, Aug 30, 2017 at 4:50 PM, Vladimir Murzin
>< vladimir.murzin@arm.com > wrote:
>
>> "set" callback is optional and can be NULL, instead use chip->set
>> which always points at proper callback function.
>>
>> Fixes 2c341d62eb4b ("gpio: syscon: add soc specific callback to assign output value")
>>
>> Signed-off-by: Vladimir Murzin < vladimir.murzin@arm.com >
>> ---
>>  drivers/gpio/gpio-syscon.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpio/gpio-syscon.c b/drivers/gpio/gpio-syscon.c
>> index 537cec7..cf88a0b 100644
>> --- a/drivers/gpio/gpio-syscon.c
>> +++ b/drivers/gpio/gpio-syscon.c
>> @@ -122,7 +122,7 @@ static int syscon_gpio_dir_out(struct gpio_chip *chip, unsigned offset, int val)
>>                                    BIT(offs % SYSCON_REG_BITS));
>>         }
>>
>> -       priv->data->set(chip, offset, val);
>> +       chip->set(chip, offset, val);
>>
>>         return 0;
>>  }

---

Patch

diff --git a/drivers/gpio/gpio-syscon.c b/drivers/gpio/gpio-syscon.c
index 537cec7..cf88a0b 100644
--- a/drivers/gpio/gpio-syscon.c
+++ b/drivers/gpio/gpio-syscon.c
@@ -122,7 +122,7 @@  static int syscon_gpio_dir_out(struct gpio_chip *chip, unsigned offset, int val)
 				   BIT(offs % SYSCON_REG_BITS));
 	}
 
-	priv->data->set(chip, offset, val);
+	chip->set(chip, offset, val);
 
 	return 0;
 }