Commit 265d313e authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Lee Jones

leds: syscon: 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-11-andriy.shevchenko@linux.intel.com
parent bf8a9a76
...@@ -61,7 +61,8 @@ static int syscon_led_probe(struct platform_device *pdev) ...@@ -61,7 +61,8 @@ static int syscon_led_probe(struct platform_device *pdev)
struct device *parent; struct device *parent;
struct regmap *map; struct regmap *map;
struct syscon_led *sled; struct syscon_led *sled;
const char *state; enum led_default_state state;
u32 value;
int ret; int ret;
parent = dev->parent; parent = dev->parent;
...@@ -86,34 +87,30 @@ static int syscon_led_probe(struct platform_device *pdev) ...@@ -86,34 +87,30 @@ static int syscon_led_probe(struct platform_device *pdev)
if (of_property_read_u32(np, "mask", &sled->mask)) if (of_property_read_u32(np, "mask", &sled->mask))
return -EINVAL; return -EINVAL;
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);
u32 val; switch (state) {
case LEDS_DEFSTATE_ON:
ret = regmap_read(map, sled->offset, &val); ret = regmap_update_bits(map, sled->offset, sled->mask, sled->mask);
if (ret < 0) if (ret < 0)
return ret; return ret;
sled->state = !!(val & sled->mask); sled->state = true;
} else if (!strcmp(state, "on")) { break;
sled->state = true; case LEDS_DEFSTATE_KEEP:
ret = regmap_update_bits(map, sled->offset, ret = regmap_read(map, sled->offset, &value);
sled->mask, if (ret < 0)
sled->mask); return ret;
if (ret < 0) sled->state = !!(value & sled->mask);
return ret; break;
} else { default:
sled->state = false; ret = regmap_update_bits(map, sled->offset, sled->mask, 0);
ret = regmap_update_bits(map, sled->offset, if (ret < 0)
sled->mask, 0); return ret;
if (ret < 0) sled->state = false;
return ret;
}
} }
sled->cdev.brightness_set = syscon_led_set; sled->cdev.brightness_set = syscon_led_set;
init_data.fwnode = of_fwnode_handle(np);
ret = devm_led_classdev_register_ext(dev, &sled->cdev, &init_data); ret = devm_led_classdev_register_ext(dev, &sled->cdev, &init_data);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
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