/* Test obtaining an LED by label */ static int dm_test_led_label(struct unit_test_state *uts) { struct udevice *dev, *cmp; ut_assertok(led_get_by_label("sandbox:red", &dev)); ut_asserteq(1, device_active(dev)); ut_assertok(uclass_get_device(UCLASS_LED, 1, &cmp)); ut_asserteq_ptr(dev, cmp); ut_assertok(led_get_by_label("sandbox:green", &dev)); ut_asserteq(1, device_active(dev)); ut_assertok(uclass_get_device(UCLASS_LED, 2, &cmp)); ut_asserteq_ptr(dev, cmp); ut_asserteq(-ENODEV, led_get_by_label("sandbox:blue", &dev)); return 0; }
static int setup_led(void) { #ifdef CONFIG_SPL_LED struct udevice *dev; char *led_name; int ret; led_name = fdtdec_get_config_string(gd->fdt_blob, "u-boot,boot-led"); if (!led_name) return 0; ret = led_get_by_label(led_name, &dev); if (ret) { debug("%s: get=%d\n", __func__, ret); return ret; } ret = led_set_on(dev, 1); if (ret) return ret; #endif return 0; }