From: Julia Lawall <julia.lawall@lip6.fr>
To: simran singhal <singhalsimran0@gmail.com>
Cc: lars@metafoo.de, Michael.Hennerich@analog.com, jic23@kernel.org,
Hartmut Knaack <knaack.h@gmx.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-iio@vger.kernel.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org, outreachy-kernel@googlegroups.com
Subject: Re: [Outreachy kernel] [PATCH] staging: impedance-analyzer: ad5933: Remove unnecessary goto
Date: Sun, 19 Mar 2017 18:56:05 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.20.1703191854260.2094@hadrien> (raw)
In-Reply-To: <20170319175133.GA19710@singhal-Inspiron-5558>
On Sun, 19 Mar 2017, simran singhal wrote:
> Remove unnecessary goto.
>
> Signed-off-by: simran singhal <singhalsimran0@gmail.com>
> ---
> drivers/staging/iio/impedance-analyzer/ad5933.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c
> index 297665d..c9ed2ac 100644
> --- a/drivers/staging/iio/impedance-analyzer/ad5933.c
> +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c
> @@ -663,12 +663,12 @@ static void ad5933_work(struct work_struct *work)
> ad5933_cmd(st, AD5933_CTRL_START_SWEEP);
> st->state = AD5933_CTRL_START_SWEEP;
> schedule_delayed_work(&st->work, st->poll_time_jiffies);
> - goto out;
> + mutex_unlock(&indio_dev->mlock);
This is not correct. The code at the end of the function implicitly does
a return, which has disappeared in the change. You could add a return to
each place wher you have put a mutex_unlock, but I think that the code was
better off as it was. It's microscopically less error prone to have this
cleanup code in only one place.
julia
> }
>
> ret = ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status);
> if (ret)
> - goto out;
> + mutex_unlock(&indio_dev->mlock);
>
> if (status & AD5933_STAT_DATA_VALID) {
> int scan_count = bitmap_weight(indio_dev->active_scan_mask,
> @@ -678,7 +678,7 @@ static void ad5933_work(struct work_struct *work)
> AD5933_REG_REAL_DATA : AD5933_REG_IMAG_DATA,
> scan_count * 2, (u8 *)buf);
> if (ret)
> - goto out;
> + mutex_unlock(&indio_dev->mlock);
>
> if (scan_count == 2) {
> val[0] = be16_to_cpu(buf[0]);
> @@ -690,7 +690,7 @@ static void ad5933_work(struct work_struct *work)
> } else {
> /* no data available - try again later */
> schedule_delayed_work(&st->work, st->poll_time_jiffies);
> - goto out;
> + mutex_unlock(&indio_dev->mlock);
> }
>
> if (status & AD5933_STAT_SWEEP_DONE) {
> @@ -703,8 +703,6 @@ static void ad5933_work(struct work_struct *work)
> ad5933_cmd(st, AD5933_CTRL_INC_FREQ);
> schedule_delayed_work(&st->work, st->poll_time_jiffies);
> }
> -out:
> - mutex_unlock(&indio_dev->mlock);
> }
>
> static int ad5933_probe(struct i2c_client *client,
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170319175133.GA19710%40singhal-Inspiron-5558.
> For more options, visit https://groups.google.com/d/optout.
>
next prev parent reply other threads:[~2017-03-19 18:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-19 17:51 simran singhal
2017-03-19 17:56 ` Julia Lawall [this message]
2017-03-19 18:13 ` [Outreachy kernel] " SIMRAN SINGHAL
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=alpine.DEB.2.20.1703191854260.2094@hadrien \
--to=julia.lawall@lip6.fr \
--cc=Michael.Hennerich@analog.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=outreachy-kernel@googlegroups.com \
--cc=pmeerw@pmeerw.net \
--cc=singhalsimran0@gmail.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
all inboxes | Powered by JetHome®