All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org, jani.nikula@intel.com,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Jessica Zhang <quic_jesszhan@quicinc.com>,
	Sam Ravnborg <sam@ravnborg.org>,
	stable@vger.kernel.org
Subject: [PATCH 2/8] drm/panel: do not return negative error codes from drm_panel_get_modes()
Date: Fri,  8 Mar 2024 18:03:40 +0200	[thread overview]
Message-ID: <79f559b72d8c493940417304e222a4b04dfa19c4.1709913674.git.jani.nikula@intel.com> (raw)
In-Reply-To: <cover.1709913674.git.jani.nikula@intel.com>

None of the callers of drm_panel_get_modes() expect it to return
negative error codes. Either they propagate the return value in their
struct drm_connector_helper_funcs .get_modes() hook (which is also not
supposed to return negative codes), or add it to other counts leading to
bogus values.

On the other hand, many of the struct drm_panel_funcs .get_modes() hooks
do return negative error codes, so handle them gracefully instead of
propagating further.

Return 0 for no modes, whatever the reason.

Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Jessica Zhang <quic_jesszhan@quicinc.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: stable@vger.kernel.org
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/drm_panel.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c
index e814020bbcd3..cfbe020de54e 100644
--- a/drivers/gpu/drm/drm_panel.c
+++ b/drivers/gpu/drm/drm_panel.c
@@ -274,19 +274,24 @@ EXPORT_SYMBOL(drm_panel_disable);
  * The modes probed from the panel are automatically added to the connector
  * that the panel is attached to.
  *
- * Return: The number of modes available from the panel on success or a
- * negative error code on failure.
+ * Return: The number of modes available from the panel on success, or 0 on
+ * failure (no modes).
  */
 int drm_panel_get_modes(struct drm_panel *panel,
 			struct drm_connector *connector)
 {
 	if (!panel)
-		return -EINVAL;
+		return 0;
 
-	if (panel->funcs && panel->funcs->get_modes)
-		return panel->funcs->get_modes(panel, connector);
+	if (panel->funcs && panel->funcs->get_modes) {
+		int num;
 
-	return -EOPNOTSUPP;
+		num = panel->funcs->get_modes(panel, connector);
+		if (num > 0)
+			return num;
+	}
+
+	return 0;
 }
 EXPORT_SYMBOL(drm_panel_get_modes);
 
-- 
2.39.2


  parent reply	other threads:[~2024-03-08 16:04 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-08 16:03 [PATCH 0/8] drm: fix .get_modes() return values Jani Nikula
2024-03-08 16:03 ` [PATCH 1/8] drm/probe-helper: warn about negative .get_modes() Jani Nikula
2024-03-08 16:03 ` Jani Nikula [this message]
2024-03-08 16:52   ` [PATCH 2/8] drm/panel: do not return negative error codes from drm_panel_get_modes() Jessica Zhang
2024-03-11  8:23   ` Neil Armstrong
2024-03-08 16:03 ` [PATCH 3/8] drm/exynos: do not return negative values from .get_modes() Jani Nikula
2024-03-08 16:03 ` [PATCH 4/8] drm/bridge: lt8912b: " Jani Nikula
2024-03-08 16:03 ` [PATCH 5/8] drm/imx/ipuv3: " Jani Nikula
2024-03-08 16:41   ` Philipp Zabel
2024-03-08 16:03 ` [PATCH 6/8] drm/vc4: hdmi: " Jani Nikula
2024-03-08 16:06   ` Maxime Ripard
2024-03-08 16:03 ` [PATCH 7/8] drm/bridge: lt9611uxc: use int for holding number of modes Jani Nikula
2024-03-11  8:28   ` Neil Armstrong
2024-03-11  9:18   ` Dmitry Baryshkov
2024-03-08 16:03 ` [PATCH 8/8] drm/exynos: simplify the return value handling in exynos_dp_get_modes() Jani Nikula
2024-03-08 16:24 ` [PATCH 0/8] drm: fix .get_modes() return values Thomas Zimmermann
2024-03-13 11:47   ` Jani Nikula
2024-03-08 18:25 ` ✗ Fi.CI.SPARSE: warning for " Patchwork
2024-03-08 18:30 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-03-12  0:28 ` ✗ Fi.CI.SPARSE: warning for drm: fix .get_modes() return values (rev2) Patchwork
2024-03-12  0:45 ` ✗ Fi.CI.BAT: failure " Patchwork

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=79f559b72d8c493940417304e222a4b04dfa19c4.1709913674.git.jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=neil.armstrong@linaro.org \
    --cc=quic_jesszhan@quicinc.com \
    --cc=sam@ravnborg.org \
    --cc=stable@vger.kernel.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.