public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: devel@driverdev.osuosl.org, linux-iio@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] staging: iio: ad7746: Improve unlocking of a mutex in ad7746_start_calib()
Date: Sun, 19 Nov 2017 15:37:30 +0000	[thread overview]
Message-ID: <20171119153730.3f04b953@archlinux> (raw)
In-Reply-To: <57f5d20b-cc13-07b2-51cf-53704327df27@users.sourceforge.net>

On Fri, 3 Nov 2017 09:33:57 +0100
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 3 Nov 2017 09:26:28 +0100
> 
> * Add a jump target so that a call of the function "mutex_unlock" is stored
>   only twice in this function implementation.
> 
> * Replace two calls by goto statements.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Again, a reasonable little tidy up. Applied to the togreg branch
of iio.git and pushed out as testing for the autobuilders to check
we haven't missed anything.

Thanks,

Jonathan
> ---
>  drivers/staging/iio/cdc/ad7746.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
> index a124853a05f0..c4a864725376 100644
> --- a/drivers/staging/iio/cdc/ad7746.c
> +++ b/drivers/staging/iio/cdc/ad7746.c
> @@ -302,23 +302,24 @@ static inline ssize_t ad7746_start_calib(struct device *dev,
>  	mutex_lock(&chip->lock);
>  	regval |= chip->config;
>  	ret = i2c_smbus_write_byte_data(chip->client, AD7746_REG_CFG, regval);
> -	if (ret < 0) {
> -		mutex_unlock(&chip->lock);
> -		return ret;
> -	}
> +	if (ret < 0)
> +		goto unlock;
>  
>  	do {
>  		msleep(20);
>  		ret = i2c_smbus_read_byte_data(chip->client, AD7746_REG_CFG);
> -		if (ret < 0) {
> -			mutex_unlock(&chip->lock);
> -			return ret;
> -		}
> +		if (ret < 0)
> +			goto unlock;
> +
>  	} while ((ret == regval) && timeout--);
>  
>  	mutex_unlock(&chip->lock);
>  
>  	return len;
> +
> +unlock:
> +	mutex_unlock(&chip->lock);
> +	return ret;
>  }
>  
>  static ssize_t ad7746_start_offset_calib(struct device *dev,

      reply	other threads:[~2017-11-19 15:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-03  8:33 [PATCH] staging: iio: ad7746: Improve unlocking of a mutex in ad7746_start_calib() SF Markus Elfring
2017-11-19 15:37 ` Jonathan Cameron [this message]

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=20171119153730.3f04b953@archlinux \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=elfring@users.sourceforge.net \
    --cc=gregkh@linuxfoundation.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 \
    /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