* [PATCH] gpio: rcar: Implement .get_direction() callback
@ 2018-07-12 9:15 Geert Uytterhoeven
2018-07-12 16:21 ` Wolfram Sang
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2018-07-12 9:15 UTC (permalink / raw)
To: Linus Walleij
Cc: Wolfram Sang, linux-gpio, linux-renesas-soc, Geert Uytterhoeven
Allow gpiolib to read back the current I/O direction configuration by
implementing the .get_direction() callback.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/gpio/gpio-rcar.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 4d2cc6d32184f390..ec04752b6bd25fb6 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -278,6 +278,13 @@ static void gpio_rcar_free(struct gpio_chip *chip, unsigned offset)
pm_runtime_put(&p->pdev->dev);
}
+static int gpio_rcar_get_direction(struct gpio_chip *chip, unsigned int offset)
+{
+ struct gpio_rcar_priv *p = gpiochip_get_data(chip);
+
+ return !(gpio_rcar_read(p, INOUTSEL) & BIT(offset));
+}
+
static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned offset)
{
gpio_rcar_config_general_input_output_mode(chip, offset, false);
@@ -461,6 +468,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
gpio_chip = &p->gpio_chip;
gpio_chip->request = gpio_rcar_request;
gpio_chip->free = gpio_rcar_free;
+ gpio_chip->get_direction = gpio_rcar_get_direction;
gpio_chip->direction_input = gpio_rcar_direction_input;
gpio_chip->get = gpio_rcar_get;
gpio_chip->direction_output = gpio_rcar_direction_output;
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: rcar: Implement .get_direction() callback
2018-07-12 9:15 [PATCH] gpio: rcar: Implement .get_direction() callback Geert Uytterhoeven
@ 2018-07-12 16:21 ` Wolfram Sang
2018-07-13 7:57 ` Simon Horman
2018-07-13 8:56 ` Linus Walleij
2 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2018-07-12 16:21 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Linus Walleij, Wolfram Sang, linux-gpio, linux-renesas-soc
[-- Attachment #1: Type: text/plain, Size: 616 bytes --]
On Thu, Jul 12, 2018 at 11:15:01AM +0200, Geert Uytterhoeven wrote:
> Allow gpiolib to read back the current I/O direction configuration by
> implementing the .get_direction() callback.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
So, despite it didn't help solving my original case because of an
unrelated issue, I verified that this code works:
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
I'd still think it is better to have this code than to not have it.
Thanks Geert!
Regards,
Wolfram
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: rcar: Implement .get_direction() callback
2018-07-12 9:15 [PATCH] gpio: rcar: Implement .get_direction() callback Geert Uytterhoeven
2018-07-12 16:21 ` Wolfram Sang
@ 2018-07-13 7:57 ` Simon Horman
2018-07-13 8:56 ` Linus Walleij
2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2018-07-13 7:57 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Linus Walleij, Wolfram Sang, linux-gpio, linux-renesas-soc
On Thu, Jul 12, 2018 at 11:15:01AM +0200, Geert Uytterhoeven wrote:
> Allow gpiolib to read back the current I/O direction configuration by
> implementing the .get_direction() callback.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
> ---
> drivers/gpio/gpio-rcar.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
> index 4d2cc6d32184f390..ec04752b6bd25fb6 100644
> --- a/drivers/gpio/gpio-rcar.c
> +++ b/drivers/gpio/gpio-rcar.c
> @@ -278,6 +278,13 @@ static void gpio_rcar_free(struct gpio_chip *chip, unsigned offset)
> pm_runtime_put(&p->pdev->dev);
> }
>
> +static int gpio_rcar_get_direction(struct gpio_chip *chip, unsigned int offset)
> +{
> + struct gpio_rcar_priv *p = gpiochip_get_data(chip);
> +
> + return !(gpio_rcar_read(p, INOUTSEL) & BIT(offset));
> +}
> +
> static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned offset)
> {
> gpio_rcar_config_general_input_output_mode(chip, offset, false);
> @@ -461,6 +468,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
> gpio_chip = &p->gpio_chip;
> gpio_chip->request = gpio_rcar_request;
> gpio_chip->free = gpio_rcar_free;
> + gpio_chip->get_direction = gpio_rcar_get_direction;
> gpio_chip->direction_input = gpio_rcar_direction_input;
> gpio_chip->get = gpio_rcar_get;
> gpio_chip->direction_output = gpio_rcar_direction_output;
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gpio: rcar: Implement .get_direction() callback
2018-07-12 9:15 [PATCH] gpio: rcar: Implement .get_direction() callback Geert Uytterhoeven
2018-07-12 16:21 ` Wolfram Sang
2018-07-13 7:57 ` Simon Horman
@ 2018-07-13 8:56 ` Linus Walleij
2 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2018-07-13 8:56 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Wolfram Sang, open list:GPIO SUBSYSTEM, Linux-Renesas
On Thu, Jul 12, 2018 at 11:31 AM Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> Allow gpiolib to read back the current I/O direction configuration by
> implementing the .get_direction() callback.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Patch applied with the tags!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-13 9:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-12 9:15 [PATCH] gpio: rcar: Implement .get_direction() callback Geert Uytterhoeven
2018-07-12 16:21 ` Wolfram Sang
2018-07-13 7:57 ` Simon Horman
2018-07-13 8:56 ` Linus Walleij
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.