[U-Boot] [PATCH21/23] LED: GPIO: provide get_on() op

Benjamin Tietz uboot at dresden.micronet24.de
Sat Jun 18 14:57:12 CEST 2016


From: Benjamin Tietz <benjamin at micronet24.de>


---
 drivers/led/led_gpio.c |   11 +++++++++++
 1 file changed, 11 insertions(+)
-------------- next part --------------
From: Benjamin Tietz <benjamin at micronet24.de>


---
 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 cb6e996..80e0f72 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_on(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_on		= gpio_led_get_on,
 };
 
 static const struct udevice_id led_gpio_ids[] = {


More information about the U-Boot mailing list