summaryrefslogtreecommitdiff
path: root/drivers/led/led-uclass.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2017-04-16 22:07:52 -0400
committerTom Rini <trini@konsulko.com>2017-04-16 22:07:52 -0400
commit51f866e8da758a27af596af73466bd5f0a450c4d (patch)
treeb4d47e5782265bec5ad8adcc43c43a118062ba6d /drivers/led/led-uclass.c
parent3fea95369850987de15a2a0ac009d05e13b90246 (diff)
parentad46af0e76384b22058d9ac979f34fad2483aff3 (diff)
Merge git://git.denx.de/u-boot-dm
Diffstat (limited to 'drivers/led/led-uclass.c')
-rw-r--r--drivers/led/led-uclass.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/drivers/led/led-uclass.c b/drivers/led/led-uclass.c
index 784ac870e2..78ab76050d 100644
--- a/drivers/led/led-uclass.c
+++ b/drivers/led/led-uclass.c
@@ -22,7 +22,7 @@ int led_get_by_label(const char *label, struct udevice **devp)
if (ret)
return ret;
uclass_foreach_dev(dev, uc) {
- struct led_uclass_plat *uc_plat = dev_get_uclass_platdata(dev);
+ struct led_uc_plat *uc_plat = dev_get_uclass_platdata(dev);
/* Ignore the top-level LED node */
if (uc_plat->label && !strcmp(label, uc_plat->label))
@@ -32,18 +32,40 @@ int led_get_by_label(const char *label, struct udevice **devp)
return -ENODEV;
}
-int led_set_on(struct udevice *dev, int on)
+int led_set_state(struct udevice *dev, enum led_state_t state)
{
struct led_ops *ops = led_get_ops(dev);
- if (!ops->set_on)
+ if (!ops->set_state)
return -ENOSYS;
- return ops->set_on(dev, on);
+ return ops->set_state(dev, state);
}
+enum led_state_t led_get_state(struct udevice *dev)
+{
+ struct led_ops *ops = led_get_ops(dev);
+
+ if (!ops->get_state)
+ return -ENOSYS;
+
+ return ops->get_state(dev);
+}
+
+#ifdef CONFIG_LED_BLINK
+int led_set_period(struct udevice *dev, int period_ms)
+{
+ struct led_ops *ops = led_get_ops(dev);
+
+ if (!ops->set_period)
+ return -ENOSYS;
+
+ return ops->set_period(dev, period_ms);
+}
+#endif
+
UCLASS_DRIVER(led) = {
.id = UCLASS_LED,
.name = "led",
- .per_device_platdata_auto_alloc_size = sizeof(struct led_uclass_plat),
+ .per_device_platdata_auto_alloc_size = sizeof(struct led_uc_plat),
};