From ee522bcf026ec82ada793979c3a906274430595a Mon Sep 17 00:00:00 2001 From: Yang Yingliang Date: Tue, 6 Apr 2021 21:11:59 +0800 Subject: [PATCH 01/36] leds: tlc591xx: fix return value check in tlc591xx_probe() After device_get_match_data(), tlc591xx is not checked, add check for it and also check np after dev_of_node. Reported-by: Hulk Robot Signed-off-by: Yang Yingliang Signed-off-by: Pavel Machek --- drivers/leds/leds-tlc591xx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c index 5b9dfdf743ec..cb7bd1353f9f 100644 --- a/drivers/leds/leds-tlc591xx.c +++ b/drivers/leds/leds-tlc591xx.c @@ -148,16 +148,20 @@ static int tlc591xx_probe(struct i2c_client *client, const struct i2c_device_id *id) { - struct device_node *np = dev_of_node(&client->dev), *child; + struct device_node *np, *child; struct device *dev = &client->dev; const struct tlc591xx *tlc591xx; struct tlc591xx_priv *priv; int err, count, reg; - tlc591xx = device_get_match_data(dev); + np = dev_of_node(dev); if (!np) return -ENODEV; + tlc591xx = device_get_match_data(dev); + if (!tlc591xx) + return -ENODEV; + count = of_get_available_child_count(np); if (!count || count > tlc591xx->max_leds) return -EINVAL; From c10074a1e5809ebce7f9cdaadbb820b8b447d5ad Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 28 May 2021 10:06:15 +0100 Subject: [PATCH 02/36] leds: trigger: ledtrig-cpu: Fix incorrectly documented param 'ledevt' Fixes the following W=1 kernel build warning(s): drivers/leds/trigger/ledtrig-cpu.c:52: warning: Function parameter or member 'ledevt' not described in 'ledtrig_cpu' drivers/leds/trigger/ledtrig-cpu.c:52: warning: Excess function parameter 'evt' description in 'ledtrig_cpu' Cc: Pavel Machek Cc: Linus Walleij Cc: Bryan Wu Cc: linux-leds@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Pavel Machek --- drivers/leds/trigger/ledtrig-cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/trigger/ledtrig-cpu.c b/drivers/leds/trigger/ledtrig-cpu.c index fca62d503590..8af4f9bb9cde 100644 --- a/drivers/leds/trigger/ledtrig-cpu.c +++ b/drivers/leds/trigger/ledtrig-cpu.c @@ -43,7 +43,7 @@ static atomic_t num_active_cpus = ATOMIC_INIT(0); /** * ledtrig_cpu - emit a CPU event as a trigger - * @evt: CPU event to be emitted + * @ledevt: CPU event to be emitted * * Emit a CPU event on a CPU core, which will trigger a * bound LED to turn on or turn off. From c5a87a4ac2bfecd146d7a2653481e5cea4bf76fe Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 28 May 2021 10:06:16 +0100 Subject: [PATCH 03/36] leds: leds-gpio-register: Supply description for param 'id' Fixes the following W=1 kernel build warning(s): drivers/leds/leds-gpio-register.c:24: warning: Function parameter or member 'id' not described in 'gpio_led_register_device' Cc: Pavel Machek Cc: Uwe Kleine-Koenig Cc: linux-leds@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Pavel Machek --- drivers/leds/leds-gpio-register.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/leds/leds-gpio-register.c b/drivers/leds/leds-gpio-register.c index b9187e71e0cf..de3f12c2b80d 100644 --- a/drivers/leds/leds-gpio-register.c +++ b/drivers/leds/leds-gpio-register.c @@ -11,6 +11,7 @@ /** * gpio_led_register_device - register a gpio-led device * @pdata: the platform data used for the new device + * @id: platform ID * * Makes a copy of pdata and pdata->leds and registers a new leds-gpio device * with the result. This allows to have pdata and pdata-leds in .init.rodata From 6a3a871b4baa4fe983038a3a64c05a55ce640797 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 28 May 2021 10:06:17 +0100 Subject: [PATCH 04/36] leds: led-class: Fix incorrectly documented param 'dev' Fixes the following W=1 kernel build warning(s): drivers/leds/led-class.c:521: warning: Function parameter or member 'dev' not described in 'devm_led_classdev_unregister' drivers/leds/led-class.c:521: warning: Excess function parameter 'parent' description in 'devm_led_classdev_unregister' Cc: Pavel Machek Cc: John Lenz Cc: Richard Purdie Cc: linux-leds@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Pavel Machek --- drivers/leds/led-class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 2e495ff67856..16271a1de12a 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -513,7 +513,7 @@ static int devm_led_classdev_match(struct device *dev, void *res, void *data) /** * devm_led_classdev_unregister() - resource managed led_classdev_unregister() - * @parent: The device to unregister. + * @dev: The device to unregister. * @led_cdev: the led_classdev structure for this device. */ void devm_led_classdev_unregister(struct device *dev, From 2c175615cdfb5cc45c1b0903722ca2bc26bf6f79 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 28 May 2021 10:06:18 +0100 Subject: [PATCH 05/36] leds: leds-bcm6328: Demote kernel-doc abuse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following W=1 kernel build warning(s): drivers/leds/leds-bcm6328.c:97: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst Cc: Pavel Machek Cc: "Fernández Rojas" Cc: Jonas Gorski Cc: linux-leds@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Pavel Machek --- drivers/leds/leds-bcm6328.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c index 226d17d253ed..2d4d87957a30 100644 --- a/drivers/leds/leds-bcm6328.c +++ b/drivers/leds/leds-bcm6328.c @@ -93,7 +93,7 @@ static unsigned long bcm6328_led_read(void __iomem *reg) #endif } -/** +/* * LEDMode 64 bits / 24 LEDs * bits [31:0] -> LEDs 8-23 * bits [47:32] -> LEDs 0-7 From da9c6564d5c52c3a946cc54acd0e9460c006f6f4 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 28 May 2021 10:06:19 +0100 Subject: [PATCH 06/36] leds: leds-as3645a: Fix function name 'as3645a_set_current()' Fixes the following W=1 kernel build warning(s): drivers/leds/leds-as3645a.c:198: warning: expecting prototype for as3645a_set_config(). Prototype was for as3645a_set_current() instead Cc: Sakari Ailus Cc: Pavel Machek Cc: Laurent Pinchart Cc: linux-leds@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Pavel Machek --- drivers/leds/leds-as3645a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c index e8922fa03379..c41937ff8fd3 100644 --- a/drivers/leds/leds-as3645a.c +++ b/drivers/leds/leds-as3645a.c @@ -185,7 +185,7 @@ static int as3645a_read(struct as3645a *flash, u8 addr) */ /** - * as3645a_set_config - Set flash configuration registers + * as3645a_set_current - Set flash configuration registers * @flash: The flash * * Configure the hardware with flash, assist and indicator currents, as well as From 69f0027e0cb1bf0adb68172896759c94745932a4 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 28 May 2021 10:06:20 +0100 Subject: [PATCH 07/36] leds: leds-blinkm: Remove unused variable 'ret' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Function returns void anyway. Fixes the following W=1 kernel build warning(s): drivers/leds/leds-blinkm.c: In function ‘blinkm_init_hw’: drivers/leds/leds-blinkm.c:483:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable] Cc: Jan-Simon Moeller Cc: Pavel Machek Cc: "Jan-Simon Möller" Cc: linux-leds@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Pavel Machek --- drivers/leds/leds-blinkm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/leds/leds-blinkm.c b/drivers/leds/leds-blinkm.c index b4e1fdff4186..bd7d0d5cf3b6 100644 --- a/drivers/leds/leds-blinkm.c +++ b/drivers/leds/leds-blinkm.c @@ -480,9 +480,8 @@ static int blinkm_led_blue_set(struct led_classdev *led_cdev, static void blinkm_init_hw(struct i2c_client *client) { - int ret; - ret = blinkm_transfer_hw(client, BLM_STOP_SCRIPT); - ret = blinkm_transfer_hw(client, BLM_GO_RGB); + blinkm_transfer_hw(client, BLM_STOP_SCRIPT); + blinkm_transfer_hw(client, BLM_GO_RGB); } static int blinkm_test_run(struct i2c_client *client) From bf588389939e0f9a73f06bcd533f5b9adc5556cd Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 28 May 2021 10:06:21 +0100 Subject: [PATCH 08/36] leds: leds-is31fl32xx: Provide missing description for member 'sw_shutdown_func' Fixes the following W=1 kernel build warning(s): drivers/leds/leds-is31fl32xx.c:85: warning: Function parameter or member 'sw_shutdown_func' not described in 'is31fl32xx_chipdef' Cc: Pavel Machek Cc: David Rivshin Cc: linux-leds@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Pavel Machek --- drivers/leds/leds-is31fl32xx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/leds/leds-is31fl32xx.c b/drivers/leds/leds-is31fl32xx.c index 2180255ad339..3b55af9a8c58 100644 --- a/drivers/leds/leds-is31fl32xx.c +++ b/drivers/leds/leds-is31fl32xx.c @@ -58,7 +58,8 @@ struct is31fl32xx_priv { * @pwm_registers_reversed: : true if PWM registers count down instead of up * @led_control_register_base : address of first LED control register (optional) * @enable_bits_per_led_control_register: number of LEDs enable bits in each - * @reset_func: : pointer to reset function + * @reset_func : pointer to reset function + * @sw_shutdown_func : pointer to software shutdown function * * For all optional register addresses, the sentinel value %IS31FL32XX_REG_NONE * indicates that this chip has no such register. From 9933bde2932cc971db6871d0827b7ad78d962d61 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 28 May 2021 10:06:22 +0100 Subject: [PATCH 09/36] leds: leds-lp3944: Provide missing function names in documentation headers Fixes the following W=1 kernel build warning(s): drivers/leds/leds-lp3944.c:95: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst drivers/leds/leds-lp3944.c:126: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst drivers/leds/leds-lp3944.c:158: warning: This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst Cc: Pavel Machek Cc: Antonio Ospite Cc: linux-leds@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Pavel Machek --- drivers/leds/leds-lp3944.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/leds/leds-lp3944.c b/drivers/leds/leds-lp3944.c index 838e6f19d37e..437c711b2a27 100644 --- a/drivers/leds/leds-lp3944.c +++ b/drivers/leds/leds-lp3944.c @@ -92,7 +92,7 @@ static int lp3944_reg_write(struct i2c_client *client, u8 reg, u8 value) } /** - * Set the period for DIM status + * lp3944_dim_set_period() - Set the period for DIM status * * @client: the i2c client * @dim: either LP3944_DIM0 or LP3944_DIM1 @@ -123,7 +123,7 @@ static int lp3944_dim_set_period(struct i2c_client *client, u8 dim, u16 period) } /** - * Set the duty cycle for DIM status + * lp3944_dim_set_dutycycle - Set the duty cycle for DIM status * * @client: the i2c client * @dim: either LP3944_DIM0 or LP3944_DIM1 @@ -155,7 +155,7 @@ static int lp3944_dim_set_dutycycle(struct i2c_client *client, u8 dim, } /** - * Set the led status + * lp3944_led_set() - Set the led status * * @led: a lp3944_led_data structure * @status: one of LP3944_LED_STATUS_OFF From 2906aecb9aca8e48668da0ad112d0c0e7ff4e4d4 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 28 May 2021 10:06:23 +0100 Subject: [PATCH 10/36] leds: leds-lm3530: Fix incorrect spelling of 'brightness' Fixes the following W=1 kernel build warning(s): drivers/leds/leds-lm3530.c:113: warning: Function parameter or member 'brightness' not described in 'lm3530_data' Cc: Pavel Machek Cc: Kumar SAHU Cc: Dan Murphy Cc: linux-leds@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Pavel Machek --- drivers/leds/leds-lm3530.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-lm3530.c b/drivers/leds/leds-lm3530.c index 2db455efd4b1..e72393534b72 100644 --- a/drivers/leds/leds-lm3530.c +++ b/drivers/leds/leds-lm3530.c @@ -99,7 +99,7 @@ static struct lm3530_mode_map mode_map[] = { * @pdata: LM3530 platform data * @mode: mode of operation - manual, ALS, PWM * @regulator: regulator - * @brighness: previous brightness value + * @brightness: previous brightness value * @enable: regulator is enabled */ struct lm3530_data { From 406a0c2c546c162f18ca5c435bc3a61ec5e25890 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 28 May 2021 10:06:24 +0100 Subject: [PATCH 11/36] leds: leds-lm3692x: Fix some kernel-doc formatting issues Fixes the following W=1 kernel build warning(s): drivers/leds/leds-lm3692x.c:121: warning: Function parameter or member 'lock' not described in 'lm3692x_led' drivers/leds/leds-lm3692x.c:121: warning: Function parameter or member 'client' not described in 'lm3692x_led' drivers/leds/leds-lm3692x.c:121: warning: Function parameter or member 'led_dev' not described in 'lm3692x_led' drivers/leds/leds-lm3692x.c:121: warning: Function parameter or member 'regmap' not described in 'lm3692x_led' drivers/leds/leds-lm3692x.c:121: warning: Function parameter or member 'enable_gpio' not described in 'lm3692x_led' drivers/leds/leds-lm3692x.c:121: warning: Function parameter or member 'regulator' not described in 'lm3692x_led' drivers/leds/leds-lm3692x.c:121: warning: Function parameter or member 'led_enable' not described in 'lm3692x_led' drivers/leds/leds-lm3692x.c:121: warning: Function parameter or member 'model_id' not described in 'lm3692x_led' drivers/leds/leds-lm3692x.c:121: warning: Function parameter or member 'boost_ctrl' not described in 'lm3692x_led' drivers/leds/leds-lm3692x.c:121: warning: Function parameter or member 'brightness_ctrl' not described in 'lm3692x_led' drivers/leds/leds-lm3692x.c:121: warning: Function parameter or member 'enabled' not described in 'lm3692x_led' Cc: Pavel Machek Cc: Liam Girdwood Cc: Mark Brown Cc: Dan Murphy Cc: linux-leds@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Pavel Machek --- drivers/leds/leds-lm3692x.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c index e945de45388c..a2ab6bd5de11 100644 --- a/drivers/leds/leds-lm3692x.c +++ b/drivers/leds/leds-lm3692x.c @@ -96,15 +96,15 @@ #define LM3692X_FAULT_FLAG_OPEN BIT(4) /** - * struct lm3692x_led - - * @lock - Lock for reading/writing the device - * @client - Pointer to the I2C client - * @led_dev - LED class device pointer - * @regmap - Devices register map - * @enable_gpio - VDDIO/EN gpio to enable communication interface - * @regulator - LED supply regulator pointer - * @led_enable - LED sync to be enabled - * @model_id - Current device model ID enumerated + * struct lm3692x_led + * @lock: Lock for reading/writing the device + * @client: Pointer to the I2C client + * @led_dev: LED class device pointer + * @regmap: Devices register map + * @enable_gpio: VDDIO/EN gpio to enable communication interface + * @regulator: LED supply regulator pointer + * @led_enable: LED sync to be enabled + * @model_id: Current device model ID enumerated */ struct lm3692x_led { struct mutex lock; From 6e174d3911f15807f558e2e37f12b5e142e5b492 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 28 May 2021 10:06:25 +0100 Subject: [PATCH 12/36] leds: leds-lm3697: Provide some missing descriptions for struct members Fixes the following W=1 kernel build warning(s): drivers/leds/leds-lm3697.c:60: warning: Function parameter or member 'enabled' not described in 'lm3697_led' drivers/leds/leds-lm3697.c:60: warning: Function parameter or member 'num_leds' not described in 'lm3697_led' drivers/leds/leds-lm3697.c:84: warning: Function parameter or member 'bank_cfg' not described in 'lm3697' drivers/leds/leds-lm3697.c:84: warning: Function parameter or member 'num_banks' not described in 'lm3697' Cc: Pavel Machek Cc: Dan Murphy Cc: linux-leds@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Pavel Machek --- drivers/leds/leds-lm3697.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/leds/leds-lm3697.c b/drivers/leds/leds-lm3697.c index 7d216cdb91a8..0d10d1213447 100644 --- a/drivers/leds/leds-lm3697.c +++ b/drivers/leds/leds-lm3697.c @@ -47,6 +47,8 @@ * @lmu_data: Register and setting values for common code * @control_bank: Control bank the LED is associated to. 0 is control bank A * 1 is control bank B + * @enabled: LED brightness level (or LED_OFF) + * @num_leds: Number of LEDs available */ struct lm3697_led { u32 hvled_strings[LM3697_MAX_LED_STRINGS]; @@ -68,6 +70,8 @@ struct lm3697_led { * @dev: Pointer to the devices device struct * @lock: Lock for reading/writing the device * @leds: Array of LED strings + * @bank_cfg: OUTPUT_CONFIG register values + * @num_banks: Number of control banks */ struct lm3697 { struct gpio_desc *enable_gpio; From aedc13573c537f65424c5ad28ecf7078038d6975 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 28 May 2021 10:06:26 +0100 Subject: [PATCH 13/36] leds: leds-mlxreg: Fix incorrect documentation of struct member 'led_cdev' and 'led_cdev_name' Fixes the following W=1 kernel build warning(s): drivers/leds/leds-mlxreg.c:42: warning: Function parameter or member 'led_cdev' not described in 'mlxreg_led_data' drivers/leds/leds-mlxreg.c:42: warning: Function parameter or member 'led_cdev_name' not described in 'mlxreg_led_data' Cc: Vadim Pasternak Cc: Pavel Machek Cc: linux-leds@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Pavel Machek --- drivers/leds/leds-mlxreg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/leds/leds-mlxreg.c b/drivers/leds/leds-mlxreg.c index 82aea1cd0c12..b7855c93bd72 100644 --- a/drivers/leds/leds-mlxreg.c +++ b/drivers/leds/leds-mlxreg.c @@ -28,10 +28,11 @@ * struct mlxreg_led_data - led control data: * * @data: led configuration data; - * @led_classdev: led class data; + * @led_cdev: led class data; * @base_color: base led color (other colors have constant offset from base); * @led_data: led data; * @data_parent: pointer to private device control data of parent; + * @led_cdev_name: class device name */ struct mlxreg_led_data { struct mlxreg_core_data *data; From 46cc5941a091bd4f5e2c8d89006752710153ef74 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 28 May 2021 10:06:27 +0100 Subject: [PATCH 14/36] leds: leds-lp8860: Fix kernel-doc related formatting issues Fixes the following W=1 kernel build warning(s): drivers/leds/leds-lp8860.c:105: warning: Function parameter or member 'lock' not described in 'lp8860_led' drivers/leds/leds-lp8860.c:105: warning: Function parameter or member 'client' not described in 'lp8860_led' drivers/leds/leds-lp8860.c:105: warning: Function parameter or member 'led_dev' not described in 'lp8860_led' drivers/leds/leds-lp8860.c:105: warning: Function parameter or member 'regmap' not described in 'lp8860_led' drivers/leds/leds-lp8860.c:105: warning: Function parameter or member 'eeprom_regmap' not described in 'lp8860_led' drivers/leds/leds-lp8860.c:105: warning: Function parameter or member 'enable_gpio' not described in 'lp8860_led' drivers/leds/leds-lp8860.c:105: warning: Function parameter or member 'regulator' not described in 'lp8860_led' Cc: Pavel Machek Cc: Dan Murphy Cc: linux-leds@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Pavel Machek --- drivers/leds/leds-lp8860.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/leds/leds-lp8860.c b/drivers/leds/leds-lp8860.c index f0533a337bc1..3c693d5e3b44 100644 --- a/drivers/leds/leds-lp8860.c +++ b/drivers/leds/leds-lp8860.c @@ -85,14 +85,14 @@ #define LP8860_NAME "lp8860" /** - * struct lp8860_led - - * @lock - Lock for reading/writing the device - * @client - Pointer to the I2C client - * @led_dev - led class device pointer - * @regmap - Devices register map - * @eeprom_regmap - EEPROM register map - * @enable_gpio - VDDIO/EN gpio to enable communication interface - * @regulator - LED supply regulator pointer + * struct lp8860_led + * @lock: Lock for reading/writing the device + * @client: Pointer to the I2C client + * @led_dev: led class device pointer + * @regmap: Devices register map + * @eeprom_regmap: EEPROM register map + * @enable_gpio: VDDIO/EN gpio to enable communication interface + * @regulator: LED supply regulator pointer */ struct lp8860_led { struct mutex lock; From db30c91add87fb49a63798e204c467e611dc2718 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Fri, 28 May 2021 10:06:29 +0100 Subject: [PATCH 15/36] leds: leds-mlxcpld: Fix a bunch of kernel-doc formatting issues Fixes the following W=1 kernel build warning(s): drivers/leds/leds-mlxcpld.c:72: warning: cannot understand function prototype: 'struct mlxcpld_param ' drivers/leds/leds-mlxcpld.c:83: warning: cannot understand function prototype: 'struct mlxcpld_led_priv ' drivers/leds/leds-mlxcpld.c:98: warning: cannot understand function prototype: 'struct mlxcpld_led_profile ' drivers/leds/leds-mlxcpld.c:114: warning: cannot understand function prototype: 'struct mlxcpld_led_pdata ' Cc: Vadim Pasternak Cc: Pavel Machek Cc: linux-leds@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Pavel Machek --- drivers/leds/leds-mlxcpld.c | 38 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/leds/leds-mlxcpld.c b/drivers/leds/leds-mlxcpld.c index f4721f8065f0..1355c84a2919 100644 --- a/drivers/leds/leds-mlxcpld.c +++ b/drivers/leds/leds-mlxcpld.c @@ -64,10 +64,10 @@ #define MLXCPLD_LED_BLINK_6HZ 83 /* ~83 msec off/on */ /** - * mlxcpld_param - LED access parameters: - * @offset - offset for LED access in CPLD device - * @mask - mask for LED access in CPLD device - * @base_color - base color code for LED + * struct mlxcpld_param - LED access parameters: + * @offset: offset for LED access in CPLD device + * @mask: mask for LED access in CPLD device + * @base_color: base color code for LED **/ struct mlxcpld_param { u8 offset; @@ -76,9 +76,9 @@ struct mlxcpld_param { }; /** - * mlxcpld_led_priv - LED private data: - * @cled - LED class device instance - * @param - LED CPLD access parameters + * struct mlxcpld_led_priv - LED private data: + * @cled: LED class device instance + * @param: LED CPLD access parameters **/ struct mlxcpld_led_priv { struct led_classdev cdev; @@ -88,12 +88,12 @@ struct mlxcpld_led_priv { #define cdev_to_priv(c) container_of(c, struct mlxcpld_led_priv, cdev) /** - * mlxcpld_led_profile - system LED profile (defined per system class): - * @offset - offset for LED access in CPLD device - * @mask - mask for LED access in CPLD device - * @base_color - base color code - * @brightness - default brightness setting (on/off) - * @name - LED name + * struct mlxcpld_led_profile - system LED profile (defined per system class): + * @offset: offset for LED access in CPLD device + * @mask: mask for LED access in CPLD device + * @base_color: base color code + * @brightness: default brightness setting (on/off) + * @name: LED name **/ struct mlxcpld_led_profile { u8 offset; @@ -104,12 +104,12 @@ struct mlxcpld_led_profile { }; /** - * mlxcpld_led_pdata - system LED private data - * @pdev - platform device pointer - * @pled - LED class device instance - * @profile - system configuration profile - * @num_led_instances - number of LED instances - * @lock - device access lock + * struct mlxcpld_led_pdata - system LED private data + * @pdev: platform device pointer + * @pled: LED class device instance + * @profile: system configuration profile + * @num_led_instances: number of LED instances + * @lock: device access lock **/ struct mlxcpld_led_pdata { struct platform_device *pdev; From 0ac40af86077982a5346dbc9655172d2775d6b08 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 10 May 2021 12:50:18 +0300 Subject: [PATCH 16/36] leds: class: The -ENOTSUPP should never be seen by user space Drop the bogus error code and let of_led_get() to take care about absent of_node. Fixes: e389240ad992 ("leds: Add managed API to get a LED from a device driver") Cc: Jean-Jacques Hiblot Signed-off-by: Andy Shevchenko Signed-off-by: Pavel Machek --- drivers/leds/led-class.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 16271a1de12a..f704391d57a8 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -285,10 +285,6 @@ struct led_classdev *__must_check devm_of_led_get(struct device *dev, if (!dev) return ERR_PTR(-EINVAL); - /* Not using device tree? */ - if (!IS_ENABLED(CONFIG_OF) || !dev->of_node) - return ERR_PTR(-ENOTSUPP); - led = of_led_get(dev->of_node, index); if (IS_ERR(led)) return led; From a43a4e588e72bafc81924d61bf1167cd6810ecbb Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 10 May 2021 12:50:23 +0300 Subject: [PATCH 17/36] leds: el15203000: Introduce to_el15203000_led() helper Introduce a helper to replace open coded container_of() calls. At the same time move ldev member to be first in the struct el15203000_led, that makes container_of() effectivelly a no-op. Signed-off-by: Andy Shevchenko Signed-off-by: Pavel Machek --- drivers/leds/leds-el15203000.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/leds/leds-el15203000.c b/drivers/leds/leds-el15203000.c index 6ca47f2a2004..c82f5d11e16c 100644 --- a/drivers/leds/leds-el15203000.c +++ b/drivers/leds/leds-el15203000.c @@ -68,8 +68,8 @@ enum el15203000_command { }; struct el15203000_led { - struct el15203000 *priv; struct led_classdev ldev; + struct el15203000 *priv; u32 reg; }; @@ -82,6 +82,8 @@ struct el15203000 { struct el15203000_led leds[]; }; +#define to_el15203000_led(d) container_of(d, struct el15203000_led, ldev) + static int el15203000_cmd(struct el15203000_led *led, u8 brightness) { int ret; @@ -128,9 +130,7 @@ static int el15203000_cmd(struct el15203000_led *led, u8 brightness) static int el15203000_set_blocking(struct led_classdev *ldev, enum led_brightness brightness) { - struct el15203000_led *led = container_of(ldev, - struct el15203000_led, - ldev); + struct el15203000_led *led = to_el15203000_led(ldev); return el15203000_cmd(led, brightness == LED_OFF ? EL_OFF : EL_ON); } @@ -139,9 +139,7 @@ static int el15203000_pattern_set_S(struct led_classdev *ldev, struct led_pattern *pattern, u32 len, int repeat) { - struct el15203000_led *led = container_of(ldev, - struct el15203000_led, - ldev); + struct el15203000_led *led = to_el15203000_led(ldev); if (repeat > 0 || len != 2 || pattern[0].delta_t != 4000 || pattern[0].brightness != 0 || @@ -192,10 +190,8 @@ static int el15203000_pattern_set_P(struct led_classdev *ldev, struct led_pattern *pattern, u32 len, int repeat) { + struct el15203000_led *led = to_el15203000_led(ldev); u8 cmd; - struct el15203000_led *led = container_of(ldev, - struct el15203000_led, - ldev); if (repeat > 0) return -EINVAL; @@ -232,9 +228,7 @@ static int el15203000_pattern_set_P(struct led_classdev *ldev, static int el15203000_pattern_clear(struct led_classdev *ldev) { - struct el15203000_led *led = container_of(ldev, - struct el15203000_led, - ldev); + struct el15203000_led *led = to_el15203000_led(ldev); return el15203000_cmd(led, EL_OFF); } From fba8a6f2263bc54683cf3fd75df4dbd5d041c195 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 10 May 2021 12:50:24 +0300 Subject: [PATCH 18/36] leds: lgm-sso: Fix clock handling The clock handling has a few issues: - when getting second clock fails, the first one left prepared and enabled - on ->remove() clocks are unprepared and disabled twice Fix all these by converting to use bulk clock operations since both clocks are mandatory. Fixes: c3987cd2bca3 ("leds: lgm: Add LED controller driver for LGM SoC") Cc: Amireddy Mallikarjuna reddy Signed-off-by: Andy Shevchenko Signed-off-by: Pavel Machek --- drivers/leds/blink/leds-lgm-sso.c | 44 ++++++++++++------------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/drivers/leds/blink/leds-lgm-sso.c b/drivers/leds/blink/leds-lgm-sso.c index 6a63846d10b5..7d5f0bf2817a 100644 --- a/drivers/leds/blink/leds-lgm-sso.c +++ b/drivers/leds/blink/leds-lgm-sso.c @@ -132,8 +132,7 @@ struct sso_led_priv { struct regmap *mmap; struct device *dev; struct platform_device *pdev; - struct clk *gclk; - struct clk *fpid_clk; + struct clk_bulk_data clocks[2]; u32 fpid_clkrate; u32 gptc_clkrate; u32 freq[MAX_FREQ_RANK]; @@ -763,12 +762,11 @@ static int sso_probe_gpios(struct sso_led_priv *priv) return sso_gpio_gc_init(dev, priv); } -static void sso_clk_disable(void *data) +static void sso_clock_disable_unprepare(void *data) { struct sso_led_priv *priv = data; - clk_disable_unprepare(priv->fpid_clk); - clk_disable_unprepare(priv->gclk); + clk_bulk_disable_unprepare(ARRAY_SIZE(priv->clocks), priv->clocks); } static int intel_sso_led_probe(struct platform_device *pdev) @@ -785,36 +783,30 @@ static int intel_sso_led_probe(struct platform_device *pdev) priv->dev = dev; /* gate clock */ - priv->gclk = devm_clk_get(dev, "sso"); - if (IS_ERR(priv->gclk)) { - dev_err(dev, "get sso gate clock failed!\n"); - return PTR_ERR(priv->gclk); - } + priv->clocks[0].id = "sso"; - ret = clk_prepare_enable(priv->gclk); + /* fpid clock */ + priv->clocks[1].id = "fpid"; + + ret = devm_clk_bulk_get(dev, ARRAY_SIZE(priv->clocks), priv->clocks); if (ret) { - dev_err(dev, "Failed to prepare/enable sso gate clock!\n"); + dev_err(dev, "Getting clocks failed!\n"); return ret; } - priv->fpid_clk = devm_clk_get(dev, "fpid"); - if (IS_ERR(priv->fpid_clk)) { - dev_err(dev, "Failed to get fpid clock!\n"); - return PTR_ERR(priv->fpid_clk); - } - - ret = clk_prepare_enable(priv->fpid_clk); + ret = clk_bulk_prepare_enable(ARRAY_SIZE(priv->clocks), priv->clocks); if (ret) { - dev_err(dev, "Failed to prepare/enable fpid clock!\n"); + dev_err(dev, "Failed to prepare and enable clocks!\n"); return ret; } - priv->fpid_clkrate = clk_get_rate(priv->fpid_clk); - ret = devm_add_action_or_reset(dev, sso_clk_disable, priv); - if (ret) { - dev_err(dev, "Failed to devm_add_action_or_reset, %d\n", ret); + ret = devm_add_action_or_reset(dev, sso_clock_disable_unprepare, priv); + if (ret) return ret; - } + + priv->fpid_clkrate = clk_get_rate(priv->clocks[1].clk); + + priv->mmap = syscon_node_to_regmap(dev->of_node); priv->mmap = syscon_node_to_regmap(dev->of_node); if (IS_ERR(priv->mmap)) { @@ -859,8 +851,6 @@ static int intel_sso_led_remove(struct platform_device *pdev) sso_led_shutdown(led); } - clk_disable_unprepare(priv->fpid_clk); - clk_disable_unprepare(priv->gclk); regmap_exit(priv->mmap); return 0; From 2cbbe9c50d13b6417e0baf8e8475ed73d4d12c2d Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 10 May 2021 12:50:27 +0300 Subject: [PATCH 19/36] leds: lgm-sso: Remove unneeded of_match_ptr() LGM SSO is an OF dependent driver, so of_match_ptr() can be safely removed. Remove the unneeded of_match_ptr(). Signed-off-by: Andy Shevchenko Signed-off-by: Pavel Machek --- drivers/leds/blink/leds-lgm-sso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/blink/leds-lgm-sso.c b/drivers/leds/blink/leds-lgm-sso.c index 7d5f0bf2817a..0b5e19904fa4 100644 --- a/drivers/leds/blink/leds-lgm-sso.c +++ b/drivers/leds/blink/leds-lgm-sso.c @@ -868,7 +868,7 @@ static struct platform_driver intel_sso_led_driver = { .remove = intel_sso_led_remove, .driver = { .name = "lgm-ssoled", - .of_match_table = of_match_ptr(of_sso_led_match), + .of_match_table = of_sso_led_match, }, }; From f3e2b3825ffb034b001fbe283d7a32a56e41aca7 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 10 May 2021 12:50:29 +0300 Subject: [PATCH 20/36] leds: lgm-sso: Drop duplicate NULL check for GPIO operations Since GPIO operations are NULL-aware, we don't need to duplicate this check. Remove it and fold the rest of the code. Signed-off-by: Andy Shevchenko Signed-off-by: Pavel Machek --- drivers/leds/blink/leds-lgm-sso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/blink/leds-lgm-sso.c b/drivers/leds/blink/leds-lgm-sso.c index 0b5e19904fa4..885e1277cbbd 100644 --- a/drivers/leds/blink/leds-lgm-sso.c +++ b/drivers/leds/blink/leds-lgm-sso.c @@ -258,7 +258,7 @@ static void sso_led_brightness_set(struct led_classdev *led_cdev, 1 << desc->pin); } - if (!desc->hw_trig && led->gpiod) + if (!desc->hw_trig) gpiod_set_value(led->gpiod, val); } From 99be74f61cb0292b518f5e6d7e5c6611555c2ec7 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 10 May 2021 12:50:31 +0300 Subject: [PATCH 21/36] leds: lm3532: select regmap I2C API Regmap APIs should be selected, otherwise link can fail ERROR: modpost: "__devm_regmap_init_i2c" [drivers/leds/leds-lm3532.ko] undefined! Fixes: bc1b8492c764 ("leds: lm3532: Introduce the lm3532 LED driver") Cc: Dan Murphy Signed-off-by: Andy Shevchenko Signed-off-by: Pavel Machek --- drivers/leds/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 49d99cb084db..c81b1e60953c 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -199,6 +199,7 @@ config LEDS_LM3530 config LEDS_LM3532 tristate "LCD Backlight driver for LM3532" + select REGMAP_I2C depends on LEDS_CLASS depends on I2C help From 2f39f68cec0a19c0371c1e7cb149159810e87f64 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 10 May 2021 12:50:32 +0300 Subject: [PATCH 22/36] leds: lm3532: Make error handling more robust It's easy to miss necessary clean up, e.g. firmware node reference counting, during error path in ->probe(). Make it more robust by moving to a single point of return. Signed-off-by: Andy Shevchenko Signed-off-by: Pavel Machek --- drivers/leds/leds-lm3532.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c index 0bf25bdde02f..beb53040e09e 100644 --- a/drivers/leds/leds-lm3532.c +++ b/drivers/leds/leds-lm3532.c @@ -586,7 +586,6 @@ static int lm3532_parse_node(struct lm3532_data *priv) ret = fwnode_property_read_u32(child, "reg", &control_bank); if (ret) { dev_err(&priv->client->dev, "reg property missing\n"); - fwnode_handle_put(child); goto child_out; } @@ -601,7 +600,6 @@ static int lm3532_parse_node(struct lm3532_data *priv) &led->mode); if (ret) { dev_err(&priv->client->dev, "ti,led-mode property missing\n"); - fwnode_handle_put(child); goto child_out; } @@ -636,7 +634,6 @@ static int lm3532_parse_node(struct lm3532_data *priv) led->num_leds); if (ret) { dev_err(&priv->client->dev, "led-sources property missing\n"); - fwnode_handle_put(child); goto child_out; } @@ -647,7 +644,6 @@ static int lm3532_parse_node(struct lm3532_data *priv) if (ret) { dev_err(&priv->client->dev, "led register err: %d\n", ret); - fwnode_handle_put(child); goto child_out; } @@ -655,14 +651,15 @@ static int lm3532_parse_node(struct lm3532_data *priv) if (ret) { dev_err(&priv->client->dev, "register init err: %d\n", ret); - fwnode_handle_put(child); goto child_out; } i++; } + return 0; child_out: + fwnode_handle_put(child); return ret; } From 3c5f655c44bb65cb7e3c219d08c130ce5fa45d7f Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 10 May 2021 12:50:33 +0300 Subject: [PATCH 23/36] leds: lm36274: Put fwnode in error case during ->probe() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit device_get_next_child_node() bumps a reference counting of a returned variable. We have to balance it whenever we return to the caller. In the older code the same is implied with device_for_each_child_node(). Fixes: 11e1bbc116a7 ("leds: lm36274: Introduce the TI LM36274 LED driver") Fixes: a448fcf19c9c ("leds: lm36274: don't iterate through children since there is only one") Cc: Dan Murphy Cc: Marek Behún Signed-off-by: Andy Shevchenko Signed-off-by: Pavel Machek --- drivers/leds/leds-lm36274.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/leds/leds-lm36274.c b/drivers/leds/leds-lm36274.c index aadb03468a40..a23a9424c2f3 100644 --- a/drivers/leds/leds-lm36274.c +++ b/drivers/leds/leds-lm36274.c @@ -127,6 +127,7 @@ static int lm36274_probe(struct platform_device *pdev) ret = lm36274_init(chip); if (ret) { + fwnode_handle_put(init_data.fwnode); dev_err(chip->dev, "Failed to init the device\n"); return ret; } From e2e8e4e8187509a77cb6328d876d9c09c07c2e82 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 10 May 2021 12:50:34 +0300 Subject: [PATCH 24/36] leds: lm36274: Correct headers (of*.h -> mod_devicetable.h) There is no user of of*.h headers, but mod_devicetable.h. Update header block accordingly. Signed-off-by: Andy Shevchenko Signed-off-by: Pavel Machek --- drivers/leds/leds-lm36274.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-lm36274.c b/drivers/leds/leds-lm36274.c index a23a9424c2f3..90dc5cbebed4 100644 --- a/drivers/leds/leds-lm36274.c +++ b/drivers/leds/leds-lm36274.c @@ -7,8 +7,8 @@ #include #include #include +#include #include -#include #include #include From f55db1c7fadc2a29c9fa4ff3aec98dbb111f2206 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 10 May 2021 12:50:35 +0300 Subject: [PATCH 25/36] leds: lm3692x: Put fwnode in any case during ->probe() device_get_next_child_node() bumps a reference counting of a returned variable. We have to balance it whenever we return to the caller. Fixes: 9a5c1c64ac0a ("leds: lm3692x: Change DT calls to fwnode calls") Cc: Dan Murphy Signed-off-by: Andy Shevchenko Signed-off-by: Pavel Machek --- drivers/leds/leds-lm3692x.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/leds/leds-lm3692x.c b/drivers/leds/leds-lm3692x.c index a2ab6bd5de11..a02756d7ed8f 100644 --- a/drivers/leds/leds-lm3692x.c +++ b/drivers/leds/leds-lm3692x.c @@ -435,6 +435,7 @@ static int lm3692x_probe_dt(struct lm3692x_led *led) ret = fwnode_property_read_u32(child, "reg", &led->led_enable); if (ret) { + fwnode_handle_put(child); dev_err(&led->client->dev, "reg DT property missing\n"); return ret; } @@ -449,12 +450,11 @@ static int lm3692x_probe_dt(struct lm3692x_led *led) ret = devm_led_classdev_register_ext(&led->client->dev, &led->led_dev, &init_data); - if (ret) { + if (ret) dev_err(&led->client->dev, "led register err: %d\n", ret); - return ret; - } - return 0; + fwnode_handle_put(init_data.fwnode); + return ret; } static int lm3692x_probe(struct i2c_client *client, From 807553f8bf4afa673750e52905e0f9488179112f Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 10 May 2021 12:50:39 +0300 Subject: [PATCH 26/36] leds: lm3697: Don't spam logs when probe is deferred When requesting GPIO line the probe can be deferred. In such case don't spam logs with an error message. This can be achieved by switching to dev_err_probe(). Fixes: 5c1d824cda9f ("leds: lm3697: Introduce the lm3697 driver") Cc: Dan Murphy Signed-off-by: Andy Shevchenko Signed-off-by: Pavel Machek --- drivers/leds/leds-lm3697.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-lm3697.c b/drivers/leds/leds-lm3697.c index 0d10d1213447..970a4f34791b 100644 --- a/drivers/leds/leds-lm3697.c +++ b/drivers/leds/leds-lm3697.c @@ -207,11 +207,9 @@ static int lm3697_probe_dt(struct lm3697 *priv) priv->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); - if (IS_ERR(priv->enable_gpio)) { - ret = PTR_ERR(priv->enable_gpio); - dev_err(dev, "Failed to get enable gpio: %d\n", ret); - return ret; - } + if (IS_ERR(priv->enable_gpio)) + return dev_err_probe(dev, PTR_ERR(priv->enable_gpio), + "Failed to get enable GPIO\n"); priv->regulator = devm_regulator_get(dev, "vled"); if (IS_ERR(priv->regulator)) From f1e1d532da7e6ef355528a22fb97d9a8fbf76c4e Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 10 May 2021 12:50:40 +0300 Subject: [PATCH 27/36] leds: lp50xx: Put fwnode in error case during ->probe() fwnode_for_each_child_node() bumps a reference counting of a returned variable. We have to balance it whenever we return to the caller. OTOH, the successful iteration will drop reference count under the hood, no need to do it twice. Fixes: 242b81170fb8 ("leds: lp50xx: Add the LP50XX family of the RGB LED driver") Cc: Dan Murphy Signed-off-by: Andy Shevchenko Signed-off-by: Pavel Machek --- drivers/leds/leds-lp50xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-lp50xx.c b/drivers/leds/leds-lp50xx.c index 06230614fdc5..401df1e2e05d 100644 --- a/drivers/leds/leds-lp50xx.c +++ b/drivers/leds/leds-lp50xx.c @@ -490,6 +490,7 @@ static int lp50xx_probe_dt(struct lp50xx *priv) ret = fwnode_property_read_u32(led_node, "color", &color_id); if (ret) { + fwnode_handle_put(led_node); dev_err(priv->dev, "Cannot read color\n"); goto child_out; } @@ -512,7 +513,6 @@ static int lp50xx_probe_dt(struct lp50xx *priv) goto child_out; } i++; - fwnode_handle_put(child); } return 0; From d33e98a1f3ee76f38668304f9ffce49af07da77a Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 10 May 2021 12:50:42 +0300 Subject: [PATCH 28/36] leds: lt3593: Make use of device properties Device property API allows to gather device resources from different sources, such as ACPI. Convert the driver to unleash the power of device property API. Signed-off-by: Andy Shevchenko Signed-off-by: Pavel Machek --- drivers/leds/Kconfig | 1 - drivers/leds/leds-lt3593.c | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index c81b1e60953c..bdf16180f5ff 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -617,7 +617,6 @@ config LEDS_LT3593 tristate "LED driver for LT3593 controllers" depends on LEDS_CLASS depends on GPIOLIB || COMPILE_TEST - depends on OF help This option enables support for LEDs driven by a Linear Technology LT3593 controller. This controller uses a special one-wire pulse diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c index 68e06434ac08..3bb52d3165d9 100644 --- a/drivers/leds/leds-lt3593.c +++ b/drivers/leds/leds-lt3593.c @@ -7,8 +7,9 @@ #include #include #include +#include #include -#include +#include #define LED_LT3593_NAME "lt3593" @@ -68,9 +69,6 @@ static int lt3593_led_probe(struct platform_device *pdev) struct led_init_data init_data = {}; const char *tmp; - if (!dev_of_node(dev)) - return -ENODEV; - led_data = devm_kzalloc(dev, sizeof(*led_data), GFP_KERNEL); if (!led_data) return -ENOMEM; @@ -119,7 +117,7 @@ static struct platform_driver lt3593_led_driver = { .probe = lt3593_led_probe, .driver = { .name = "leds-lt3593", - .of_match_table = of_match_ptr(of_lt3593_leds_match), + .of_match_table = of_lt3593_leds_match, }, }; From 95138e01275e1af3f1fc2780fe1d9c6138b29c7a Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 10 May 2021 12:50:43 +0300 Subject: [PATCH 29/36] leds: pwm: Make error handling more robust It's easy to miss necessary clean up, e.g. firmware node reference counting, during error path in ->probe(). Make it more robust by moving to a single point of return. Signed-off-by: Andy Shevchenko Signed-off-by: Pavel Machek --- drivers/leds/leds-pwm.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c index f53f9309ca6c..d71e9fa5c8de 100644 --- a/drivers/leds/leds-pwm.c +++ b/drivers/leds/leds-pwm.c @@ -101,7 +101,7 @@ static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv) { struct fwnode_handle *fwnode; struct led_pwm led; - int ret = 0; + int ret; memset(&led, 0, sizeof(led)); @@ -111,8 +111,8 @@ static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv) led.name = to_of_node(fwnode)->name; if (!led.name) { - fwnode_handle_put(fwnode); - return -EINVAL; + ret = EINVAL; + goto err_child_out; } led.active_low = fwnode_property_read_bool(fwnode, @@ -121,12 +121,14 @@ static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv) &led.max_brightness); ret = led_pwm_add(dev, priv, &led, fwnode); - if (ret) { - fwnode_handle_put(fwnode); - break; - } + if (ret) + goto err_child_out; } + return 0; + +err_child_out: + fwnode_handle_put(fwnode); return ret; } From e1012160bbbca92d67c729f68108734b7d679db9 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 10 May 2021 12:50:21 +0300 Subject: [PATCH 30/36] leds: el15203000: Make error handling more robust It's easy to miss necessary clean up, e.g. firmware node reference counting, during error path in ->probe(). Make it more robust by moving to a single point of return. Signed-off-by: Andy Shevchenko Signed-off-by: Pavel Machek --- drivers/leds/leds-el15203000.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/leds/leds-el15203000.c b/drivers/leds/leds-el15203000.c index c82f5d11e16c..76b455e87574 100644 --- a/drivers/leds/leds-el15203000.c +++ b/drivers/leds/leds-el15203000.c @@ -245,16 +245,13 @@ static int el15203000_probe_dt(struct el15203000 *priv) ret = fwnode_property_read_u32(child, "reg", &led->reg); if (ret) { dev_err(priv->dev, "LED without ID number"); - fwnode_handle_put(child); - - break; + goto err_child_out; } if (led->reg > U8_MAX) { dev_err(priv->dev, "LED value %d is invalid", led->reg); - fwnode_handle_put(child); - - return -EINVAL; + ret = -EINVAL; + goto err_child_out; } led->priv = priv; @@ -276,14 +273,16 @@ static int el15203000_probe_dt(struct el15203000 *priv) dev_err(priv->dev, "failed to register LED device %s, err %d", led->ldev.name, ret); - fwnode_handle_put(child); - - break; + goto err_child_out; } led++; } + return 0; + +err_child_out: + fwnode_handle_put(child); return ret; } From e90abb95bc71566e2016964e98181557929f55f5 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Sun, 30 May 2021 23:32:28 +0300 Subject: [PATCH 31/36] leds: lm36274: Add missed property.h It appears that property.h has been included in some configurations implicitly, but in some it's not and hence build may fail. Add missed property.h explicitly. Fixes: e2e8e4e81875 ("leds: lm36274: Correct headers (of*.h -> mod_devicetable.h)") Reported-by: kernel test robot Signed-off-by: Andy Shevchenko Signed-off-by: Pavel Machek --- drivers/leds/leds-lm36274.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/leds/leds-lm36274.c b/drivers/leds/leds-lm36274.c index 90dc5cbebed4..e009b6d17915 100644 --- a/drivers/leds/leds-lm36274.c +++ b/drivers/leds/leds-lm36274.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include From a5d3d1adc95f4ac5968b7a77ee95a3abbbb96f49 Mon Sep 17 00:00:00 2001 From: Doug Zobel Date: Mon, 10 May 2021 15:40:00 -0500 Subject: [PATCH 32/36] leds: lp55xx: Initialize enable GPIO direction to output The "Convert to use GPIO descriptors" commit changed the initialization of the enable GPIO from GPIOF_DIR_OUT to GPIOD_ASIS. This breaks systems where the GPIO does not default to output. Changing the enable initialization to GPIOD_OUT_LOW. Signed-off-by: Doug Zobel Signed-off-by: Pavel Machek --- drivers/leds/leds-lp55xx-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 81de1346bf5d..d1657c46ee2f 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c @@ -694,7 +694,7 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, of_property_read_u8(np, "clock-mode", &pdata->clock_mode); pdata->enable_gpiod = devm_gpiod_get_optional(dev, "enable", - GPIOD_ASIS); + GPIOD_OUT_LOW); if (IS_ERR(pdata->enable_gpiod)) return ERR_CAST(pdata->enable_gpiod); From 9d0150db97583cfbb6b44cbe02241a1a48f90210 Mon Sep 17 00:00:00 2001 From: Zou Wei Date: Wed, 12 May 2021 14:49:18 +0800 Subject: [PATCH 33/36] leds: turris-omnia: add missing MODULE_DEVICE_TABLE This patch adds missing MODULE_DEVICE_TABLE definition which generates correct modalias for automatic loading of this driver when it is built as an external module. Reported-by: Hulk Robot Signed-off-by: Zou Wei Signed-off-by: Pavel Machek --- drivers/leds/leds-turris-omnia.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index 2f9a289ab245..1adfed1c0619 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -274,6 +274,7 @@ static const struct i2c_device_id omnia_id[] = { { "omnia", 0 }, { } }; +MODULE_DEVICE_TABLE(i2c, omnia_id); static struct i2c_driver omnia_leds_driver = { .probe = omnia_leds_probe, From 96a30960a2c5246c8ffebe8a3c9031f9df094d97 Mon Sep 17 00:00:00 2001 From: Zhen Lei Date: Sat, 15 May 2021 11:06:46 +0800 Subject: [PATCH 34/36] leds: as3645a: Fix error return code in as3645a_parse_node() Return error code -ENODEV rather than '0' when the indicator node can not be found. Fixes: a56ba8fbcb55 ("media: leds: as3645a: Add LED flash class driver") Reported-by: Hulk Robot Acked-by: Sakari Ailus Signed-off-by: Zhen Lei Signed-off-by: Pavel Machek --- drivers/leds/leds-as3645a.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c index c41937ff8fd3..aa3f82be0a9c 100644 --- a/drivers/leds/leds-as3645a.c +++ b/drivers/leds/leds-as3645a.c @@ -545,6 +545,7 @@ static int as3645a_parse_node(struct as3645a *flash, if (!flash->indicator_node) { dev_warn(&flash->client->dev, "can't find indicator node\n"); + rval = -ENODEV; goto out_err; } From ee78b9360e14c276f5ceaa4a0d06f790f04ccdad Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Fri, 21 May 2021 13:21:01 +0200 Subject: [PATCH 35/36] leds: ktd2692: Fix an error handling path In 'ktd2692_parse_dt()', if an error occurs after a successful 'regulator_enable()' call, we should call 'regulator_enable()'. This is the same in 'ktd2692_probe()', if an error occurs after a successful 'ktd2692_parse_dt()' call. Instead of adding 'regulator_enable()' in several places, implement a resource managed solution and simplify the remove function accordingly. Fixes: b7da8c5c725c ("leds: Add ktd2692 flash LED driver") Signed-off-by: Christophe JAILLET Signed-off-by: Pavel Machek --- drivers/leds/leds-ktd2692.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/leds/leds-ktd2692.c b/drivers/leds/leds-ktd2692.c index 632f10db4b3f..f341da1503a4 100644 --- a/drivers/leds/leds-ktd2692.c +++ b/drivers/leds/leds-ktd2692.c @@ -256,6 +256,17 @@ static void ktd2692_setup(struct ktd2692_context *led) | KTD2692_REG_FLASH_CURRENT_BASE); } +static void regulator_disable_action(void *_data) +{ + struct device *dev = _data; + struct ktd2692_context *led = dev_get_drvdata(dev); + int ret; + + ret = regulator_disable(led->regulator); + if (ret) + dev_err(dev, "Failed to disable supply: %d\n", ret); +} + static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev, struct ktd2692_led_config_data *cfg) { @@ -286,8 +297,14 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev, if (led->regulator) { ret = regulator_enable(led->regulator); - if (ret) + if (ret) { dev_err(dev, "Failed to enable supply: %d\n", ret); + } else { + ret = devm_add_action_or_reset(dev, + regulator_disable_action, dev); + if (ret) + return ret; + } } child_node = of_get_next_available_child(np, NULL); @@ -377,17 +394,9 @@ static int ktd2692_probe(struct platform_device *pdev) static int ktd2692_remove(struct platform_device *pdev) { struct ktd2692_context *led = platform_get_drvdata(pdev); - int ret; led_classdev_flash_unregister(&led->fled_cdev); - if (led->regulator) { - ret = regulator_disable(led->regulator); - if (ret) - dev_err(&pdev->dev, - "Failed to disable supply: %d\n", ret); - } - mutex_destroy(&led->lock); return 0; From 7b97174cc93fadb055258f4f8f3b964e9968e59f Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 14 Jun 2021 01:16:47 +0200 Subject: [PATCH 36/36] leds: lgm: Fix up includes This driver is including the legacy GPIO header but the only thing it is using from that header is the wrong define for GPIOF_DIR_OUT. Fix it up by using GPIO_LINE_DIRECTION_OUT and including the correct consumer and driver headers. Cc: Amireddy Mallikarjuna reddy Signed-off-by: Linus Walleij Signed-off-by: Pavel Machek --- drivers/leds/blink/leds-lgm-sso.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/leds/blink/leds-lgm-sso.c b/drivers/leds/blink/leds-lgm-sso.c index 885e1277cbbd..7eb2f44f16be 100644 --- a/drivers/leds/blink/leds-lgm-sso.c +++ b/drivers/leds/blink/leds-lgm-sso.c @@ -7,7 +7,8 @@ #include #include -#include +#include +#include #include #include #include @@ -422,7 +423,7 @@ static void sso_gpio_free(struct gpio_chip *chip, unsigned int offset) static int sso_gpio_get_dir(struct gpio_chip *chip, unsigned int offset) { - return GPIOF_DIR_OUT; + return GPIO_LINE_DIRECTION_OUT; } static int