Skip to content

Commit 99cade8

Browse files
andy-shevlag-linaro
authored andcommitted
leds: mt6323: 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: Andy Shevchenko <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Lee Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e41ff81 commit 99cade8

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

drivers/leds/leds-mt6323.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -339,23 +339,23 @@ static int mt6323_led_set_dt_default(struct led_classdev *cdev,
339339
struct device_node *np)
340340
{
341341
struct mt6323_led *led = container_of(cdev, struct mt6323_led, cdev);
342-
const char *state;
342+
enum led_default_state state;
343343
int ret = 0;
344344

345-
state = of_get_property(np, "default-state", NULL);
346-
if (state) {
347-
if (!strcmp(state, "keep")) {
348-
ret = mt6323_get_led_hw_brightness(cdev);
349-
if (ret < 0)
350-
return ret;
351-
led->current_brightness = ret;
352-
ret = 0;
353-
} else if (!strcmp(state, "on")) {
354-
ret =
355-
mt6323_led_set_brightness(cdev, cdev->max_brightness);
356-
} else {
357-
ret = mt6323_led_set_brightness(cdev, LED_OFF);
358-
}
345+
state = led_init_default_state_get(of_fwnode_handle(np));
346+
switch (state) {
347+
case LEDS_DEFSTATE_ON:
348+
ret = mt6323_led_set_brightness(cdev, cdev->max_brightness);
349+
break;
350+
case LEDS_DEFSTATE_KEEP:
351+
ret = mt6323_get_led_hw_brightness(cdev);
352+
if (ret < 0)
353+
return ret;
354+
led->current_brightness = ret;
355+
ret = 0;
356+
break;
357+
default:
358+
ret = mt6323_led_set_brightness(cdev, LED_OFF);
359359
}
360360

361361
return ret;

0 commit comments

Comments
 (0)