public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: dri-devel@lists.freedesktop.org,
	Andrzej Hajda <a.hajda@samsung.com>,
	Archit Taneja <architt@codeaurora.org>,
	David Airlie <airlied@linux.ie>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Maciej Purski <m.purski@samsung.com>,
	Rob Herring <robh@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] gpu/drm/bridge/sii9234: Use common error handling code in sii9234_writebm()
Date: Sun, 22 Oct 2017 19:32:46 +0000	[thread overview]
Message-ID: <8bb4a1d2-8876-731f-2938-8be075f4252c@users.sourceforge.net> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 22 Oct 2017 21:21:44 +0200

* Add a jump target so that a bit of exception handling can be better
  reused at the end of this function.

  This issue was detected by using the Coccinelle software.

* Adjust condition checks.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/bridge/sii9234.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/bridge/sii9234.c b/drivers/gpu/drm/bridge/sii9234.c
index c77000626c22..fbdacdaf485c 100644
--- a/drivers/gpu/drm/bridge/sii9234.c
+++ b/drivers/gpu/drm/bridge/sii9234.c
@@ -231,30 +231,22 @@ static int sii9234_writebm(struct sii9234 *ctx, int id, int offset,
 		return ctx->i2c_error;
 
 	ret = i2c_smbus_write_byte(client, offset);
-	if (ret < 0) {
-		dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n",
-			sii9234_client_name[id], offset, value);
-		ctx->i2c_error = ret;
-		return ret;
-	}
+	if (ret)
+		goto report_failure;
 
 	ret = i2c_smbus_read_byte(client);
-	if (ret < 0) {
-		dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n",
-			sii9234_client_name[id], offset, value);
-		ctx->i2c_error = ret;
-		return ret;
-	}
+	if (ret)
+		goto report_failure;
 
 	value = (value & mask) | (ret & ~mask);
-
 	ret = i2c_smbus_write_byte_data(client, offset, value);
-	if (ret < 0) {
-		dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n",
-			sii9234_client_name[id], offset, value);
-		ctx->i2c_error = ret;
-	}
+	if (!ret)
+		return 0;
 
+report_failure:
+	dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n",
+		sii9234_client_name[id], offset, value);
+	ctx->i2c_error = ret;
 	return ret;
 }
 
-- 
2.14.2


             reply	other threads:[~2017-10-22 19:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-22 19:32 SF Markus Elfring [this message]
2017-10-22 20:00 ` [PATCH v2] gpu/drm/bridge/sii9234: Use common error handling code in sii9234_writebm() SF Markus Elfring
2017-10-23  7:18 ` [PATCH] " Dan Carpenter
2017-10-23  8:45   ` SF Markus Elfring

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=8bb4a1d2-8876-731f-2938-8be075f4252c@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=a.hajda@samsung.com \
    --cc=airlied@linux.ie \
    --cc=architt@codeaurora.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.purski@samsung.com \
    --cc=robh@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox