diff mbox series

[RFT] gpio: sama5d2-piobu: Set proper output level for direction_output

Message ID 20181231095256.14814-1-axel.lin@ingics.com (mailing list archive)
State Mainlined, archived
Commit e4889362e0389e95970d28707599aa8e08c35b51
Headers show
Series [RFT] gpio: sama5d2-piobu: Set proper output level for direction_output | expand

Commit Message

Axel Lin Dec. 31, 2018, 9:52 a.m. UTC
Set proper output level base on the argument of direction_output.
Also remove sama5d2_piobu_set_direction() as there is only one caller
now.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
Hi Andrei,
I don't have this h/w, so please test if this patch works.

BTW, I think this change is better than just adding 
sama5d2_piobu_set(chip, pin, value); call in sama5d2_piobu_direction_output
becasue only write register once for setting direction_output.

Thanks,
Axel

 drivers/gpio/gpio-sama5d2-piobu.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

Comments

Linus Walleij Jan. 11, 2019, 9:35 a.m. UTC | #1
On Mon, Dec 31, 2018 at 10:53 AM Axel Lin <axel.lin@ingics.com> wrote:

> Set proper output level base on the argument of direction_output.
> Also remove sama5d2_piobu_set_direction() as there is only one caller
> now.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Patch tentatively applied as non-critical fix (for v5.1) unless
Andrei has concerns.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-sama5d2-piobu.c b/drivers/gpio/gpio-sama5d2-piobu.c
index 03a000659fa1..7d718557092e 100644
--- a/drivers/gpio/gpio-sama5d2-piobu.c
+++ b/drivers/gpio/gpio-sama5d2-piobu.c
@@ -108,16 +108,6 @@  static int sama5d2_piobu_read_value(struct gpio_chip *chip, unsigned int pin,
 	return val & mask;
 }
 
-/**
- * sama5d2_piobu_set_direction() - mark pin as input or output
- */
-static int sama5d2_piobu_set_direction(struct gpio_chip *chip,
-				       unsigned int direction,
-				       unsigned int pin)
-{
-	return sama5d2_piobu_write_value(chip, pin, PIOBU_DIRECTION, direction);
-}
-
 /**
  * sama5d2_piobu_get_direction() - gpiochip get_direction
  */
@@ -138,7 +128,7 @@  static int sama5d2_piobu_get_direction(struct gpio_chip *chip,
 static int sama5d2_piobu_direction_input(struct gpio_chip *chip,
 					 unsigned int pin)
 {
-	return sama5d2_piobu_set_direction(chip, PIOBU_IN, pin);
+	return sama5d2_piobu_write_value(chip, pin, PIOBU_DIRECTION, PIOBU_IN);
 }
 
 /**
@@ -147,7 +137,13 @@  static int sama5d2_piobu_direction_input(struct gpio_chip *chip,
 static int sama5d2_piobu_direction_output(struct gpio_chip *chip,
 					  unsigned int pin, int value)
 {
-	return sama5d2_piobu_set_direction(chip, PIOBU_OUT, pin);
+	unsigned int val = PIOBU_OUT;
+
+	if (value)
+		val |= PIOBU_HIGH;
+
+	return sama5d2_piobu_write_value(chip, pin, PIOBU_DIRECTION | PIOBU_SOD,
+					 val);
 }
 
 /**