[PATCH v2 07/11] leds: mt6360: Get rid of custom led_init_default_state_get()
Andy Shevchenko
andriy.shevchenko at linux.intel.com
Fri Aug 5 08:49:03 PDT 2022
LED core provides a helper to parse default state from firmware node.
Use it instead of custom implementation.
Signed-off-by: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
Reviewed-by: Matthias Brugger <matthias.bgg at gmail.com>
---
drivers/leds/flash/leds-mt6360.c | 38 +++++---------------------------
1 file changed, 6 insertions(+), 32 deletions(-)
diff --git a/drivers/leds/flash/leds-mt6360.c b/drivers/leds/flash/leds-mt6360.c
index e1066a52d2d2..1af6c5898343 100644
--- a/drivers/leds/flash/leds-mt6360.c
+++ b/drivers/leds/flash/leds-mt6360.c
@@ -71,10 +71,6 @@ enum {
#define MT6360_STRBTO_STEPUS 32000
#define MT6360_STRBTO_MAXUS 2432000
-#define STATE_OFF 0
-#define STATE_KEEP 1
-#define STATE_ON 2
-
struct mt6360_led {
union {
struct led_classdev isnk;
@@ -84,7 +80,7 @@ struct mt6360_led {
struct v4l2_flash *v4l2_flash;
struct mt6360_priv *priv;
u32 led_no;
- u32 default_state;
+ enum led_default_state default_state;
};
struct mt6360_priv {
@@ -405,10 +401,10 @@ static int mt6360_isnk_init_default_state(struct mt6360_led *led)
level = LED_OFF;
switch (led->default_state) {
- case STATE_ON:
+ case LEDS_DEFSTATE_ON:
led->isnk.brightness = led->isnk.max_brightness;
break;
- case STATE_KEEP:
+ case LEDS_DEFSTATE_KEEP:
led->isnk.brightness = min(level, led->isnk.max_brightness);
break;
default:
@@ -443,10 +439,10 @@ static int mt6360_flash_init_default_state(struct mt6360_led *led)
level = LED_OFF;
switch (led->default_state) {
- case STATE_ON:
+ case LEDS_DEFSTATE_ON:
flash->led_cdev.brightness = flash->led_cdev.max_brightness;
break;
- case STATE_KEEP:
+ case LEDS_DEFSTATE_KEEP:
flash->led_cdev.brightness =
min(level, flash->led_cdev.max_brightness);
break;
@@ -760,25 +756,6 @@ static int mt6360_init_flash_properties(struct mt6360_led *led,
return 0;
}
-static int mt6360_init_common_properties(struct mt6360_led *led,
- struct led_init_data *init_data)
-{
- const char *const states[] = { "off", "keep", "on" };
- const char *str;
- int ret;
-
- if (!fwnode_property_read_string(init_data->fwnode,
- "default-state", &str)) {
- ret = match_string(states, ARRAY_SIZE(states), str);
- if (ret < 0)
- ret = STATE_OFF;
-
- led->default_state = ret;
- }
-
- return 0;
-}
-
static void mt6360_v4l2_flash_release(struct mt6360_priv *priv)
{
int i;
@@ -852,10 +829,7 @@ static int mt6360_led_probe(struct platform_device *pdev)
led->led_no = reg;
led->priv = priv;
-
- ret = mt6360_init_common_properties(led, &init_data);
- if (ret)
- goto out_flash_release;
+ led->default_state = led_init_default_state_get(child);
if (reg == MT6360_VIRTUAL_MULTICOLOR ||
reg <= MT6360_LED_ISNKML)
--
2.35.1
More information about the Linux-mediatek
mailing list