From: Marek Vasut Date: Mon, 25 Apr 2022 16:33:50 +0000 (+0200) Subject: test: dm: led: Fix LED enumeration X-Git-Url: http://git.dujemihanovic.xyz/img/static/git-logo.png?a=commitdiff_plain;h=876276f5de92cbaa4a55706606451354650cc730;p=u-boot.git test: dm: led: Fix LED enumeration The GPIO LED driver no longer considers the top level node an LED, because it is not an LED. With this bug fixed, the LED enumeration has changed. Update the test accordingly. Signed-off-by: Marek Vasut Cc: Patrice Chotard Cc: Patrick Delaunay Cc: Sean Anderson Cc: Simon Glass Cc: Steven Lawrance --- diff --git a/test/dm/led.c b/test/dm/led.c index 5bbe04648a..eed3f4654c 100644 --- a/test/dm/led.c +++ b/test/dm/led.c @@ -21,8 +21,7 @@ static int dm_test_led_base(struct unit_test_state *uts) ut_assertok(uclass_get_device(UCLASS_LED, 1, &dev)); ut_assertok(uclass_get_device(UCLASS_LED, 2, &dev)); ut_assertok(uclass_get_device(UCLASS_LED, 3, &dev)); - ut_assertok(uclass_get_device(UCLASS_LED, 4, &dev)); - ut_asserteq(-ENODEV, uclass_get_device(UCLASS_LED, 5, &dev)); + ut_asserteq(-ENODEV, uclass_get_device(UCLASS_LED, 4, &dev)); return 0; } @@ -52,10 +51,10 @@ static int dm_test_led_gpio(struct unit_test_state *uts) struct udevice *dev, *gpio; /* - * Check that we can manipulate an LED. LED 1 is connected to GPIO + * Check that we can manipulate an LED. LED 0 is connected to GPIO * bank gpio_a, offset 1. */ - ut_assertok(uclass_get_device(UCLASS_LED, 1, &dev)); + ut_assertok(uclass_get_device(UCLASS_LED, 0, &dev)); ut_assertok(uclass_get_device(UCLASS_GPIO, 1, &gpio)); ut_asserteq(0, sandbox_gpio_get_value(gpio, offset)); ut_assertok(led_set_state(dev, LEDST_ON)); @@ -77,10 +76,10 @@ static int dm_test_led_toggle(struct unit_test_state *uts) struct udevice *dev, *gpio; /* - * Check that we can manipulate an LED. LED 1 is connected to GPIO + * Check that we can manipulate an LED. LED 0 is connected to GPIO * bank gpio_a, offset 1. */ - ut_assertok(uclass_get_device(UCLASS_LED, 1, &dev)); + ut_assertok(uclass_get_device(UCLASS_LED, 0, &dev)); ut_assertok(uclass_get_device(UCLASS_GPIO, 1, &gpio)); ut_asserteq(0, sandbox_gpio_get_value(gpio, offset)); ut_assertok(led_set_state(dev, LEDST_TOGGLE)); @@ -102,12 +101,12 @@ static int dm_test_led_label(struct unit_test_state *uts) 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_assertok(uclass_get_device(UCLASS_LED, 0, &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_assertok(uclass_get_device(UCLASS_LED, 1, &cmp)); ut_asserteq_ptr(dev, cmp); ut_asserteq(-ENODEV, led_get_by_label("sandbox:blue", &dev)); @@ -127,7 +126,7 @@ static int dm_test_led_blink(struct unit_test_state *uts) * Check that we get an error when trying to blink an LED, since it is * not supported by the GPIO LED driver. */ - ut_assertok(uclass_get_device(UCLASS_LED, 1, &dev)); + ut_assertok(uclass_get_device(UCLASS_LED, 0, &dev)); ut_assertok(uclass_get_device(UCLASS_GPIO, 1, &gpio)); ut_asserteq(0, sandbox_gpio_get_value(gpio, offset)); ut_asserteq(-ENOSYS, led_set_state(dev, LEDST_BLINK));