All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: linux-iio@vger.kernel.org, Andreas Klinger <ak@it-klinger.de>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] iio/proximity/srf08: Improve unlocking of a mutex in srf08_read_ranging()
Date: Thu, 26 Oct 2017 16:18:31 +0000	[thread overview]
Message-ID: <20171026171831.3e8018d2@archlinux> (raw)
In-Reply-To: <62f61dbd-b106-1d3f-fb75-3fa87251e6ef@users.sourceforge.net>

On Thu, 26 Oct 2017 17:00:07 +0200
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 26 Oct 2017 16:51:08 +0200
> 
> Add a jump target so that a call of the function "mutex_unlock" is stored
> only once at the end of 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>

This simple case is a reasonable change.  A few minor points though.
Firstly, for a given subsystem please look at other patches to identify
the standard formatting used in patch titles.

Secondly make sure you don't make unconnected changes.  Here there
is a whitespace change that should not be here.

Jonathan
> ---
>  drivers/iio/proximity/srf08.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/iio/proximity/srf08.c b/drivers/iio/proximity/srf08.c
> index f2bf783f829a..85957550195b 100644
> --- a/drivers/iio/proximity/srf08.c
> +++ b/drivers/iio/proximity/srf08.c
> @@ -135,8 +135,7 @@ static int srf08_read_ranging(struct srf08_data *data)
>  			SRF08_WRITE_COMMAND, SRF08_CMD_RANGING_CM);
>  	if (ret < 0) {
>  		dev_err(&client->dev, "write command - err: %d\n", ret);
> -		mutex_unlock(&data->lock);
> -		return ret;
> +		goto unlock;
>  	}
>  
>  	/*
> @@ -163,20 +162,17 @@ static int srf08_read_ranging(struct srf08_data *data)
>  
>  	if (ret >= 255 || ret <= 0) {
>  		dev_err(&client->dev, "device not ready\n");
> -		mutex_unlock(&data->lock);
> -		return -EIO;
> +		ret = -EIO;
> +		goto unlock;
>  	}
>  
>  	ret = i2c_smbus_read_word_swapped(data->client,
>  						SRF08_READ_ECHO_1_HIGH);
> -	if (ret < 0) {
> +	if (ret < 0)
>  		dev_err(&client->dev, "cannot read distance: ret=%d\n", ret);
> -		mutex_unlock(&data->lock);
> -		return ret;
> -	}
>  
> +unlock:
>  	mutex_unlock(&data->lock);
> -

Please don't make unconnected white space changes.

>  	return ret;
>  }
>  


WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <jic23@kernel.org>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: linux-iio@vger.kernel.org, Andreas Klinger <ak@it-klinger.de>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] iio/proximity/srf08: Improve unlocking of a mutex in srf08_read_ranging()
Date: Thu, 26 Oct 2017 17:18:31 +0100	[thread overview]
Message-ID: <20171026171831.3e8018d2@archlinux> (raw)
In-Reply-To: <62f61dbd-b106-1d3f-fb75-3fa87251e6ef@users.sourceforge.net>

On Thu, 26 Oct 2017 17:00:07 +0200
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 26 Oct 2017 16:51:08 +0200
> 
> Add a jump target so that a call of the function "mutex_unlock" is stored
> only once at the end of 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>

This simple case is a reasonable change.  A few minor points though.
Firstly, for a given subsystem please look at other patches to identify
the standard formatting used in patch titles.

Secondly make sure you don't make unconnected changes.  Here there
is a whitespace change that should not be here.

Jonathan
> ---
>  drivers/iio/proximity/srf08.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/iio/proximity/srf08.c b/drivers/iio/proximity/srf08.c
> index f2bf783f829a..85957550195b 100644
> --- a/drivers/iio/proximity/srf08.c
> +++ b/drivers/iio/proximity/srf08.c
> @@ -135,8 +135,7 @@ static int srf08_read_ranging(struct srf08_data *data)
>  			SRF08_WRITE_COMMAND, SRF08_CMD_RANGING_CM);
>  	if (ret < 0) {
>  		dev_err(&client->dev, "write command - err: %d\n", ret);
> -		mutex_unlock(&data->lock);
> -		return ret;
> +		goto unlock;
>  	}
>  
>  	/*
> @@ -163,20 +162,17 @@ static int srf08_read_ranging(struct srf08_data *data)
>  
>  	if (ret >= 255 || ret <= 0) {
>  		dev_err(&client->dev, "device not ready\n");
> -		mutex_unlock(&data->lock);
> -		return -EIO;
> +		ret = -EIO;
> +		goto unlock;
>  	}
>  
>  	ret = i2c_smbus_read_word_swapped(data->client,
>  						SRF08_READ_ECHO_1_HIGH);
> -	if (ret < 0) {
> +	if (ret < 0)
>  		dev_err(&client->dev, "cannot read distance: ret=%d\n", ret);
> -		mutex_unlock(&data->lock);
> -		return ret;
> -	}
>  
> +unlock:
>  	mutex_unlock(&data->lock);
> -

Please don't make unconnected white space changes.

>  	return ret;
>  }
>  


  reply	other threads:[~2017-10-26 16:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-26 15:00 [PATCH] iio/proximity/srf08: Improve unlocking of a mutex in srf08_read_ranging() SF Markus Elfring
2017-10-26 15:00 ` SF Markus Elfring
2017-10-26 16:18 ` Jonathan Cameron [this message]
2017-10-26 16:18   ` 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=20171026171831.3e8018d2@archlinux \
    --to=jic23@kernel.org \
    --cc=ak@it-klinger.de \
    --cc=elfring@users.sourceforge.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.