Skip to content

Commit 43ee1e3

Browse files
andy-shevlag-linaro
authored andcommitted
leds: mt6360: 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: Matthias Brugger <[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 99cade8 commit 43ee1e3

File tree

1 file changed

+6
-32
lines changed

1 file changed

+6
-32
lines changed

drivers/leds/flash/leds-mt6360.c

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ enum {
7171
#define MT6360_STRBTO_STEPUS 32000
7272
#define MT6360_STRBTO_MAXUS 2432000
7373

74-
#define STATE_OFF 0
75-
#define STATE_KEEP 1
76-
#define STATE_ON 2
77-
7874
struct mt6360_led {
7975
union {
8076
struct led_classdev isnk;
@@ -84,7 +80,7 @@ struct mt6360_led {
8480
struct v4l2_flash *v4l2_flash;
8581
struct mt6360_priv *priv;
8682
u32 led_no;
87-
u32 default_state;
83+
enum led_default_state default_state;
8884
};
8985

9086
struct mt6360_priv {
@@ -405,10 +401,10 @@ static int mt6360_isnk_init_default_state(struct mt6360_led *led)
405401
level = LED_OFF;
406402

407403
switch (led->default_state) {
408-
case STATE_ON:
404+
case LEDS_DEFSTATE_ON:
409405
led->isnk.brightness = led->isnk.max_brightness;
410406
break;
411-
case STATE_KEEP:
407+
case LEDS_DEFSTATE_KEEP:
412408
led->isnk.brightness = min(level, led->isnk.max_brightness);
413409
break;
414410
default:
@@ -443,10 +439,10 @@ static int mt6360_flash_init_default_state(struct mt6360_led *led)
443439
level = LED_OFF;
444440

445441
switch (led->default_state) {
446-
case STATE_ON:
442+
case LEDS_DEFSTATE_ON:
447443
flash->led_cdev.brightness = flash->led_cdev.max_brightness;
448444
break;
449-
case STATE_KEEP:
445+
case LEDS_DEFSTATE_KEEP:
450446
flash->led_cdev.brightness =
451447
min(level, flash->led_cdev.max_brightness);
452448
break;
@@ -760,25 +756,6 @@ static int mt6360_init_flash_properties(struct mt6360_led *led,
760756
return 0;
761757
}
762758

763-
static int mt6360_init_common_properties(struct mt6360_led *led,
764-
struct led_init_data *init_data)
765-
{
766-
const char *const states[] = { "off", "keep", "on" };
767-
const char *str;
768-
int ret;
769-
770-
if (!fwnode_property_read_string(init_data->fwnode,
771-
"default-state", &str)) {
772-
ret = match_string(states, ARRAY_SIZE(states), str);
773-
if (ret < 0)
774-
ret = STATE_OFF;
775-
776-
led->default_state = ret;
777-
}
778-
779-
return 0;
780-
}
781-
782759
static void mt6360_v4l2_flash_release(struct mt6360_priv *priv)
783760
{
784761
int i;
@@ -852,10 +829,7 @@ static int mt6360_led_probe(struct platform_device *pdev)
852829

853830
led->led_no = reg;
854831
led->priv = priv;
855-
856-
ret = mt6360_init_common_properties(led, &init_data);
857-
if (ret)
858-
goto out_flash_release;
832+
led->default_state = led_init_default_state_get(child);
859833

860834
if (reg == MT6360_VIRTUAL_MULTICOLOR ||
861835
reg <= MT6360_LED_ISNKML)

0 commit comments

Comments
 (0)