All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: jani.nikula@intel.com
Subject: [Intel-gfx] [RFC] drm/i915/backlight: switch to unique backlight device names
Date: Wed,  7 Apr 2021 12:08:12 +0300	[thread overview]
Message-ID: <20210407090812.3602-1-jani.nikula@intel.com> (raw)

Change the backlight device names from intel_backlight to
card%d-%s-backlight format, for example card0-eDP-1-backlight, to make
them unique. Otherwise, registering multiple backlight devices with
intel_backlight name will fail, regardless of whether they're two
connectors in the same device or two different devices.

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/2794
Signed-off-by: Jani Nikula <jani.nikula@intel.com>

---

Is the name "intel_backlight" part of the UABI? In theory the userspace
should only look at the names and types available under
/sys/class/backlight, not the exact names.
---
 drivers/gpu/drm/i915/display/intel_panel.c | 29 ++++++++++++++--------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_panel.c b/drivers/gpu/drm/i915/display/intel_panel.c
index 10022d1575e1..5ebf8cb0e8e3 100644
--- a/drivers/gpu/drm/i915/display/intel_panel.c
+++ b/drivers/gpu/drm/i915/display/intel_panel.c
@@ -1372,6 +1372,8 @@ int intel_backlight_device_register(struct intel_connector *connector)
 	struct drm_i915_private *i915 = to_i915(connector->base.dev);
 	struct intel_panel *panel = &connector->panel;
 	struct backlight_properties props;
+	const char *name;
+	int ret = 0;
 
 	if (WARN_ON(panel->backlight.device))
 		return -ENODEV;
@@ -1398,28 +1400,33 @@ int intel_backlight_device_register(struct intel_connector *connector)
 	else
 		props.power = FB_BLANK_POWERDOWN;
 
-	/*
-	 * Note: using the same name independent of the connector prevents
-	 * registration of multiple backlight devices in the driver.
-	 */
+	name = kasprintf(GFP_KERNEL, "card%d-%s-backlight", i915->drm.primary->index,
+			 connector->base.name);
+	if (!name)
+		return -ENOMEM;
+
 	panel->backlight.device =
-		backlight_device_register("intel_backlight",
+		backlight_device_register(name,
 					  connector->base.kdev,
 					  connector,
 					  &intel_backlight_device_ops, &props);
 
 	if (IS_ERR(panel->backlight.device)) {
-		drm_err(&i915->drm, "Failed to register backlight: %ld\n",
-			PTR_ERR(panel->backlight.device));
+		drm_err(&i915->drm, "Failed to register backlight %s: %ld\n",
+			name, PTR_ERR(panel->backlight.device));
 		panel->backlight.device = NULL;
-		return -ENODEV;
+		ret = -ENODEV;
+		goto out;
 	}
 
 	drm_dbg_kms(&i915->drm,
-		    "Connector %s backlight sysfs interface registered\n",
-		    connector->base.name);
+		    "Connector %s backlight sysfs interface %s registered\n",
+		    name, connector->base.name);
 
-	return 0;
+out:
+	kfree(name);
+
+	return ret;
 }
 
 void intel_backlight_device_unregister(struct intel_connector *connector)
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

             reply	other threads:[~2021-04-07  9:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07  9:08 Jani Nikula [this message]
2021-04-07  9:25 ` [Intel-gfx] ✗ Fi.CI.DOCS: warning for drm/i915/backlight: switch to unique backlight device names Patchwork
2021-04-07  9:49 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2021-04-07 10:02   ` Jani Nikula
2021-04-07 20:47 ` [Intel-gfx] [RFC] " Ville Syrjälä
2021-04-28 10:16   ` Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210407090812.3602-1-jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.