mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 22:21:42 +00:00
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20230103131256.33894-11-andriy.shevchenko@linux.intel.com
This commit is contained in:
parent
bf8a9a7684
commit
265d313ee6
@ -61,7 +61,8 @@ static int syscon_led_probe(struct platform_device *pdev)
|
||||
struct device *parent;
|
||||
struct regmap *map;
|
||||
struct syscon_led *sled;
|
||||
const char *state;
|
||||
enum led_default_state state;
|
||||
u32 value;
|
||||
int ret;
|
||||
|
||||
parent = dev->parent;
|
||||
@ -86,34 +87,30 @@ static int syscon_led_probe(struct platform_device *pdev)
|
||||
if (of_property_read_u32(np, "mask", &sled->mask))
|
||||
return -EINVAL;
|
||||
|
||||
state = of_get_property(np, "default-state", NULL);
|
||||
if (state) {
|
||||
if (!strcmp(state, "keep")) {
|
||||
u32 val;
|
||||
init_data.fwnode = of_fwnode_handle(np);
|
||||
|
||||
ret = regmap_read(map, sled->offset, &val);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
sled->state = !!(val & sled->mask);
|
||||
} else if (!strcmp(state, "on")) {
|
||||
sled->state = true;
|
||||
ret = regmap_update_bits(map, sled->offset,
|
||||
sled->mask,
|
||||
sled->mask);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} else {
|
||||
sled->state = false;
|
||||
ret = regmap_update_bits(map, sled->offset,
|
||||
sled->mask, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
state = led_init_default_state_get(init_data.fwnode);
|
||||
switch (state) {
|
||||
case LEDS_DEFSTATE_ON:
|
||||
ret = regmap_update_bits(map, sled->offset, sled->mask, sled->mask);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
sled->state = true;
|
||||
break;
|
||||
case LEDS_DEFSTATE_KEEP:
|
||||
ret = regmap_read(map, sled->offset, &value);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
sled->state = !!(value & sled->mask);
|
||||
break;
|
||||
default:
|
||||
ret = regmap_update_bits(map, sled->offset, sled->mask, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
sled->state = false;
|
||||
}
|
||||
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);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user