dm: led: Add support for getting the state of an LED

It is useful to be able to read the LED as well as write it. Add this to
the uclass and update the GPIO driver.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ziping Chen <techping.chan@gmail.com>
This commit is contained in:
Simon Glass
2017-04-10 11:34:55 -06:00
parent ddae9fcddc
commit 8f4b612333
4 changed files with 50 additions and 0 deletions

View File

@@ -43,9 +43,11 @@ static int dm_test_led_gpio(struct unit_test_state *uts)
ut_asserteq(0, sandbox_gpio_get_value(gpio, offset));
ut_assertok(led_set_state(dev, LEDST_ON));
ut_asserteq(1, sandbox_gpio_get_value(gpio, offset));
ut_asserteq(LEDST_ON, led_get_state(dev));
ut_assertok(led_set_state(dev, LEDST_OFF));
ut_asserteq(0, sandbox_gpio_get_value(gpio, offset));
ut_asserteq(LEDST_OFF, led_get_state(dev));
return 0;
}