public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: devel@driverdev.osuosl.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] staging: fbtft: fb_ssd1331: Use common error handling code in write_reg8_bus8()
Date: Thu, 2 Nov 2017 22:30:31 +0100	[thread overview]
Message-ID: <233f4d2c-e099-e097-5484-7df2770d076f@users.sourceforge.net> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 2 Nov 2017 22:27:13 +0100

* Add a jump target so that a specific error message is stored only once
  at the end of this function implementation.

* Replace two calls of the function "dev_err" by goto statements.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/fbtft/fb_ssd1331.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/fbtft/fb_ssd1331.c b/drivers/staging/fbtft/fb_ssd1331.c
index 9aa9864fcf30..b3a8f2668951 100644
--- a/drivers/staging/fbtft/fb_ssd1331.c
+++ b/drivers/staging/fbtft/fb_ssd1331.c
@@ -76,12 +76,9 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
 	if (par->gpio.dc != -1)
 		gpio_set_value(par->gpio.dc, 0);
 	ret = par->fbtftops.write(par, par->buf, sizeof(u8));
-	if (ret < 0) {
-		va_end(args);
-		dev_err(par->info->device,
-			"write() failed and returned %d\n", ret);
-		return;
-	}
+	if (ret < 0)
+		goto end_va;
+
 	len--;
 
 	if (len) {
@@ -89,16 +86,17 @@ static void write_reg8_bus8(struct fbtft_par *par, int len, ...)
 		while (i--)
 			*buf++ = (u8)va_arg(args, unsigned int);
 		ret = par->fbtftops.write(par, par->buf, len * (sizeof(u8)));
-		if (ret < 0) {
-			va_end(args);
-			dev_err(par->info->device,
-				"write() failed and returned %d\n", ret);
-			return;
-		}
+		if (ret < 0)
+			goto end_va;
 	}
 	if (par->gpio.dc != -1)
 		gpio_set_value(par->gpio.dc, 1);
 	va_end(args);
+	return;
+
+end_va:
+	va_end(args);
+	dev_err(par->info->device, "write() failed and returned %d\n", ret);
 }
 
 /*
-- 
2.15.0

                 reply	other threads:[~2017-11-02 21:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=233f4d2c-e099-e097-5484-7df2770d076f@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thomas.petazzoni@free-electrons.com \
    /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