[v2] pinctrl: rza2: Include the appropriate headers
diff mbox series

Message ID 20190820132548.4012-1-linus.walleij@linaro.org
State New
Headers show
Series
  • [v2] pinctrl: rza2: Include the appropriate headers
Related show

Commit Message

Linus Walleij Aug. 20, 2019, 1:25 p.m. UTC
This driver is implementing a GPIO driver so include
<linux/gpio/driver.h> and not the legacy API <linux/gpio.h>.
When testing it turns out it also relies on implicit
inclusion of <linux/io.h> (readw etc) so make sure to
include that as well.

The GPIOF_* flags used in the driver is not for driver use,
these are consumer flags. Replace these with literal 0/1.

Cc: Chris Brandt <chris.brandt@renesas.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Remove the use of GPIOF_* consumer flags in the driver.

Geert: assuming you will pick this up if you're happy
with it.
---
 drivers/pinctrl/pinctrl-rza2.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

Geert Uytterhoeven Aug. 20, 2019, 1:37 p.m. UTC | #1
Hi Linus,

On Tue, Aug 20, 2019 at 3:25 PM Linus Walleij <linus.walleij@linaro.org> wrote:
> This driver is implementing a GPIO driver so include
> <linux/gpio/driver.h> and not the legacy API <linux/gpio.h>.
> When testing it turns out it also relies on implicit
> inclusion of <linux/io.h> (readw etc) so make sure to
> include that as well.
>
> The GPIOF_* flags used in the driver is not for driver use,
> these are consumer flags. Replace these with literal 0/1.

Perhaps this should be extracted into a separate patch?

> Cc: Chris Brandt <chris.brandt@renesas.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> ChangeLog v1->v2:
> - Remove the use of GPIOF_* consumer flags in the driver.

Thanks for the update!

> --- a/drivers/pinctrl/pinctrl-rza2.c
> +++ b/drivers/pinctrl/pinctrl-rza2.c

> @@ -145,7 +146,7 @@ static int rza2_chip_get_direction(struct gpio_chip *chip, unsigned int offset)
>          */
>         rza2_pin_to_gpio(priv->base, offset, GPIOF_DIR_IN);

Oops:

    drivers/pinctrl/pinctrl-rza2.c: In function ‘rza2_chip_get_direction’:
    drivers/pinctrl/pinctrl-rza2.c:147:39: error: ‘GPIOF_DIR_IN’
undeclared (first use in this function); did you mean ‘_IOC_DIRBITS’?

What happened to your arm cross-compiler? ;-)

Gr{oetje,eeting}s,

                        Geert

Patch
diff mbox series

diff --git a/drivers/pinctrl/pinctrl-rza2.c b/drivers/pinctrl/pinctrl-rza2.c
index 5b951c7422cc..ecb5d7ee5078 100644
--- a/drivers/pinctrl/pinctrl-rza2.c
+++ b/drivers/pinctrl/pinctrl-rza2.c
@@ -11,7 +11,8 @@ 
  */
 
 #include <linux/bitops.h>
-#include <linux/gpio.h>
+#include <linux/gpio/driver.h>
+#include <linux/io.h>
 #include <linux/module.h>
 #include <linux/of_device.h>
 #include <linux/pinctrl/pinmux.h>
@@ -115,7 +116,7 @@  static void rza2_pin_to_gpio(void __iomem *pfc_base, unsigned int offset,
 	mask16 = RZA2_PDR_MASK << (pin * 2);
 	reg16 &= ~mask16;
 
-	if (dir == GPIOF_DIR_IN)
+	if (dir)
 		reg16 |= RZA2_PDR_INPUT << (pin * 2);	/* pin as input */
 	else
 		reg16 |= RZA2_PDR_OUTPUT << (pin * 2);	/* pin as output */
@@ -134,10 +135,10 @@  static int rza2_chip_get_direction(struct gpio_chip *chip, unsigned int offset)
 	reg16 = (reg16 >> (pin * 2)) & RZA2_PDR_MASK;
 
 	if (reg16 == RZA2_PDR_OUTPUT)
-		return GPIOF_DIR_OUT;
+		return 0;
 
 	if (reg16 == RZA2_PDR_INPUT)
-		return GPIOF_DIR_IN;
+		return 1;
 
 	/*
 	 * This GPIO controller has a default Hi-Z state that is not input or
@@ -145,7 +146,7 @@  static int rza2_chip_get_direction(struct gpio_chip *chip, unsigned int offset)
 	 */
 	rza2_pin_to_gpio(priv->base, offset, GPIOF_DIR_IN);
 
-	return GPIOF_DIR_IN;
+	return 1;
 }
 
 static int rza2_chip_direction_input(struct gpio_chip *chip,
@@ -153,7 +154,7 @@  static int rza2_chip_direction_input(struct gpio_chip *chip,
 {
 	struct rza2_pinctrl_priv *priv = gpiochip_get_data(chip);
 
-	rza2_pin_to_gpio(priv->base, offset, GPIOF_DIR_IN);
+	rza2_pin_to_gpio(priv->base, offset, 1);
 
 	return 0;
 }
@@ -191,7 +192,7 @@  static int rza2_chip_direction_output(struct gpio_chip *chip,
 	struct rza2_pinctrl_priv *priv = gpiochip_get_data(chip);
 
 	rza2_chip_set(chip, offset, val);
-	rza2_pin_to_gpio(priv->base, offset, GPIOF_DIR_OUT);
+	rza2_pin_to_gpio(priv->base, offset, 0);
 
 	return 0;
 }