linux/drivers/video/backlight
Luca Ceresoli 08c9dc6b0f backlight: led-bl: Add devlink to supplier LEDs
[ Upstream commit 9341d6698f ]

LED Backlight is a consumer of one or multiple LED class devices, but
devlink is currently unable to create correct supplier-producer links when
the supplier is a class device. It creates instead a link where the
supplier is the parent of the expected device.

One consequence is that removal order is not correctly enforced.

Issues happen for example with the following sections in a device tree
overlay:

    // An LED driver chip
    pca9632@62 {
        compatible = "nxp,pca9632";
        reg = <0x62>;

	// ...

        addon_led_pwm: led-pwm@3 {
            reg = <3>;
            label = "addon:led:pwm";
        };
    };

    backlight-addon {
        compatible = "led-backlight";
        leds = <&addon_led_pwm>;
        brightness-levels = <255>;
        default-brightness-level = <255>;
    };

In this example, the devlink should be created between the backlight-addon
(consumer) and the pca9632@62 (supplier). Instead it is created between the
backlight-addon (consumer) and the parent of the pca9632@62, which is
typically the I2C bus adapter.

On removal of the above overlay, the LED driver can be removed before the
backlight device, resulting in:

    Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010
    ...
    Call trace:
     led_put+0xe0/0x140
     devm_led_release+0x6c/0x98

Another way to reproduce the bug without any device tree overlays is
unbinding the LED class device (pca9632@62) before unbinding the consumer
(backlight-addon):

  echo 11-0062 >/sys/bus/i2c/drivers/leds-pca963x/unbind
  echo ...backlight-dock >/sys/bus/platform/drivers/led-backlight/unbind

Fix by adding a devlink between the consuming led-backlight device and the
supplying LED device, as other drivers and subsystems do as well.

Fixes: ae232e45ac ("backlight: add led-backlight driver")
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Reviewed-by: Daniel Thompson (RISCstar) <danielt@kernel.org>
Reviewed-by: Herve Codina <herve.codina@bootlin.com>
Tested-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Link: https://patch.msgid.link/20250519-led-backlight-add-devlink-to-supplier-class-device-v6-1-845224aeb2ce@bootlin.com
Signed-off-by: Lee Jones <lee@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-12-18 14:03:17 +01:00
..
88pm860x_bl.c backlight: 88pm860x_bl: Do not include <linux/fb.h> 2025-02-11 10:20:18 +00:00
aat2870_bl.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
adp5520_bl.c backlight: adp5520_bl: Do not include <linux/fb.h> 2025-02-11 10:20:18 +00:00
adp8860_bl.c backlight: adp8860_bl: Do not include <linux/fb.h> 2025-02-11 10:20:18 +00:00
adp8870_bl.c backlight: adp8870_bl: Do not include <linux/fb.h> 2025-02-11 10:20:18 +00:00
ams369fg06.c backlight: ams369fb06: Use backlight power constants 2024-07-04 16:45:25 +01:00
apple_bl.c backlight: apple_bl: Use acpi_video_get_backlight_type() 2023-03-16 13:33:11 +01:00
apple_dwi_bl.c backlight: apple_dwi_bl: Include <linux/mod_devicetable.h> 2025-09-16 17:05:19 +01:00
arcxcnn_bl.c backlight: Switch i2c drivers back to use .probe() 2023-05-25 12:25:26 +01:00
as3711_bl.c backlight: as3711_bl: Include <linux/of.h> 2025-09-16 17:05:19 +01:00
backlight.c backlight: Include <linux/of.h> 2025-09-16 17:05:19 +01:00
bd6107.c backlight: bd6107_bl: Do not include <linux/fb.h> 2025-02-11 10:20:18 +00:00
corgi_lcd.c backlight: lcd: Remove struct fb_videomode from set_mode callback 2024-09-30 16:49:42 +01:00
da903x_bl.c backlight: da903x_bl: Do not include <linux/fb.h> 2025-02-11 10:20:18 +00:00
da9052_bl.c backlight: da9052_bl: Include <linux/mod_devicetable.h> 2025-09-16 17:05:19 +01:00
ep93xx_bl.c backlight: ep93xx_bl: Do not include <linux/fb.h> 2025-02-11 10:20:18 +00:00
gpio_backlight.c backlight: gpio-backlight: Use backlight power constants 2024-07-04 16:45:25 +01:00
hp680_bl.c backlight: hp680_bl: Do not include <linux/fb.h> 2025-02-11 10:20:18 +00:00
hx8357.c backlight: hx8357: Use lcd power constants 2024-09-30 16:49:41 +01:00
ili922x.c backlight: ili922x: Use lcd power constants 2024-09-30 16:49:41 +01:00
ili9320.c backlight: ili9320: Use lcd power constants 2024-09-30 16:49:41 +01:00
ili9320.h video: backlight: ili9320: Make ili9320_remove() return void 2021-10-20 15:13:59 +01:00
ipaq_micro_bl.c backlight: ipaq-micro-backlight: Use backlight power constants 2024-07-04 16:45:25 +01:00
jornada720_bl.c backlight: jornada720: Include <linux/io.h> 2025-09-16 17:05:19 +01:00
jornada720_lcd.c backlight: jornada720_lcd: Use lcd power constants 2024-09-30 16:49:41 +01:00
kb3886_bl.c backlight: kb3886-bl: Use backlight power constants 2024-07-04 16:45:25 +01:00
Kconfig backlight: pcf50633-backlight: Remove unused driver 2025-03-14 11:36:33 +00:00
ktd253-backlight.c backlight: ktd253-backlight: Use backlight power constants 2024-07-04 16:45:25 +01:00
ktd2801-backlight.c backlight: ktd2801: Include <linux/mod_devicetable.h> 2025-09-16 17:05:19 +01:00
ktz8866.c backlight: ktz8866: Fix module autoloading 2024-10-02 13:46:34 +01:00
l4f00242t03.c backlight: l4f00242t03: Use lcd power constants 2024-09-30 16:49:41 +01:00
lcd.c backlight: lcd: Replace fb events with a dedicated function call 2025-04-10 10:39:10 +01:00
led_bl.c backlight: led-bl: Add devlink to supplier LEDs 2025-12-18 14:03:17 +01:00
lm3509_bl.c backlight: lm3509_bl: Fix early returns in for_each_child_of_node() 2024-06-26 16:49:59 +01:00
lm3533_bl.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
lm3630a_bl.c backlight: Drop explicit initialization of struct i2c_device_id::driver_data to 0 2024-06-20 18:36:25 +01:00
lm3639_bl.c backlight: Drop explicit initialization of struct i2c_device_id::driver_data to 0 2024-06-20 18:36:25 +01:00
lms283gf05.c backlight: lms283gf05: Use lcd power constants 2024-09-30 16:49:41 +01:00
lms501kf03.c backlight: lms501kf03: Use lcd power constants 2024-09-30 16:49:42 +01:00
locomolcd.c backlight: locomolcd: Do not include <linux/fb.h> 2025-02-11 10:20:18 +00:00
lp855x_bl.c video: backlight: lp855x_bl: Set correct EPROM start for LP8556 2025-09-16 16:50:50 +01:00
lp8788_bl.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
ltv350qv.c backlight: ltv350qv: Use lcd power constants 2024-09-30 16:49:42 +01:00
ltv350qv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
lv5207lp.c backlight: lv5207lp: Do not include <linux/fb.h> 2025-02-11 10:20:18 +00:00
Makefile backlight: pcf50633-backlight: Remove unused driver 2025-03-14 11:36:33 +00:00
max8925_bl.c backlight: max8925_bl: Do not include <linux/fb.h> 2025-02-11 10:20:18 +00:00
mp3309c.c backlight: mp3309c: Initialize backlight properties without memset 2025-09-02 11:36:59 +01:00
mt6370-backlight.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
omap1_bl.c backlight: Remove fb_blank from struct backlight_properties 2024-03-28 10:16:26 +00:00
otm3225a.c backlight: otm3225a: Use lcd power constants 2024-09-30 16:49:42 +01:00
pandora_bl.c backlight: pandora-backlight: Use backlight power constants 2024-07-04 16:45:25 +01:00
platform_lcd.c backlight: lcd: Replace check_fb with controls_device 2024-09-30 16:49:42 +01:00
pwm_bl.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
qcom-wled.c backlight: pm8941: Add NULL check in wled_configure() 2025-04-15 18:27:38 +01:00
rave-sp-backlight.c backlight: rave-sp: Include <linux/of.h> and <linux/mod_devicetable.h> 2025-09-16 17:05:19 +01:00
rt4831-backlight.c backlight: rt4831: Include <linux/mod_devicetable.h> 2025-09-16 17:05:19 +01:00
sky81452-backlight.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
tdo24m.c backlight: lcd: Remove struct fb_videomode from set_mode callback 2024-09-30 16:49:42 +01:00
tps65217_bl.c backlight: tps65217_bl: Do not include <linux/fb.h> 2025-02-11 10:20:18 +00:00
vgg2432a4.c backlight: vgg2432a4: Do not include <linux/fb.h> 2025-02-11 10:20:18 +00:00
wm831x_bl.c backlight: wm831x_bl: Do not include <linux/fb.h> 2025-02-11 10:20:18 +00:00