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

leds: spi-byte: Make use of device properties

Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.

Add mod_devicetable.h include.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240606173037.3091598-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Andy Shevchenko and committed by
Lee Jones
67b66160 4b268456

+7 -9
-1
drivers/leds/Kconfig
··· 884 884 tristate "LED support for SPI LED controller with a single byte" 885 885 depends on LEDS_CLASS 886 886 depends on SPI 887 - depends on OF 888 887 help 889 888 This option enables support for LED controller which use a single byte 890 889 for controlling the brightness. Currently the following controller is
+7 -8
drivers/leds/leds-spi-byte.c
··· 29 29 */ 30 30 31 31 #include <linux/leds.h> 32 + #include <linux/mod_devicetable.h> 32 33 #include <linux/module.h> 33 - #include <linux/of.h> 34 + #include <linux/property.h> 34 35 #include <linux/spi/spi.h> 35 36 #include <linux/mutex.h> 36 37 #include <uapi/linux/uleds.h> ··· 81 80 82 81 static int spi_byte_probe(struct spi_device *spi) 83 82 { 84 - struct device_node *child; 83 + struct fwnode_handle *child __free(fwnode_handle) = NULL; 85 84 struct device *dev = &spi->dev; 86 85 struct spi_byte_led *led; 87 86 struct led_init_data init_data = {}; 88 87 enum led_default_state state; 89 88 int ret; 90 89 91 - if (of_get_available_child_count(dev_of_node(dev)) != 1) { 90 + if (device_get_child_node_count(dev) != 1) { 92 91 dev_err(dev, "Device must have exactly one LED sub-node."); 93 92 return -EINVAL; 94 93 } ··· 104 103 led->ldev.max_brightness = led->cdef->max_value - led->cdef->off_value; 105 104 led->ldev.brightness_set_blocking = spi_byte_brightness_set_blocking; 106 105 107 - child = of_get_next_available_child(dev_of_node(dev), NULL); 106 + child = device_get_next_child_node(dev, NULL); 108 107 109 - state = led_init_default_state_get(of_fwnode_handle(child)); 108 + state = led_init_default_state_get(child); 110 109 if (state == LEDS_DEFSTATE_ON) 111 110 led->ldev.brightness = led->ldev.max_brightness; 112 111 spi_byte_brightness_set_blocking(&led->ldev, 113 112 led->ldev.brightness); 114 113 115 - init_data.fwnode = of_fwnode_handle(child); 114 + init_data.fwnode = child; 116 115 init_data.devicename = "leds-spi-byte"; 117 116 init_data.default_label = ":"; 118 117 119 118 ret = devm_led_classdev_register_ext(&spi->dev, &led->ldev, &init_data); 120 119 if (ret) { 121 - of_node_put(child); 122 120 mutex_destroy(&led->mutex); 123 121 return ret; 124 122 } 125 123 126 - of_node_put(child); 127 124 spi_set_drvdata(spi, led); 128 125 129 126 return 0;