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>,
Peter Rosin <peda@axentia.se>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] iio/pressure/mpl3115: Improve unlocking of a mutex in mpl3115_trigger_handler()
Date: Thu, 26 Oct 2017 16:23:45 +0200 [thread overview]
Message-ID: <b93264eb-3d22-46dc-fe0a-538fbe9e600f@users.sourceforge.net> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 26 Oct 2017 16:10:46 +0200
Adjust jump targets so that a call of the function "mutex_unlock" is stored
at the end of this function implementation.
Replace three calls by goto statements.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/iio/pressure/mpl3115.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c
index 7537547fb7ee..f39e6f42a9c0 100644
--- a/drivers/iio/pressure/mpl3115.c
+++ b/drivers/iio/pressure/mpl3115.c
@@ -152,38 +152,36 @@ static irqreturn_t mpl3115_trigger_handler(int irq, void *p)
mutex_lock(&data->lock);
ret = mpl3115_request(data);
- if (ret < 0) {
- mutex_unlock(&data->lock);
- goto done;
- }
+ if (ret < 0)
+ goto unlock;
memset(buffer, 0, sizeof(buffer));
if (test_bit(0, indio_dev->active_scan_mask)) {
ret = i2c_smbus_read_i2c_block_data(data->client,
MPL3115_OUT_PRESS, 3, &buffer[pos]);
- if (ret < 0) {
- mutex_unlock(&data->lock);
- goto done;
- }
+ if (ret < 0)
+ goto unlock;
+
pos += 4;
}
if (test_bit(1, indio_dev->active_scan_mask)) {
ret = i2c_smbus_read_i2c_block_data(data->client,
MPL3115_OUT_TEMP, 2, &buffer[pos]);
- if (ret < 0) {
- mutex_unlock(&data->lock);
- goto done;
- }
+ if (ret < 0)
+ goto unlock;
}
mutex_unlock(&data->lock);
iio_push_to_buffers_with_timestamp(indio_dev, buffer,
iio_get_time_ns(indio_dev));
-
-done:
+notify_trigger:
iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
+
+unlock:
+ mutex_unlock(&data->lock);
+ goto notify_trigger;
}
static const struct iio_chan_spec mpl3115_channels[] = {
--
2.14.3
next reply other threads:[~2017-10-26 14:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-26 14:23 SF Markus Elfring [this message]
2017-10-26 16:21 ` [PATCH] iio/pressure/mpl3115: Improve unlocking of a mutex in mpl3115_trigger_handler() Jonathan Cameron
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=b93264eb-3d22-46dc-fe0a-538fbe9e600f@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=peda@axentia.se \
--cc=pmeerw@pmeerw.net \
/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).