All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/6] led: add get_status support for DM LED support
@ 2017-03-27 14:38 techping.chan at gmail.com
  2017-03-27 14:38 ` [U-Boot] [PATCH 2/6] led: gpio: add support for get_status function techping.chan at gmail.com
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: techping.chan at gmail.com @ 2017-03-27 14:38 UTC (permalink / raw)
  To: u-boot

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

Sometimes we need to read back the status of a LED.

Add a led_get_status function for DM LED support, and add a get_status
function for the driver to implement this function.

Signed-off-by: Ziping Chen <techping.chan@gmail.com>
---
 drivers/led/led-uclass.c | 10 ++++++++++
 include/led.h            | 15 +++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c
index 784ac87..304b92a 100644
--- a/drivers/led/led-uclass.c
+++ b/drivers/led/led-uclass.c
@@ -42,6 +42,16 @@ int led_set_on(struct udevice *dev, int on)
 	return ops->set_on(dev, on);
 }
 
+int led_get_status(struct udevice *dev)
+{
+	struct led_ops *ops = led_get_ops(dev);
+
+	if (!ops->get_status)
+		return -ENOSYS;
+
+	return ops->get_status(dev);
+}
+
 UCLASS_DRIVER(led) = {
 	.id		= UCLASS_LED,
 	.name		= "led",
diff --git a/include/led.h b/include/led.h
index b929d0c..cd6fe98 100644
--- a/include/led.h
+++ b/include/led.h
@@ -26,6 +26,13 @@ struct led_ops {
 	 * @return 0 if OK, -ve on error
 	 */
 	int (*set_on)(struct udevice *dev, int on);
+	/**
+	 * led_get_status() - get the state of an LED
+	 *
+	 * @dev:	LED device to query
+	 * @return 0 if LED off, 1 if LED on, -ve on error
+	 */
+	int (*get_status)(struct udevice *dev);
 };
 
 #define led_get_ops(dev)	((struct led_ops *)(dev)->driver->ops)
@@ -48,4 +55,12 @@ int led_get_by_label(const char *label, struct udevice **devp);
  */
 int led_set_on(struct udevice *dev, int on);
 
+/**
+ * led_get_status() - get the state of an LED
+ *
+ * @dev:	LED device to query
+ * @return 0 if LED off, 1 if LED on, -ve on error
+ */
+int led_get_status(struct udevice *dev);
+
 #endif
-- 
2.7.4

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

end of thread, other threads:[~2017-04-10 17:35 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [U-Boot] [PATCH 2/6] led: gpio: add support for get_status function techping.chan at gmail.com
2017-04-01  4:23   ` 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

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.