Commit 67d162e8 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Lee Jones

leds: bcm6328: 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>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarLee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20230103131256.33894-5-andriy.shevchenko@linux.intel.com
parent 5ff422a7
...@@ -330,7 +330,9 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, ...@@ -330,7 +330,9 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
{ {
struct led_init_data init_data = {}; struct led_init_data init_data = {};
struct bcm6328_led *led; struct bcm6328_led *led;
const char *state; enum led_default_state state;
unsigned long val, shift;
void __iomem *mode;
int rc; int rc;
led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
...@@ -346,31 +348,29 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, ...@@ -346,31 +348,29 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
if (of_property_read_bool(nc, "active-low")) if (of_property_read_bool(nc, "active-low"))
led->active_low = true; led->active_low = true;
if (!of_property_read_string(nc, "default-state", &state)) { init_data.fwnode = of_fwnode_handle(nc);
if (!strcmp(state, "on")) {
state = led_init_default_state_get(init_data.fwnode);
switch (state) {
case LEDS_DEFSTATE_ON:
led->cdev.brightness = LED_FULL;
break;
case LEDS_DEFSTATE_KEEP:
shift = bcm6328_pin2shift(led->pin);
if (shift / 16)
mode = mem + BCM6328_REG_MODE_HI;
else
mode = mem + BCM6328_REG_MODE_LO;
val = bcm6328_led_read(mode) >> BCM6328_LED_SHIFT(shift % 16);
val &= BCM6328_LED_MODE_MASK;
if ((led->active_low && val == BCM6328_LED_MODE_OFF) ||
(!led->active_low && val == BCM6328_LED_MODE_ON))
led->cdev.brightness = LED_FULL; led->cdev.brightness = LED_FULL;
} else if (!strcmp(state, "keep")) { else
void __iomem *mode;
unsigned long val, shift;
shift = bcm6328_pin2shift(led->pin);
if (shift / 16)
mode = mem + BCM6328_REG_MODE_HI;
else
mode = mem + BCM6328_REG_MODE_LO;
val = bcm6328_led_read(mode) >>
BCM6328_LED_SHIFT(shift % 16);
val &= BCM6328_LED_MODE_MASK;
if ((led->active_low && val == BCM6328_LED_MODE_OFF) ||
(!led->active_low && val == BCM6328_LED_MODE_ON))
led->cdev.brightness = LED_FULL;
else
led->cdev.brightness = LED_OFF;
} else {
led->cdev.brightness = LED_OFF; led->cdev.brightness = LED_OFF;
} break;
} else { default:
led->cdev.brightness = LED_OFF; led->cdev.brightness = LED_OFF;
} }
...@@ -378,7 +378,6 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, ...@@ -378,7 +378,6 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
led->cdev.brightness_set = bcm6328_led_set; led->cdev.brightness_set = bcm6328_led_set;
led->cdev.blink_set = bcm6328_blink_set; led->cdev.blink_set = bcm6328_blink_set;
init_data.fwnode = of_fwnode_handle(nc);
rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); rc = devm_led_classdev_register_ext(dev, &led->cdev, &init_data);
if (rc < 0) if (rc < 0)
......
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