From: Jonathan Cameron <jic23@jic23.retrosnub.co.uk>
To: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: <linux-iio@vger.kernel.org>
Subject: Re: [PATCH 2/5] iio: amplifiers: ad8366: use own lock to guard state
Date: Sat, 8 Jun 2019 14:55:38 +0100 [thread overview]
Message-ID: <20190608145538.0107f3ce@archlinux> (raw)
In-Reply-To: <20190530131812.3476-2-alexandru.ardelean@analog.com>
On Thu, 30 May 2019 16:18:09 +0300
Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:
> This driver is still using iio_dev's mlock to guard against inconsistent
> state. This has been discouraged for some time.
>
> This change switches to using it's own mutex, defined on the state struct.
>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Applied,
Thanks,
Jonathan
> ---
> drivers/iio/amplifiers/ad8366.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
> index 82ac15914ff3..24ff5475d9f2 100644
> --- a/drivers/iio/amplifiers/ad8366.c
> +++ b/drivers/iio/amplifiers/ad8366.c
> @@ -21,6 +21,7 @@
> struct ad8366_state {
> struct spi_device *spi;
> struct regulator *reg;
> + struct mutex lock; /* protect sensor state */
> unsigned char ch[2];
> /*
> * DMA (thus cache coherency maintenance) requires the
> @@ -58,7 +59,7 @@ static int ad8366_read_raw(struct iio_dev *indio_dev,
> int ret;
> unsigned code;
>
> - mutex_lock(&indio_dev->mlock);
> + mutex_lock(&st->lock);
> switch (m) {
> case IIO_CHAN_INFO_HARDWAREGAIN:
> code = st->ch[chan->channel];
> @@ -73,7 +74,7 @@ static int ad8366_read_raw(struct iio_dev *indio_dev,
> default:
> ret = -EINVAL;
> }
> - mutex_unlock(&indio_dev->mlock);
> + mutex_unlock(&st->lock);
>
> return ret;
> };
> @@ -99,7 +100,7 @@ static int ad8366_write_raw(struct iio_dev *indio_dev,
>
> code = (code - 4500) / 253;
>
> - mutex_lock(&indio_dev->mlock);
> + mutex_lock(&st->lock);
> switch (mask) {
> case IIO_CHAN_INFO_HARDWAREGAIN:
> st->ch[chan->channel] = code;
> @@ -108,7 +109,7 @@ static int ad8366_write_raw(struct iio_dev *indio_dev,
> default:
> ret = -EINVAL;
> }
> - mutex_unlock(&indio_dev->mlock);
> + mutex_unlock(&st->lock);
>
> return ret;
> }
> @@ -151,6 +152,7 @@ static int ad8366_probe(struct spi_device *spi)
> }
>
> spi_set_drvdata(spi, indio_dev);
> + mutex_init(&st->lock);
> st->spi = spi;
>
> indio_dev->dev.parent = &spi->dev;
next prev parent reply other threads:[~2019-06-08 13:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-30 13:18 [PATCH 1/5] iio: amplifiers: update license information Alexandru Ardelean
2019-05-30 13:18 ` [PATCH 2/5] iio: amplifiers: ad8366: use own lock to guard state Alexandru Ardelean
2019-06-08 13:55 ` Jonathan Cameron [this message]
2019-05-30 13:18 ` [PATCH 3/5] iio: amplifiers: ad8366: rework driver to allow other chips Alexandru Ardelean
2019-06-08 13:57 ` Jonathan Cameron
2019-05-30 13:18 ` [PATCH 4/5] iio: amplifiers: ad8366: Add support for the ADA4961 DGA Alexandru Ardelean
2019-06-08 14:04 ` Jonathan Cameron
2019-06-08 20:20 ` Alexandru Ardelean
2019-05-30 13:18 ` [PATCH 5/5] iio: amplifiers: ad8366: Add support for ADL5240 VGA Alexandru Ardelean
2019-06-08 14:05 ` Jonathan Cameron
2019-06-08 13:54 ` [PATCH 1/5] iio: amplifiers: update license information 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=20190608145538.0107f3ce@archlinux \
--to=jic23@jic23.retrosnub.co.uk \
--cc=alexandru.ardelean@analog.com \
--cc=linux-iio@vger.kernel.org \
/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).