Skip to contentSkip to conversation

gpio: moxart: Avoid forward declaration

PATCH In review Axel Lin 4 participants 8 messages Mar 25, 2014 – Apr 10, 2014 GPIO

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH v3 1/2 gpio: moxart: Avoid forward declaration

Slightly adjust the code to avoid forward declaration as we need to call moxart_gpio_set() in moxart_gpio_direction_output() to properly set the output state.

---
 drivers/gpio/gpio-moxart.c | 39 +++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 20 deletions(-)
drivers/gpio/gpio-moxart.c +19 -20
index 2af9900..a19a14d 100644
@@ -48,25 +48,6 @@ static void moxart_gpio_free(struct gpio_chip *chip, unsigned offset)
 	pinctrl_free_gpio(offset);
 }
 
-static int moxart_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
-{
-	struct moxart_gpio_chip *gc = to_moxart_gpio(chip);
-	void __iomem *ioaddr = gc->base + GPIO_PIN_DIRECTION;
-
-	writel(readl(ioaddr) & ~BIT(offset), ioaddr);
-	return 0;
-}
-
-static int moxart_gpio_direction_output(struct gpio_chip *chip,
-					unsigned offset, int value)
-{
-	struct moxart_gpio_chip *gc = to_moxart_gpio(chip);
-	void __iomem *ioaddr = gc->base + GPIO_PIN_DIRECTION;
-
-	writel(readl(ioaddr) | BIT(offset), ioaddr);
-	return 0;
-}
-
 static void moxart_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 {
 	struct moxart_gpio_chip *gc = to_moxart_gpio(chip);
@@ -78,7 +59,6 @@ static void moxart_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 	else
 		reg = reg & ~BIT(offset);
 
-
 	writel(reg, ioaddr);
 }
 
@@ -93,6 +73,25 @@ static int moxart_gpio_get(struct gpio_chip *chip, unsigned offset)
 		return !!(readl(gc->base + GPIO_DATA_IN) & BIT(offset));
 }
 
+static int moxart_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
+{
+	struct moxart_gpio_chip *gc = to_moxart_gpio(chip);
+	void __iomem *ioaddr = gc->base + GPIO_PIN_DIRECTION;
+
+	writel(readl(ioaddr) & ~BIT(offset), ioaddr);
+	return 0;
+}
+
+static int moxart_gpio_direction_output(struct gpio_chip *chip,
+					unsigned offset, int value)
+{
+	struct moxart_gpio_chip *gc = to_moxart_gpio(chip);
+	void __iomem *ioaddr = gc->base + GPIO_PIN_DIRECTION;
+
+	writel(readl(ioaddr) | BIT(offset), ioaddr);
+	return 0;
+}
+
 static struct gpio_chip moxart_template_chip = {
 	.label			= "moxart-gpio",
 	.request		= moxart_gpio_request,
Signature · 1 line
1.8.3.2
author
#1 lore raw

PATCH v3 2/2 gpio: moxart: Actually set output state in moxart_gpio_direction_output()

moxart_gpio_direction_output() ignored the state passed into it. Fix it.

---
 drivers/gpio/gpio-moxart.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpio/gpio-moxart.c +1 -0
index a19a14d..ccd4570 100644
@@ -88,6 +88,7 @@ static int moxart_gpio_direction_output(struct gpio_chip *chip,
 	struct moxart_gpio_chip *gc = to_moxart_gpio(chip);
 	void __iomem *ioaddr = gc->base + GPIO_PIN_DIRECTION;
 
+	moxart_gpio_set(chip, offset, value);
 	writel(readl(ioaddr) | BIT(offset), ioaddr);
 	return 0;
 }
Signature · 1 line
1.8.3.2
#3 lore raw

Re: [PATCH v3 2/2] gpio: moxart: Actually set output state in moxart_gpio_direction_output()

In reply to Axel Lin
Quoted 3 lines · Axel Lin

moxart_gpio_direction_output() ignored the state passed into it. Fix it.

Patch applied unless the moxart people start complaining.

Yours,
Linus Walleij

Tested-by on v3 2/2
#4 lore raw

Re: [PATCH v3 2/2] gpio: moxart: Actually set output state in moxart_gpio_direction_output()

In reply to Axel Lin

Thanks !

Verified by buzzing the buzzer and writing RTC (next-20140403):

echo 24 > /sys/class/gpio/export echo out > /sys/class/gpio/gpio24/direction echo 1 > /sys/class/gpio/gpio24/value echo 0 > /sys/class/gpio/gpio24/value

date +%Y%m%d%h%m -s "201001202323" hwclock -w
reboot
..

[    2.420000] moxart-rtc rtc.0: setting system clock to 2010-01-20

22:23:31 UTC (1264026211)
..
date +%Y%m%d%h%m -s "201212181553" hwclock -w
reboot
..

[    2.410000] moxart-rtc rtc.0: setting system clock to 2012-12-18

14:53:29 UTC (1355842409)

#5 lore raw

Re: [PATCH v3 2/2] gpio: moxart: Actually set output state in moxart_gpio_direction_output()

Quoted 1 line · Jonas Jensen

Verified by buzzing the buzzer and writing RTC (next-20140403):

(...)

Quoted 1 line

This patch is already upstream in Torvalds' tree, but thanks anyway!

Yours,
Linus Walleij

#7 lore raw
In reply to Axel Lin
Quoted 5 lines · Axel Lin

Slightly adjust the code to avoid forward declaration as we need to call moxart_gpio_set() in moxart_gpio_direction_output() to properly set the output state.

Nice cleanup, patch applied with Alexandre's review tag.

Yours,
Linus Walleij