Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Jani Nikula <jani.nikula@intel.com>
Subject: [Intel-gfx] [PATCH 3/3] drm/i915/psr: clean up PSR debugfs sink status error handling
Date: Fri, 17 Mar 2023 15:41:44 +0200	[thread overview]
Message-ID: <20230317134144.223936-3-jani.nikula@intel.com> (raw)
In-Reply-To: <20230317134144.223936-1-jani.nikula@intel.com>

Handle errors first and return early, and reduce indentation on the
happy day code path.

Cc: Jouni Högander <jouni.hogander@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/display/intel_psr.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_psr.c b/drivers/gpu/drm/i915/display/intel_psr.c
index bd1a1a2524b5..31084d95711d 100644
--- a/drivers/gpu/drm/i915/display/intel_psr.c
+++ b/drivers/gpu/drm/i915/display/intel_psr.c
@@ -2891,6 +2891,7 @@ static int i915_psr_sink_status_show(struct seq_file *m, void *data)
 		"reserved",
 		"sink internal error",
 	};
+	const char *str;
 	int ret;
 	u8 val;
 
@@ -2903,17 +2904,16 @@ static int i915_psr_sink_status_show(struct seq_file *m, void *data)
 		return -ENODEV;
 
 	ret = drm_dp_dpcd_readb(&intel_dp->aux, DP_PSR_STATUS, &val);
+	if (ret != 1)
+		return ret < 0 ? ret : -EIO;
 
-	if (ret == 1) {
-		const char *str = "unknown";
+	val &= DP_PSR_SINK_STATE_MASK;
+	if (val < ARRAY_SIZE(sink_status))
+		str = sink_status[val];
+	else
+		str = "unknown";
 
-		val &= DP_PSR_SINK_STATE_MASK;
-		if (val < ARRAY_SIZE(sink_status))
-			str = sink_status[val];
-		seq_printf(m, "Sink PSR status: 0x%x [%s]\n", val, str);
-	} else {
-		return ret;
-	}
+	seq_printf(m, "Sink PSR status: 0x%x [%s]\n", val, str);
 
 	return 0;
 }
-- 
2.39.2


  parent reply	other threads:[~2023-03-17 13:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 13:41 [Intel-gfx] [PATCH 1/3] drm/i915/psr: move PSR debugfs to intel_psr.c Jani Nikula
2023-03-17 13:41 ` [Intel-gfx] [PATCH 2/3] drm/i915/psr: switch PSR debugfs to struct intel_connector Jani Nikula
2023-03-20  8:50   ` Hogander, Jouni
2023-03-17 13:41 ` Jani Nikula [this message]
2023-03-20  8:50   ` [Intel-gfx] [PATCH 3/3] drm/i915/psr: clean up PSR debugfs sink status error handling Hogander, Jouni
2023-03-17 18:07 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/3] drm/i915/psr: move PSR debugfs to intel_psr.c Patchwork
2023-03-17 18:07 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2023-03-17 18:07 ` [Intel-gfx] ✗ Fi.CI.DOCS: " Patchwork
2023-03-17 18:20 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-03-17 20:54 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2023-03-20  8:50 ` [Intel-gfx] [PATCH 1/3] " Hogander, Jouni
2023-03-20 10:14   ` 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=20230317134144.223936-3-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