Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

leds: spi-byte: 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>
Link: https://lore.kernel.org/r/20240606173037.3091598-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Andy Shevchenko and committed by
Lee Jones
4b268456 7f9ab862

+5 -12
+5 -12
drivers/leds/leds-spi-byte.c
··· 84 84 struct device *dev = &spi->dev; 85 85 struct spi_byte_led *led; 86 86 struct led_init_data init_data = {}; 87 - const char *state; 87 + enum led_default_state state; 88 88 int ret; 89 89 90 90 if (of_get_available_child_count(dev_of_node(dev)) != 1) { ··· 104 104 led->ldev.brightness_set_blocking = spi_byte_brightness_set_blocking; 105 105 106 106 child = of_get_next_available_child(dev_of_node(dev), NULL); 107 - state = of_get_property(child, "default-state", NULL); 108 - if (state) { 109 - if (!strcmp(state, "on")) { 110 - led->ldev.brightness = led->ldev.max_brightness; 111 - } else if (strcmp(state, "off")) { 112 - of_node_put(child); 113 - /* all other cases except "off" */ 114 - dev_err(dev, "default-state can only be 'on' or 'off'"); 115 - return -EINVAL; 116 - } 117 - } 107 + 108 + state = led_init_default_state_get(of_fwnode_handle(child)); 109 + if (state == LEDS_DEFSTATE_ON) 110 + led->ldev.brightness = led->ldev.max_brightness; 118 111 spi_byte_brightness_set_blocking(&led->ldev, 119 112 led->ldev.brightness); 120 113