mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] gpio: stp-xway: Implement get callback
@ 2018-06-28 19:57 Mathias Kresin
  2018-07-02 13:22 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Mathias Kresin @ 2018-06-28 19:57 UTC (permalink / raw)
  To: linus.walleij, john, linux-gpio, linux-kernel; +Cc: martin.blumenstingl

Add an implementation to get the current GPIO state.

The callback is used by the leds-gpio driver for example, in case the
current LED/GPIO state should be kept during driver load.

Signed-off-by: Mathias Kresin <dev@kresin.me>
---
 drivers/gpio/gpio-stp-xway.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/gpio/gpio-stp-xway.c b/drivers/gpio/gpio-stp-xway.c
index c07385b..63c708c 100644
--- a/drivers/gpio/gpio-stp-xway.c
+++ b/drivers/gpio/gpio-stp-xway.c
@@ -91,6 +91,20 @@ struct xway_stp {
 };
 
 /**
+ * xway_stp_get() - gpio_chip->get - get gpios.
+ * @gc:     Pointer to gpio_chip device structure.
+ * @gpio:   GPIO signal number.
+ *
+ * Gets the shadow value.
+ */
+static int xway_stp_get(struct gpio_chip *gc, unsigned int gpio)
+{
+	struct xway_stp *chip = gpiochip_get_data(gc);
+
+	return (xway_stp_r32(chip->virt, XWAY_STP_CPU0) & BIT(gpio));
+}
+
+/**
  * xway_stp_set() - gpio_chip->set - set gpios.
  * @gc:     Pointer to gpio_chip device structure.
  * @gpio:   GPIO signal number.
@@ -215,6 +229,7 @@ static int xway_stp_probe(struct platform_device *pdev)
 	chip->gc.parent = &pdev->dev;
 	chip->gc.label = "stp-xway";
 	chip->gc.direction_output = xway_stp_dir_out;
+	chip->gc.get = xway_stp_get;
 	chip->gc.set = xway_stp_set;
 	chip->gc.request = xway_stp_request;
 	chip->gc.base = -1;
-- 
2.7.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gpio: stp-xway: Implement get callback
  2018-06-28 19:57 [PATCH] gpio: stp-xway: Implement get callback Mathias Kresin
@ 2018-07-02 13:22 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2018-07-02 13:22 UTC (permalink / raw)
  To: dev
  Cc: John Crispin, open list:GPIO SUBSYSTEM, linux-kernel,
	Martin Blumenstingl

On Thu, Jun 28, 2018 at 10:02 PM Mathias Kresin <dev@kresin.me> wrote:

> Add an implementation to get the current GPIO state.
>
> The callback is used by the leds-gpio driver for example, in case the
> current LED/GPIO state should be kept during driver load.
>
> Signed-off-by: Mathias Kresin <dev@kresin.me>

Patch applied.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-02 13:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-28 19:57 [PATCH] gpio: stp-xway: Implement get callback Mathias Kresin
2018-07-02 13:22 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®