diff mbox

[RFT,v2,1/3] gpio: mpc8xxx: Fixup setting gpio direction output

Message ID 1456125772.27297.0.camel@ingics.com
State New
Headers show

Commit Message

Axel Lin Feb. 22, 2016, 7:22 a.m. UTC
For devtype with specific gpio_dir_out implementation, current code is
wrong because below code sets both gc->direction_output and
mpc8xxx_gc->direction_output to the same function.

gc->direction_output = devtype->gpio_dir_out ?: gc->direction_output;
mpc8xxx_gc->direction_output = gc->direction_output;

Set mpc8xxx_gc->direction_output = gc->direction_output first to fix it.
This way mpc8xxx_gc->direction_output actually calls the standard
bgpio_dir_out() to update register.

Fixes: commit 42178e2a1e42 ("drivers/gpio: Switch gpio-mpc8xxx to use gpio-generic")

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/gpio/gpio-mpc8xxx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Liu Gang March 2, 2016, 7:20 a.m. UTC | #1
On 2/22/2016 3:23 PM, Axel Lin wrote:
> For devtype with specific gpio_dir_out implementation, current code is
> wrong because below code sets both gc->direction_output and
> mpc8xxx_gc->direction_output to the same function.
>
> gc->direction_output = devtype->gpio_dir_out ?: gc->direction_output;
> mpc8xxx_gc->direction_output = gc->direction_output;
>
> Set mpc8xxx_gc->direction_output = gc->direction_output first to fix it.
> This way mpc8xxx_gc->direction_output actually calls the standard
> bgpio_dir_out() to update register.
>
> Fixes: commit 42178e2a1e42 ("drivers/gpio: Switch gpio-mpc8xxx to use gpio-generic")
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>  drivers/gpio/gpio-mpc8xxx.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
> index ecdb27a..d2472c5 100644
> --- a/drivers/gpio/gpio-mpc8xxx.c
> +++ b/drivers/gpio/gpio-mpc8xxx.c
> @@ -334,6 +334,7 @@ static int mpc8xxx_probe(struct platform_device *pdev)
>  
>  	mpc8xxx_gc->read_reg = gc->read_reg;
>  	mpc8xxx_gc->write_reg = gc->write_reg;
> +	mpc8xxx_gc->direction_output = gc->direction_output;
>  
>  	if (!devtype)
>  		devtype = &mpc8xxx_gpio_devtype_default;
> @@ -348,8 +349,6 @@ static int mpc8xxx_probe(struct platform_device *pdev)
>  	gc->get = devtype->gpio_get ?: gc->get;
>  	gc->to_irq = mpc8xxx_gpio_to_irq;
>  
> -	mpc8xxx_gc->direction_output = gc->direction_output;
> -
>  	ret = gpiochip_add_data(gc, mpc8xxx_gc);
>  	if (ret) {
>  		pr_err("%s: GPIO chip registration failed with status %d\n",
This is OK for me.

Liu Gang
--
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
Linus Walleij March 9, 2016, 3:42 a.m. UTC | #2
On Mon, Feb 22, 2016 at 2:22 PM, Axel Lin <axel.lin@ingics.com> wrote:

> For devtype with specific gpio_dir_out implementation, current code is
> wrong because below code sets both gc->direction_output and
> mpc8xxx_gc->direction_output to the same function.
>
> gc->direction_output = devtype->gpio_dir_out ?: gc->direction_output;
> mpc8xxx_gc->direction_output = gc->direction_output;
>
> Set mpc8xxx_gc->direction_output = gc->direction_output first to fix it.
> This way mpc8xxx_gc->direction_output actually calls the standard
> bgpio_dir_out() to update register.
>
> Fixes: commit 42178e2a1e42 ("drivers/gpio: Switch gpio-mpc8xxx to use gpio-generic")
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Patch applied.

Yours,
Linus Walleij
--
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
diff mbox

Patch

diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index ecdb27a..d2472c5 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -334,6 +334,7 @@  static int mpc8xxx_probe(struct platform_device *pdev)
 
 	mpc8xxx_gc->read_reg = gc->read_reg;
 	mpc8xxx_gc->write_reg = gc->write_reg;
+	mpc8xxx_gc->direction_output = gc->direction_output;
 
 	if (!devtype)
 		devtype = &mpc8xxx_gpio_devtype_default;
@@ -348,8 +349,6 @@  static int mpc8xxx_probe(struct platform_device *pdev)
 	gc->get = devtype->gpio_get ?: gc->get;
 	gc->to_irq = mpc8xxx_gpio_to_irq;
 
-	mpc8xxx_gc->direction_output = gc->direction_output;
-
 	ret = gpiochip_add_data(gc, mpc8xxx_gc);
 	if (ret) {
 		pr_err("%s: GPIO chip registration failed with status %d\n",