Commit d565263b authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Jakub Kicinski

net: dsa: hellcreek: Get rid of custom led_init_default_state_get()

LED core provides a helper to parse default state from firmware node.
Use it instead of custom implementation.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Kurt Kanzenbach's avatarKurt Kanzenbach <kurt@linutronix.de>
Reviewed-by: default avatarMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
Link: https://lore.kernel.org/r/20230314181824.56881-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent cc6d85c1
......@@ -297,7 +297,8 @@ static enum led_brightness hellcreek_led_is_gm_get(struct led_classdev *ldev)
static int hellcreek_led_setup(struct hellcreek *hellcreek)
{
struct device_node *leds, *led = NULL;
const char *label, *state;
enum led_default_state state;
const char *label;
int ret = -EINVAL;
of_node_get(hellcreek->dev->of_node);
......@@ -318,16 +319,17 @@ static int hellcreek_led_setup(struct hellcreek *hellcreek)
ret = of_property_read_string(led, "label", &label);
hellcreek->led_sync_good.name = ret ? "sync_good" : label;
ret = of_property_read_string(led, "default-state", &state);
if (!ret) {
if (!strcmp(state, "on"))
state = led_init_default_state_get(of_fwnode_handle(led));
switch (state) {
case LEDS_DEFSTATE_ON:
hellcreek->led_sync_good.brightness = 1;
else if (!strcmp(state, "off"))
hellcreek->led_sync_good.brightness = 0;
else if (!strcmp(state, "keep"))
break;
case LEDS_DEFSTATE_KEEP:
hellcreek->led_sync_good.brightness =
hellcreek_get_brightness(hellcreek,
STATUS_OUT_SYNC_GOOD);
hellcreek_get_brightness(hellcreek, STATUS_OUT_SYNC_GOOD);
break;
default:
hellcreek->led_sync_good.brightness = 0;
}
hellcreek->led_sync_good.max_brightness = 1;
......@@ -344,16 +346,17 @@ static int hellcreek_led_setup(struct hellcreek *hellcreek)
ret = of_property_read_string(led, "label", &label);
hellcreek->led_is_gm.name = ret ? "is_gm" : label;
ret = of_property_read_string(led, "default-state", &state);
if (!ret) {
if (!strcmp(state, "on"))
state = led_init_default_state_get(of_fwnode_handle(led));
switch (state) {
case LEDS_DEFSTATE_ON:
hellcreek->led_is_gm.brightness = 1;
else if (!strcmp(state, "off"))
hellcreek->led_is_gm.brightness = 0;
else if (!strcmp(state, "keep"))
break;
case LEDS_DEFSTATE_KEEP:
hellcreek->led_is_gm.brightness =
hellcreek_get_brightness(hellcreek,
STATUS_OUT_IS_GM);
hellcreek_get_brightness(hellcreek, STATUS_OUT_IS_GM);
break;
default:
hellcreek->led_is_gm.brightness = 0;
}
hellcreek->led_is_gm.max_brightness = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment