]> git.sur5r.net Git - u-boot/commitdiff
led: Return -ENODEV if the LED device cannot be found
authorSimon Glass <sjg@chromium.org>
Mon, 6 Jul 2015 18:54:33 +0000 (12:54 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 21 Jul 2015 23:39:32 +0000 (17:39 -0600)
We normally use -ENODEV for a missing device, rather than -ENOENT. The
latter is reserved for when we have a device but cannot find something
within it.

Also avoid looking at the root LED device since it is only a container.

Signed-off-by: Simon Glass <sjg@chromium.org>
drivers/led/led-uclass.c
include/led.h

index a80ae93d4512d43b7ada95e0e96d076e0139515b..784ac870e275adace6b5871ce07cd326efbc9f4d 100644 (file)
@@ -24,11 +24,12 @@ int led_get_by_label(const char *label, struct udevice **devp)
        uclass_foreach_dev(dev, uc) {
                struct led_uclass_plat *uc_plat = dev_get_uclass_platdata(dev);
 
-               if (!strcmp(label, uc_plat->label))
+               /* Ignore the top-level LED node */
+               if (uc_plat->label && !strcmp(label, uc_plat->label))
                        return uclass_get_device_tail(dev, 0, devp);
        }
 
-       return -ENOENT;
+       return -ENODEV;
 }
 
 int led_set_on(struct udevice *dev, int on)
index 8925d75bcf6048cf38009c1477d1846ac7f78807..b929d0ca3c70c880444965d86e7956944c59d2da 100644 (file)
@@ -35,7 +35,7 @@ struct led_ops {
  *
  * @label:     LED label to look up
  * @devp:      Returns the associated device, if found
- * @return 0 if found, -ve on error
+ * @return 0 if found, -ENODEV if not found, other -ve on error
  */
 int led_get_by_label(const char *label, struct udevice **devp);