linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: linux-iio@vger.kernel.org, lars@metafoo.de, knaack.h@gmx.de
Subject: Re: [PATCH 4/4] iio: light: vcnl4000: Add missing locking
Date: Sun, 10 Jul 2016 14:34:12 +0100	[thread overview]
Message-ID: <f185cf5e-4c02-6f88-c38c-87cdd05f54c8@kernel.org> (raw)
In-Reply-To: <1467714201-11429-5-git-send-email-pmeerw@pmeerw.net>

On 05/07/16 11:23, Peter Meerwald-Stadler wrote:
> Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
As this was never right, it's not a regression so whilst this will fix
some potential race conditions, I'm not going to consider it for stable.

Thanks for the whole series.  Always nice to see continued work on a
driver years after it initially went in!

Jonathan
> ---
>  drivers/iio/light/vcnl4000.c |   18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
> index 9f94b6b..360b6e9 100644
> --- a/drivers/iio/light/vcnl4000.c
> +++ b/drivers/iio/light/vcnl4000.c
> @@ -48,6 +48,7 @@
>  
>  struct vcnl4000_data {
>  	struct i2c_client *client;
> +	struct mutex lock;
>  };
>  
>  static const struct i2c_device_id vcnl4000_id[] = {
> @@ -63,16 +64,18 @@ static int vcnl4000_measure(struct vcnl4000_data *data, u8 req_mask,
>  	__be16 buf;
>  	int ret;
>  
> +	mutex_lock(&data->lock);
> +
>  	ret = i2c_smbus_write_byte_data(data->client, VCNL4000_COMMAND,
>  					req_mask);
>  	if (ret < 0)
> -		return ret;
> +		goto fail;
>  
>  	/* wait for data to become ready */
>  	while (tries--) {
>  		ret = i2c_smbus_read_byte_data(data->client, VCNL4000_COMMAND);
>  		if (ret < 0)
> -			return ret;
> +			goto fail;
>  		if (ret & rdy_mask)
>  			break;
>  		msleep(20); /* measurement takes up to 100 ms */
> @@ -81,17 +84,23 @@ static int vcnl4000_measure(struct vcnl4000_data *data, u8 req_mask,
>  	if (tries < 0) {
>  		dev_err(&data->client->dev,
>  			"vcnl4000_measure() failed, data not ready\n");
> -		return -EIO;
> +		ret = -EIO;
> +		goto fail;
>  	}
>  
>  	ret = i2c_smbus_read_i2c_block_data(data->client,
>  		data_reg, sizeof(buf), (u8 *) &buf);
>  	if (ret < 0)
> -		return ret;
> +		goto fail;
>  
> +	mutex_unlock(&data->lock);
>  	*val = be16_to_cpu(buf);
>  
>  	return 0;
> +
> +fail:
> +	mutex_unlock(&data->lock);
> +	return ret;
>  }
>  
>  static const struct iio_chan_spec vcnl4000_channels[] = {
> @@ -163,6 +172,7 @@ static int vcnl4000_probe(struct i2c_client *client,
>  	data = iio_priv(indio_dev);
>  	i2c_set_clientdata(client, indio_dev);
>  	data->client = client;
> +	mutex_init(&data->lock);
>  
>  	ret = i2c_smbus_read_byte_data(data->client, VCNL4000_PROD_REV);
>  	if (ret < 0)
> 


      reply	other threads:[~2016-07-10 13:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-05 10:23 [PATCH 0/4] iio: light: vcnl4000: cleanup and fixes Peter Meerwald-Stadler
2016-07-05 10:23 ` [PATCH 1/4] iio: light: vcnl4000: Mention and check support for VCNL4010 and VCNL4020 Peter Meerwald-Stadler
2016-07-10 13:29   ` Jonathan Cameron
2016-07-05 10:23 ` [PATCH 2/4] iio: light: vcnl4000: Use BIT() macro Peter Meerwald-Stadler
2016-07-10 13:31   ` Jonathan Cameron
2016-07-05 10:23 ` [PATCH 3/4] iio: light: vcnl4000: Cleanup read_raw() returns Peter Meerwald-Stadler
2016-07-10 13:32   ` Jonathan Cameron
2016-07-05 10:23 ` [PATCH 4/4] iio: light: vcnl4000: Add missing locking Peter Meerwald-Stadler
2016-07-10 13:34   ` 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=f185cf5e-4c02-6f88-c38c-87cdd05f54c8@kernel.org \
    --to=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@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;
as well as URLs for NNTP newsgroup(s).