Commit bf8a9a76 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Lee Jones

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarLee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20230103131256.33894-10-andriy.shevchenko@linux.intel.com
parent 0dd37b1c
...@@ -93,8 +93,8 @@ static int pm8058_led_probe(struct platform_device *pdev) ...@@ -93,8 +93,8 @@ static int pm8058_led_probe(struct platform_device *pdev)
struct device_node *np; struct device_node *np;
int ret; int ret;
struct regmap *map; struct regmap *map;
const char *state;
enum led_brightness maxbright; enum led_brightness maxbright;
enum led_default_state state;
led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
if (!led) if (!led)
...@@ -125,25 +125,26 @@ static int pm8058_led_probe(struct platform_device *pdev) ...@@ -125,25 +125,26 @@ static int pm8058_led_probe(struct platform_device *pdev)
maxbright = 15; /* 4 bits */ maxbright = 15; /* 4 bits */
led->cdev.max_brightness = maxbright; led->cdev.max_brightness = maxbright;
state = of_get_property(np, "default-state", NULL); init_data.fwnode = of_fwnode_handle(np);
if (state) {
if (!strcmp(state, "keep")) { state = led_init_default_state_get(init_data.fwnode);
led->cdev.brightness = pm8058_led_get(&led->cdev); switch (state) {
} else if (!strcmp(state, "on")) { case LEDS_DEFSTATE_ON:
led->cdev.brightness = maxbright; led->cdev.brightness = maxbright;
pm8058_led_set(&led->cdev, maxbright); pm8058_led_set(&led->cdev, maxbright);
} else { break;
led->cdev.brightness = LED_OFF; case LEDS_DEFSTATE_KEEP:
pm8058_led_set(&led->cdev, LED_OFF); led->cdev.brightness = pm8058_led_get(&led->cdev);
} break;
default:
led->cdev.brightness = LED_OFF;
pm8058_led_set(&led->cdev, LED_OFF);
} }
if (led->ledtype == PM8058_LED_TYPE_KEYPAD || if (led->ledtype == PM8058_LED_TYPE_KEYPAD ||
led->ledtype == PM8058_LED_TYPE_FLASH) led->ledtype == PM8058_LED_TYPE_FLASH)
led->cdev.flags = LED_CORE_SUSPENDRESUME; led->cdev.flags = LED_CORE_SUSPENDRESUME;
init_data.fwnode = of_fwnode_handle(np);
ret = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); ret = devm_led_classdev_register_ext(dev, &led->cdev, &init_data);
if (ret) if (ret)
dev_err(dev, "Failed to register LED for %pOF\n", np); dev_err(dev, "Failed to register LED for %pOF\n", np);
......
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