From: Jani Nikula <jani.nikula@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: jani.nikula@intel.com
Subject: [PATCH 2/4] drm/i915/bios: return proper error codes instead of magic -1
Date: Wed, 24 Apr 2024 14:10:59 +0300 [thread overview]
Message-ID: <20240424111101.1152824-2-jani.nikula@intel.com> (raw)
In-Reply-To: <20240424111101.1152824-1-jani.nikula@intel.com>
Use proper negative error codes intead of magic -1. Don't set a bad
example, as -1 is -EPERM.
-1 might be fine for "invalid index" for a function that returns
indices, but e.g. opregion_get_panel_type() already returns negative
error codes so all the other code needs to cope with them anyway.
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
drivers/gpu/drm/i915/display/intel_bios.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
index 661842a3c2e6..e1d9e6891ebb 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.c
+++ b/drivers/gpu/drm/i915/display/intel_bios.c
@@ -631,13 +631,13 @@ static int vbt_get_panel_type(struct drm_i915_private *i915,
lvds_options = bdb_find_section(i915, BDB_LVDS_OPTIONS);
if (!lvds_options)
- return -1;
+ return -ENOENT;
if (lvds_options->panel_type > 0xf &&
lvds_options->panel_type != 0xff) {
drm_dbg_kms(&i915->drm, "Invalid VBT panel type 0x%x\n",
lvds_options->panel_type);
- return -1;
+ return -EINVAL;
}
if (devdata && devdata->child.handle == DEVICE_HANDLE_LFP2)
@@ -656,10 +656,10 @@ static int pnpid_get_panel_type(struct drm_i915_private *i915,
const struct bdb_lvds_lfp_data_ptrs *ptrs;
struct drm_edid_product_id product_id, product_id_nodate;
struct drm_printer p;
- int i, best = -1;
+ int i, best = -ENOENT;
if (!drm_edid)
- return -1;
+ return -EINVAL;
drm_edid_get_product_id(drm_edid, &product_id);
@@ -672,11 +672,11 @@ static int pnpid_get_panel_type(struct drm_i915_private *i915,
ptrs = bdb_find_section(i915, BDB_LVDS_LFP_DATA_PTRS);
if (!ptrs)
- return -1;
+ return -ENOENT;
data = bdb_find_section(i915, BDB_LVDS_LFP_DATA);
if (!data)
- return -1;
+ return -ENOENT;
for (i = 0; i < 16; i++) {
const struct drm_edid_product_id *vbt_id =
@@ -702,7 +702,7 @@ static int fallback_get_panel_type(struct drm_i915_private *i915,
const struct intel_bios_encoder_data *devdata,
const struct drm_edid *drm_edid, bool use_fallback)
{
- return use_fallback ? 0 : -1;
+ return use_fallback ? 0 : -ENOENT;
}
enum panel_type {
@@ -2568,12 +2568,12 @@ intel_bios_encoder_is_lspcon(const struct intel_bios_encoder_data *devdata)
return devdata && HAS_LSPCON(devdata->i915) && devdata->child.lspcon;
}
-/* This is an index in the HDMI/DVI DDI buffer translation table, or -1 */
+/* This is an index in the HDMI/DVI DDI buffer translation table, or -ERANGE */
int intel_bios_hdmi_level_shift(const struct intel_bios_encoder_data *devdata)
{
if (!devdata || devdata->i915->display.vbt.version < 158 ||
DISPLAY_VER(devdata->i915) >= 14)
- return -1;
+ return -ERANGE;
return devdata->child.hdmi_level_shifter_value;
}
--
2.39.2
next prev parent reply other threads:[~2024-04-24 11:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-24 11:10 [PATCH 1/4] drm/i915/dvo: return proper error code instead of magic -1 Jani Nikula
2024-04-24 11:10 ` Jani Nikula [this message]
2024-04-24 11:11 ` [PATCH 3/4] drm/i915/dp: return proper error codes " Jani Nikula
2024-04-24 11:11 ` [PATCH 4/4] drm/i915/fb: " Jani Nikula
2024-04-24 11:36 ` ✗ Fi.CI.SPARSE: warning for series starting with [1/4] drm/i915/dvo: return proper error code " Patchwork
2024-04-24 11:44 ` ✓ Fi.CI.BAT: success " Patchwork
2024-04-24 17:33 ` ✗ Fi.CI.IGT: 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=20240424111101.1152824-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox