drm/i915/display: avoid warnings when registering dual panel backlight
Commit20f85ef89d
("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 commit20f85ef89d
("drm/i915/backlight: use unique backlight device names") v3: fixed the ref count leak(Jani N) Fixes:20f85ef89d
("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 (cherry picked from commit4234ea3005
) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
This commit is contained in:
parent
875c6d2711
commit
2c4e19f873
@ -971,9 +971,9 @@ int intel_backlight_device_register(struct intel_connector *connector)
|
|||||||
if (!name)
|
if (!name)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
bd = backlight_device_register(name, connector->base.kdev, connector,
|
bd = backlight_device_get_by_name(name);
|
||||||
&intel_backlight_device_ops, &props);
|
if (bd) {
|
||||||
|
put_device(&bd->dev);
|
||||||
/*
|
/*
|
||||||
* Using the same name independent of the drm device or connector
|
* Using the same name independent of the drm device or connector
|
||||||
* prevents registration of multiple backlight devices in the
|
* prevents registration of multiple backlight devices in the
|
||||||
@ -981,16 +981,14 @@ int intel_backlight_device_register(struct intel_connector *connector)
|
|||||||
* compatibility. Use unique names for subsequent backlight devices as a
|
* compatibility. Use unique names for subsequent backlight devices as a
|
||||||
* fallback when the default name already exists.
|
* fallback when the default name already exists.
|
||||||
*/
|
*/
|
||||||
if (IS_ERR(bd) && PTR_ERR(bd) == -EEXIST) {
|
|
||||||
kfree(name);
|
kfree(name);
|
||||||
name = kasprintf(GFP_KERNEL, "card%d-%s-backlight",
|
name = kasprintf(GFP_KERNEL, "card%d-%s-backlight",
|
||||||
i915->drm.primary->index, connector->base.name);
|
i915->drm.primary->index, connector->base.name);
|
||||||
if (!name)
|
if (!name)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
bd = backlight_device_register(name, connector->base.kdev, connector,
|
bd = backlight_device_register(name, connector->base.kdev, connector,
|
||||||
&intel_backlight_device_ops, &props);
|
&intel_backlight_device_ops, &props);
|
||||||
}
|
|
||||||
|
|
||||||
if (IS_ERR(bd)) {
|
if (IS_ERR(bd)) {
|
||||||
drm_err(&i915->drm,
|
drm_err(&i915->drm,
|
||||||
|
Loading…
Reference in New Issue
Block a user