Skip to content

Commit bf8a9a7

Browse files
andy-shevlag-linaro
authored andcommitted
leds: pm8058: 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]> Signed-off-by: Lee Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0dd37b1 commit bf8a9a7

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

drivers/leds/leds-pm8058.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ static int pm8058_led_probe(struct platform_device *pdev)
9393
struct device_node *np;
9494
int ret;
9595
struct regmap *map;
96-
const char *state;
9796
enum led_brightness maxbright;
97+
enum led_default_state state;
9898

9999
led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
100100
if (!led)
@@ -125,25 +125,26 @@ static int pm8058_led_probe(struct platform_device *pdev)
125125
maxbright = 15; /* 4 bits */
126126
led->cdev.max_brightness = maxbright;
127127

128-
state = of_get_property(np, "default-state", NULL);
129-
if (state) {
130-
if (!strcmp(state, "keep")) {
131-
led->cdev.brightness = pm8058_led_get(&led->cdev);
132-
} else if (!strcmp(state, "on")) {
133-
led->cdev.brightness = maxbright;
134-
pm8058_led_set(&led->cdev, maxbright);
135-
} else {
136-
led->cdev.brightness = LED_OFF;
137-
pm8058_led_set(&led->cdev, LED_OFF);
138-
}
128+
init_data.fwnode = of_fwnode_handle(np);
129+
130+
state = led_init_default_state_get(init_data.fwnode);
131+
switch (state) {
132+
case LEDS_DEFSTATE_ON:
133+
led->cdev.brightness = maxbright;
134+
pm8058_led_set(&led->cdev, maxbright);
135+
break;
136+
case LEDS_DEFSTATE_KEEP:
137+
led->cdev.brightness = pm8058_led_get(&led->cdev);
138+
break;
139+
default:
140+
led->cdev.brightness = LED_OFF;
141+
pm8058_led_set(&led->cdev, LED_OFF);
139142
}
140143

141144
if (led->ledtype == PM8058_LED_TYPE_KEYPAD ||
142145
led->ledtype == PM8058_LED_TYPE_FLASH)
143146
led->cdev.flags = LED_CORE_SUSPENDRESUME;
144147

145-
init_data.fwnode = of_fwnode_handle(np);
146-
147148
ret = devm_led_classdev_register_ext(dev, &led->cdev, &init_data);
148149
if (ret)
149150
dev_err(dev, "Failed to register LED for %pOF\n", np);

0 commit comments

Comments
 (0)