linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Alison Schofield <amsfield22@gmail.com>
Cc: tduszyns@gmail.com, knaack.h@gmx.de, lars@metafoo.de,
	pmeerw@pmeerw.net, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: pressure: ms5611: claim direct mode during oversampling changes
Date: Sat, 21 Jan 2017 12:32:14 +0000	[thread overview]
Message-ID: <7afaeb60-2bf5-533b-9af2-7ef9c967bfbd@kernel.org> (raw)
In-Reply-To: <20170120202242.GA2153@d830.WORKGROUP>

On 20/01/17 20:22, Alison Schofield wrote:
> Driver was checking for direct mode before changing oversampling
> ratios, but was not locking it.  Use the claim/release helper
> functions to guarantee the device stays in direct mode while the
> oversampling ratios are being updated.  Continue to use the drivers
> private state lock to protect against conflicting direct mode access
> of the state data.
> 
> Signed-off-by: Alison Schofield <amsfield22@gmail.com>
I think this one is straight forward enough that I'm happy to take it
without confirmation from Thomaz.  

Anyone feel free to shout if I am missing something.

Thanks,

Jonathan
> ---
>  drivers/iio/pressure/ms5611_core.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/pressure/ms5611_core.c b/drivers/iio/pressure/ms5611_core.c
> index 6bd53e7..2a77a2f 100644
> --- a/drivers/iio/pressure/ms5611_core.c
> +++ b/drivers/iio/pressure/ms5611_core.c
> @@ -308,6 +308,7 @@ static int ms5611_write_raw(struct iio_dev *indio_dev,
>  {
>  	struct ms5611_state *st = iio_priv(indio_dev);
>  	const struct ms5611_osr *osr = NULL;
> +	int ret;
>  
>  	if (mask != IIO_CHAN_INFO_OVERSAMPLING_RATIO)
>  		return -EINVAL;
> @@ -321,12 +322,11 @@ static int ms5611_write_raw(struct iio_dev *indio_dev,
>  	if (!osr)
>  		return -EINVAL;
>  
> -	mutex_lock(&st->lock);
> +	ret = iio_device_claim_direct_mode(indio_dev);
> +	if (ret)
> +		return ret;
>  
> -	if (iio_buffer_enabled(indio_dev)) {
> -		mutex_unlock(&st->lock);
> -		return -EBUSY;
> -	}
> +	mutex_lock(&st->lock);
>  
>  	if (chan->type == IIO_TEMP)
>  		st->temp_osr = osr;
> @@ -334,6 +334,8 @@ static int ms5611_write_raw(struct iio_dev *indio_dev,
>  		st->pressure_osr = osr;
>  
>  	mutex_unlock(&st->lock);
> +	iio_device_release_direct_mode(indio_dev);
> +
>  	return 0;
>  }
>  
> 

      reply	other threads:[~2017-01-21 12:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20 20:22 [PATCH] iio: pressure: ms5611: claim direct mode during oversampling changes Alison Schofield
2017-01-21 12:32 ` 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=7afaeb60-2bf5-533b-9af2-7ef9c967bfbd@kernel.org \
    --to=jic23@kernel.org \
    --cc=amsfield22@gmail.com \
    --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 \
    --cc=tduszyns@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;
as well as URLs for NNTP newsgroup(s).