diff mbox series

gpio: rcar: Implement .get_direction() callback

Message ID 20180712091501.22344-1-geert+renesas@glider.be
State New
Headers show
Series gpio: rcar: Implement .get_direction() callback | expand

Commit Message

Geert Uytterhoeven July 12, 2018, 9:15 a.m. UTC
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(+)

Comments

Wolfram Sang July 12, 2018, 4:21 p.m. UTC | #1
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
Simon Horman July 13, 2018, 7:57 a.m. UTC | #2
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
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Linus Walleij July 13, 2018, 8:56 a.m. UTC | #3
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
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

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;