public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: techping.chan at gmail.com <techping.chan@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/6] led: gpio: add support for get_status function
Date: Mon, 27 Mar 2017 22:38:39 +0800	[thread overview]
Message-ID: <1490625523-11594-2-git-send-email-techping.chan@gmail.com> (raw)
In-Reply-To: <1490625523-11594-1-git-send-email-techping.chan@gmail.com>

From: Ziping Chen <techping.chan@gmail.com>

The status of a GPIO-connected LED can be read back by reading the GPO
value.

Add the support for get_status function in led_gpio driver.

Signed-off-by: Ziping Chen <techping.chan@gmail.com>
---
 drivers/led/led_gpio.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c
index 5b11990..b64721e 100644
--- a/drivers/led/led_gpio.c
+++ b/drivers/led/led_gpio.c
@@ -28,6 +28,16 @@ static int gpio_led_set_on(struct udevice *dev, int on)
 	return dm_gpio_set_value(&priv->gpio, on);
 }
 
+static int gpio_led_get_status(struct udevice *dev)
+{
+	struct led_gpio_priv *priv = dev_get_priv(dev);
+
+	if (!dm_gpio_is_valid(&priv->gpio))
+		return -EREMOTEIO;
+
+	return dm_gpio_get_value(&priv->gpio);
+}
+
 static int led_gpio_probe(struct udevice *dev)
 {
 	struct led_uclass_plat *uc_plat = dev_get_uclass_platdata(dev);
@@ -88,6 +98,7 @@ static int led_gpio_bind(struct udevice *parent)
 
 static const struct led_ops gpio_led_ops = {
 	.set_on		= gpio_led_set_on,
+	.get_status	= gpio_led_get_status,
 };
 
 static const struct udevice_id led_gpio_ids[] = {
-- 
2.7.4

  reply	other threads:[~2017-03-27 14:38 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-27 14:38 [U-Boot] [PATCH 1/6] led: add get_status support for DM LED support techping.chan at gmail.com
2017-03-27 14:38 ` techping.chan at gmail.com [this message]
2017-04-01  4:23   ` [U-Boot] [PATCH 2/6] led: gpio: add support for get_status function Simon Glass
2017-03-27 14:38 ` [U-Boot] [PATCH 3/6] cmd: led: rename command enum value techping.chan at gmail.com
2017-04-01  4:22   ` Simon Glass
2017-03-27 14:38 ` [U-Boot] [PATCH 4/6] cmd: led: add enum led_cmd member to support error code return techping.chan at gmail.com
2017-04-01  4:22   ` Simon Glass
2017-03-27 14:38 ` [U-Boot] [PATCH 5/6] cmd: led: add DM-based implementation techping.chan at gmail.com
2017-04-01  4:22   ` Simon Glass
2017-04-05 13:24     ` Ziping Chen
2017-04-09 19:27       ` Simon Glass
2017-04-10 15:06         ` Ziping Chen
2017-04-10 17:35           ` Simon Glass
2017-03-27 14:38 ` [U-Boot] [PATCH 6/6] cmd: led: add command led list techping.chan at gmail.com
2017-04-01  4:23 ` [U-Boot] [PATCH 1/6] led: add get_status support for DM LED support Simon Glass
2017-04-05 13:20   ` Ziping Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1490625523-11594-2-git-send-email-techping.chan@gmail.com \
    --to=techping.chan@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox