diff options
author | Denis Osterland-Heim <Denis.Osterland@diehl.com> | 2021-06-08 08:35:53 +0200 |
---|---|---|
committer | Pavel Machek <pavel@ucw.cz> | 2021-08-18 08:27:30 +0200 |
commit | 791bc41163c51f870972d6c6b82d971ce951096c (patch) | |
tree | 3b6504b86874ba8c9e1ecf3949728400f4583559 /drivers/leds/led-core.c | |
parent | 654933ae7d32f278eecd0bb0f175785574ac4775 (diff) | |
download | lwn-791bc41163c51f870972d6c6b82d971ce951096c.tar.gz lwn-791bc41163c51f870972d6c6b82d971ce951096c.zip |
leds: move default_state read from fwnode to core
This patch introduces a new function to read initial
default_state from fwnode.
Suggested-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Denis Osterland-Heim <Denis.Osterland@diehl.com>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
Diffstat (limited to 'drivers/leds/led-core.c')
-rw-r--r-- | drivers/leds/led-core.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/leds/led-core.c b/drivers/leds/led-core.c index 8eb8054ef9c6..4a97cb745788 100644 --- a/drivers/leds/led-core.c +++ b/drivers/leds/led-core.c @@ -477,3 +477,18 @@ int led_compose_name(struct device *dev, struct led_init_data *init_data, return 0; } EXPORT_SYMBOL_GPL(led_compose_name); + +enum led_default_state led_init_default_state_get(struct fwnode_handle *fwnode) +{ + const char *state = NULL; + + if (!fwnode_property_read_string(fwnode, "default-state", &state)) { + if (!strcmp(state, "keep")) + return LEDS_DEFSTATE_KEEP; + if (!strcmp(state, "on")) + return LEDS_DEFSTATE_ON; + } + + return LEDS_DEFSTATE_OFF; +} +EXPORT_SYMBOL_GPL(led_init_default_state_get); |