Browse Source

gpio: mpc8xxx: Fixup setting gpio direction output

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>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Axel Lin 9 years ago
parent
commit
fa4007ca06
1 changed files with 1 additions and 2 deletions
  1. 1 2
      drivers/gpio/gpio-mpc8xxx.c

+ 1 - 2
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->read_reg = gc->read_reg;
 	mpc8xxx_gc->write_reg = gc->write_reg;
 	mpc8xxx_gc->write_reg = gc->write_reg;
+	mpc8xxx_gc->direction_output = gc->direction_output;
 
 
 	if (!devtype)
 	if (!devtype)
 		devtype = &mpc8xxx_gpio_devtype_default;
 		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->get = devtype->gpio_get ?: gc->get;
 	gc->to_irq = mpc8xxx_gpio_to_irq;
 	gc->to_irq = mpc8xxx_gpio_to_irq;
 
 
-	mpc8xxx_gc->direction_output = gc->direction_output;
-
 	ret = gpiochip_add_data(gc, mpc8xxx_gc);
 	ret = gpiochip_add_data(gc, mpc8xxx_gc);
 	if (ret) {
 	if (ret) {
 		pr_err("%s: GPIO chip registration failed with status %d\n",
 		pr_err("%s: GPIO chip registration failed with status %d\n",