drm/i915/display: avoid warnings when registering dual panel backlight
authorArun R Murthy <arun.r.murthy@intel.com>
Mon, 8 Aug 2022 03:57:50 +0000 (09:27 +0530)
committerJani Nikula <jani.nikula@intel.com>
Mon, 22 Aug 2022 09:10:49 +0000 (12:10 +0300)
commit4234ea30051200fc6016de10e4d58369e60b38f1
treec43114fdd2d3ef9513c7d0a49e22bdd00185711e
parent4cf05a4d7125854800a0e88eb3e1dbd74368e9af
drm/i915/display: avoid warnings when registering dual panel backlight

Commit 20f85ef89d94 ("drm/i915/backlight: use unique backlight device
names") added support for multiple backlight devices on dual panel
systems, but did so with error handling on -EEXIST from
backlight_device_register(). Unfortunately, that triggered a warning in
dmesg all the way down from sysfs_add_file_mode_ns() and
sysfs_warn_dup().

Instead of optimistically always attempting to register with the default
name ("intel_backlight", which we have to retain for backward
compatibility), check if a backlight device with the name exists first,
and, if so, use the card and connector based name.

v2: reworked on top of the patch commit 20f85ef89d94
("drm/i915/backlight: use unique backlight device names")
v3: fixed the ref count leak(Jani N)

Fixes: 20f85ef89d94 ("drm/i915/backlight: use unique backlight device names")
Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220808035750.3111046-1-arun.r.murthy@intel.com
drivers/gpu/drm/i915/display/intel_backlight.c