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] [PATCH 4/5] drm/i915/dmc: add is_valid_dmc_id() and use it
Date: Thu,  2 Feb 2023 14:04:51 +0200	[thread overview]
Message-ID: <311213ce328575a95d793a219d4dac7d947086cc.1675339447.git.jani.nikula@intel.com> (raw)
In-Reply-To: <cover.1675339447.git.jani.nikula@intel.com>

Add a name to the dmc id validity check.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/display/intel_dmc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dmc.c b/drivers/gpu/drm/i915/display/intel_dmc.c
index 4cc62b040518..ab0ad8e3e620 100644
--- a/drivers/gpu/drm/i915/display/intel_dmc.c
+++ b/drivers/gpu/drm/i915/display/intel_dmc.c
@@ -252,6 +252,11 @@ struct stepping_info {
 #define for_each_dmc_id(__dmc_id) \
 	for ((__dmc_id) = DMC_FW_MAIN; (__dmc_id) < DMC_FW_MAX; (__dmc_id)++)
 
+static bool is_valid_dmc_id(enum intel_dmc_id dmc_id)
+{
+	return dmc_id >= DMC_FW_MAIN && dmc_id < DMC_FW_MAX;
+}
+
 static bool has_dmc_id_fw(struct drm_i915_private *i915, enum intel_dmc_id dmc_id)
 {
 	return i915->display.dmc.dmc_info[dmc_id].payload;
@@ -549,7 +554,7 @@ static void dmc_set_fw_offset(struct intel_dmc *dmc,
 	for (i = 0; i < num_entries; i++) {
 		dmc_id = package_ver <= 1 ? DMC_FW_MAIN : fw_info[i].dmc_id;
 
-		if (dmc_id >= DMC_FW_MAX) {
+		if (!is_valid_dmc_id(dmc_id)) {
 			drm_dbg(&i915->drm, "Unsupported firmware id: %u\n", dmc_id);
 			continue;
 		}
-- 
2.34.1


  parent reply	other threads:[~2023-02-02 12:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 12:04 [Intel-gfx] [PATCH 0/5] drm/i915/dmc: some dmc id related fixes and cleanups Jani Nikula
2023-02-02 12:04 ` [Intel-gfx] [PATCH 1/5] drm/i915/dmc: add proper name to dmc id enum and use it Jani Nikula
2023-02-02 12:04 ` [Intel-gfx] [PATCH 2/5] drm/i915/dmc: add for_each_dmc_id() " Jani Nikula
2023-02-02 12:04 ` [Intel-gfx] [PATCH 3/5] drm/i915/dmc: remove unnecessary dmc_id validity check Jani Nikula
2023-02-02 12:04 ` Jani Nikula [this message]
2023-02-02 12:04 ` [Intel-gfx] [PATCH 5/5] drm/i915/dmc: check incoming dmc id validity Jani Nikula
2023-02-02 15:13   ` Imre Deak
2023-02-03 10:34     ` Jani Nikula
2023-02-02 14:05 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/dmc: some dmc id related fixes and cleanups Patchwork
2023-02-02 14:29 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-02-02 18:05 ` [Intel-gfx] ✓ Fi.CI.IGT: " 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=311213ce328575a95d793a219d4dac7d947086cc.1675339447.git.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.