Commit 20f85ef8 authored by Jani Nikula's avatar Jani Nikula

drm/i915/backlight: use unique backlight device names

Registering multiple backlight devices with intel_backlight name will
obviously fail, regardless of whether they're two connectors in the same
drm device or two different drm devices.

It would be preferrable to switch to completely unique names, and sunset
the generic intel_backlight name. However, there are apparently users
out there that hardcode the name, so the change would break backward
compatibility.

As a compromise, register the first device with intel_backlight name. In
the common case, this is the only backlight device anyway. From the
second device on, use card%d-%s-backlight format, for example
card0-eDP-2-backlight, to make the name unique.

This approach does not preclude us from registering the first device
using the same naming scheme in the future.

v2: Keep using intel_backlight name for first backlight device

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/2794Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/7dc3f6974711ce44522189dc9db05d1e6e24e6d8.1619604743.git.jani.nikula@intel.com
parent b08a759d
...@@ -1401,16 +1401,31 @@ int intel_backlight_device_register(struct intel_connector *connector) ...@@ -1401,16 +1401,31 @@ int intel_backlight_device_register(struct intel_connector *connector)
else else
props.power = FB_BLANK_POWERDOWN; props.power = FB_BLANK_POWERDOWN;
name = kstrdup("intel_backlight", GFP_KERNEL);
if (!name)
return -ENOMEM;
bd = backlight_device_register(name, connector->base.kdev, connector,
&intel_backlight_device_ops, &props);
/* /*
* Note: using the same name independent of the connector prevents * Using the same name independent of the drm device or connector
* registration of multiple backlight devices in the driver. * prevents registration of multiple backlight devices in the
* driver. However, we need to use the default name for backward
* compatibility. Use unique names for subsequent backlight devices as a
* fallback when the default name already exists.
*/ */
name = kstrdup("intel_backlight", GFP_KERNEL); if (IS_ERR(bd) && PTR_ERR(bd) == -EEXIST) {
kfree(name);
name = kasprintf(GFP_KERNEL, "card%d-%s-backlight",
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,
"[CONNECTOR:%d:%s] backlight device %s register failed: %ld\n", "[CONNECTOR:%d:%s] backlight device %s register failed: %ld\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment