linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
	Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Tiberiu Breana <tiberiu.a.breana@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 1/2] iio/accel/stk8ba50: Use common error handling code in stk8ba50_probe()
Date: Wed, 25 Oct 2017 22:16:31 +0200	[thread overview]
Message-ID: <0f26a13b-7bbf-525b-a864-8aa8e13c3aef@users.sourceforge.net> (raw)
In-Reply-To: <5ab7e200-2dea-63e2-06db-0e185f563d16@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 25 Oct 2017 21:36:03 +0200

* 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.

* Adjust condition checks.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/iio/accel/stk8ba50.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c
index 576b6b140f08..afe90567ad37 100644
--- a/drivers/iio/accel/stk8ba50.c
+++ b/drivers/iio/accel/stk8ba50.c
@@ -426,16 +426,13 @@ static int stk8ba50_probe(struct i2c_client *client,
 	/* Set up interrupts */
 	ret = i2c_smbus_write_byte_data(client,
 			STK8BA50_REG_INTEN2, STK8BA50_DREADY_INT_MASK);
-	if (ret < 0) {
-		dev_err(&client->dev, "failed to set up interrupts\n");
-		goto err_power_off;
-	}
+	if (ret)
+		goto report_failure;
+
 	ret = i2c_smbus_write_byte_data(client,
 			STK8BA50_REG_INTMAP2, STK8BA50_DREADY_INT_MAP);
-	if (ret < 0) {
-		dev_err(&client->dev, "failed to set up interrupts\n");
-		goto err_power_off;
-	}
+	if (ret)
+		goto report_failure;
 
 	if (client->irq > 0) {
 		ret = devm_request_threaded_irq(&client->dev, client->irq,
@@ -495,6 +492,10 @@ static int stk8ba50_probe(struct i2c_client *client,
 err_power_off:
 	stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND);
 	return ret;
+
+report_failure:
+	dev_err(&client->dev, "failed to set up interrupts\n");
+	goto err_power_off;
 }
 
 static int stk8ba50_remove(struct i2c_client *client)
-- 
2.14.3

  reply	other threads:[~2017-10-25 20:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-25 20:15 [PATCH 0/2] iio/accel/stk8ba50: Fine-tuning for two function implementations SF Markus Elfring
2017-10-25 20:16 ` SF Markus Elfring [this message]
2017-10-26 16:42   ` [PATCH 1/2] iio/accel/stk8ba50: Use common error handling code in stk8ba50_probe() Jonathan Cameron
2017-10-26 17:09     ` SF Markus Elfring
2017-12-10 12:33     ` iio/…: Use common error handling code SF Markus Elfring
2017-12-10 16:08       ` Jonathan Cameron
2017-12-10 16:43         ` SF Markus Elfring
2017-12-10 19:45           ` Jonathan Cameron
2017-10-25 20:17 ` [PATCH 2/2] iio/accel/stk8ba50: Improve unlocking of a mutex in stk8ba50_read_raw() 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=0f26a13b-7bbf-525b-a864-8aa8e13c3aef@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=jic23@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    --cc=tiberiu.a.breana@intel.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;
as well as URLs for NNTP newsgroup(s).