2018-01-14 21:07:46

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 0/3] tree-wide: don't use GPIOF_* with gpiod_get_direction

The documentation was wrong, gpiod_get_direction() returns 0/1 instead of the
GPIOF_* flags. The docs were fixed with commit 94fc73094abe47 ("gpio: correct
docs about return value of gpiod_get_direction"). Now, fix the users who got it
as wrong as I did when developing bus recovery for the R-Car I2C driver.

We get rid of two users of 'linux/gpio.h' this way :)

Only build tested due to no hardware.


Wolfram Sang (3):
extcon: int3496: don't use GPIOF_* with gpiod_get_direction
serial: mxs-auart: don't use GPIOF_* with gpiod_get_direction
backlight: pwm_bl: don't use GPIOF_* with gpiod_get_direction

drivers/extcon/extcon-intel-int3496.c | 4 ++--
drivers/tty/serial/mxs-auart.c | 3 +--
drivers/video/backlight/pwm_bl.c | 6 +++---
3 files changed, 6 insertions(+), 7 deletions(-)

--
2.11.0


2018-01-14 21:07:44

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 2/3] serial: mxs-auart: don't use GPIOF_* with gpiod_get_direction

The documentation was wrong, gpiod_get_direction() returns 0/1 instead
of the GPIOF_* flags. The docs were fixed with commit 94fc73094abe47
("gpio: correct docs about return value of gpiod_get_direction"). Now,
fix this user (until a better, system-wide solution is in place). This
also means we can drop the deprecated use of 'linux/gpio.h'. Yay!

Signed-off-by: Wolfram Sang <[email protected]>
---
Only build tested!

drivers/tty/serial/mxs-auart.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 5b470406bf9d67..079dc47aa142d8 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -40,7 +40,6 @@

#include <asm/cacheflush.h>

-#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/err.h>
#include <linux/irq.h>
@@ -1597,7 +1596,7 @@ static int mxs_auart_init_gpios(struct mxs_auart_port *s, struct device *dev)

for (i = 0; i < UART_GPIO_MAX; i++) {
gpiod = mctrl_gpio_to_gpiod(s->gpios, i);
- if (gpiod && (gpiod_get_direction(gpiod) == GPIOF_DIR_IN))
+ if (gpiod && (gpiod_get_direction(gpiod) == 1))
s->gpio_irq[i] = gpiod_to_irq(gpiod);
else
s->gpio_irq[i] = -EINVAL;
--
2.11.0

2018-01-14 21:07:43

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 1/3] extcon: int3496: don't use GPIOF_* with gpiod_get_direction

The documentation was wrong, gpiod_get_direction() returns 0/1 instead
of the GPIOF_* flags. The docs were fixed with commit 94fc73094abe47
("gpio: correct docs about return value of gpiod_get_direction"). Now,
fix this user (until a better, system-wide solution is in place). This
also means we can drop the deprecated use of 'linux/gpio.h'. Yay!

Signed-off-by: Wolfram Sang <[email protected]>
---
Only build tested!

drivers/extcon/extcon-intel-int3496.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/extcon/extcon-intel-int3496.c b/drivers/extcon/extcon-intel-int3496.c
index c8691b5a9cb00c..256a25e511671d 100644
--- a/drivers/extcon/extcon-intel-int3496.c
+++ b/drivers/extcon/extcon-intel-int3496.c
@@ -20,7 +20,7 @@

#include <linux/acpi.h>
#include <linux/extcon-provider.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/platform_device.h>
@@ -112,7 +112,7 @@ static int int3496_probe(struct platform_device *pdev)
ret = PTR_ERR(data->gpio_usb_id);
dev_err(dev, "can't request USB ID GPIO: %d\n", ret);
return ret;
- } else if (gpiod_get_direction(data->gpio_usb_id) != GPIOF_DIR_IN) {
+ } else if (gpiod_get_direction(data->gpio_usb_id) != 1) {
dev_warn(dev, FW_BUG "USB ID GPIO not in input mode, fixing\n");
gpiod_direction_input(data->gpio_usb_id);
}
--
2.11.0

2018-01-14 21:08:27

by Wolfram Sang

[permalink] [raw]
Subject: [PATCH 3/3] backlight: pwm_bl: don't use GPIOF_* with gpiod_get_direction

The documentation was wrong, gpiod_get_direction() returns 0/1 instead
of the GPIOF_* flags. The docs were fixed with commit 94fc73094abe47
("gpio: correct docs about return value of gpiod_get_direction"). Now,
fix this user (until a better, system-wide solution is in place).

Signed-off-by: Wolfram Sang <[email protected]>
---
Only build tested!

drivers/video/backlight/pwm_bl.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 1c2289ddd555a6..0fa7d2bd0e4811 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -301,14 +301,14 @@ static int pwm_backlight_probe(struct platform_device *pdev)

/*
* If the GPIO is not known to be already configured as output, that
- * is, if gpiod_get_direction returns either GPIOF_DIR_IN or -EINVAL,
- * change the direction to output and set the GPIO as active.
+ * is, if gpiod_get_direction returns either 1 or -EINVAL, change the
+ * direction to output and set the GPIO as active.
* Do not force the GPIO to active when it was already output as it
* could cause backlight flickering or we would enable the backlight too
* early. Leave the decision of the initial backlight state for later.
*/
if (pb->enable_gpio &&
- gpiod_get_direction(pb->enable_gpio) != GPIOF_DIR_OUT)
+ gpiod_get_direction(pb->enable_gpio) != 0)
gpiod_direction_output(pb->enable_gpio, 1);

pb->power_supply = devm_regulator_get(&pdev->dev, "power");
--
2.11.0

2018-01-15 10:13:30

by Daniel Thompson

[permalink] [raw]
Subject: Re: [PATCH 3/3] backlight: pwm_bl: don't use GPIOF_* with gpiod_get_direction



On 14/01/18 21:07, Wolfram Sang wrote:
> The documentation was wrong, gpiod_get_direction() returns 0/1 instead
> of the GPIOF_* flags. The docs were fixed with commit 94fc73094abe47
> ("gpio: correct docs about return value of gpiod_get_direction"). Now,
> fix this user (until a better, system-wide solution is in place).
>
> Signed-off-by: Wolfram Sang <[email protected]>

Acked-by: Daniel Thompson <[email protected]>


> ---
> Only build tested!
>
> drivers/video/backlight/pwm_bl.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> index 1c2289ddd555a6..0fa7d2bd0e4811 100644
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
> @@ -301,14 +301,14 @@ static int pwm_backlight_probe(struct platform_device *pdev)
>
> /*
> * If the GPIO is not known to be already configured as output, that
> - * is, if gpiod_get_direction returns either GPIOF_DIR_IN or -EINVAL,
> - * change the direction to output and set the GPIO as active.
> + * is, if gpiod_get_direction returns either 1 or -EINVAL, change the
> + * direction to output and set the GPIO as active.
> * Do not force the GPIO to active when it was already output as it
> * could cause backlight flickering or we would enable the backlight too
> * early. Leave the decision of the initial backlight state for later.
> */
> if (pb->enable_gpio &&
> - gpiod_get_direction(pb->enable_gpio) != GPIOF_DIR_OUT)
> + gpiod_get_direction(pb->enable_gpio) != 0)
> gpiod_direction_output(pb->enable_gpio, 1);
>
> pb->power_supply = devm_regulator_get(&pdev->dev, "power");
>

2018-04-16 09:14:06

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH 3/3] backlight: pwm_bl: don't use GPIOF_* with gpiod_get_direction

On Sun, 14 Jan 2018, Wolfram Sang wrote:

> The documentation was wrong, gpiod_get_direction() returns 0/1 instead
> of the GPIOF_* flags. The docs were fixed with commit 94fc73094abe47
> ("gpio: correct docs about return value of gpiod_get_direction"). Now,
> fix this user (until a better, system-wide solution is in place).
>
> Signed-off-by: Wolfram Sang <[email protected]>
> ---
> Only build tested!
>
> drivers/video/backlight/pwm_bl.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)

Applied with Daniel and Simon's Acks.

--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog