public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-iio@vger.kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	"Stefan Popa" <stefan.popa@analog.com>,
	"Hartmut Knaack" <knaack.h@gmx.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Subject: Re: [PATCH] iio: dac: ad5761: Replace indio_dev->mlock with own device lock
Date: Sat, 16 May 2020 16:23:33 +0100	[thread overview]
Message-ID: <20200516162333.647979d5@archlinux> (raw)
In-Reply-To: <20200514091032.80883-1-sergiu.cuciurean@analog.com>

On Thu, 14 May 2020 12:10:28 +0300
Sergiu Cuciurean <sergiu.cuciurean@analog.com> wrote:

> As part of the general cleanup of indio_dev->mlock, this change replaces
> it with a local lock on the device's state structure.
> 
> Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
Applied to the togreg branch of iio.git.

Thanks,

J
> ---
>  drivers/iio/dac/ad5761.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5761.c b/drivers/iio/dac/ad5761.c
> index 4fb42b743f0f..67179944e5c5 100644
> --- a/drivers/iio/dac/ad5761.c
> +++ b/drivers/iio/dac/ad5761.c
> @@ -57,11 +57,13 @@ enum ad5761_supported_device_ids {
>   * @use_intref:		true when the internal voltage reference is used
>   * @vref:		actual voltage reference in mVolts
>   * @range:		output range mode used
> + * @lock		lock to protect the data buffer during SPI ops
>   * @data:		cache aligned spi buffer
>   */
>  struct ad5761_state {
>  	struct spi_device		*spi;
>  	struct regulator		*vref_reg;
> +	struct mutex			lock;
>  
>  	bool use_intref;
>  	int vref;
> @@ -124,9 +126,9 @@ static int ad5761_spi_write(struct iio_dev *indio_dev, u8 addr, u16 val)
>  	struct ad5761_state *st = iio_priv(indio_dev);
>  	int ret;
>  
> -	mutex_lock(&indio_dev->mlock);
> +	mutex_lock(&st->lock);
>  	ret = _ad5761_spi_write(st, addr, val);
> -	mutex_unlock(&indio_dev->mlock);
> +	mutex_unlock(&st->lock);
>  
>  	return ret;
>  }
> @@ -163,9 +165,9 @@ static int ad5761_spi_read(struct iio_dev *indio_dev, u8 addr, u16 *val)
>  	struct ad5761_state *st = iio_priv(indio_dev);
>  	int ret;
>  
> -	mutex_lock(&indio_dev->mlock);
> +	mutex_lock(&st->lock);
>  	ret = _ad5761_spi_read(st, addr, val);
> -	mutex_unlock(&indio_dev->mlock);
> +	mutex_unlock(&st->lock);
>  
>  	return ret;
>  }
> @@ -368,6 +370,8 @@ static int ad5761_probe(struct spi_device *spi)
>  	if (pdata)
>  		voltage_range = pdata->voltage_range;
>  
> +	mutex_init(&st->lock);
> +
>  	ret = ad5761_spi_set_range(st, voltage_range);
>  	if (ret)
>  		goto disable_regulator_err;


      reply	other threads:[~2020-05-16 15:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-14  9:10 [PATCH] iio: dac: ad5761: Replace indio_dev->mlock with own device lock Sergiu Cuciurean
2020-05-16 15:23 ` 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=20200516162333.647979d5@archlinux \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.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=sergiu.cuciurean@analog.com \
    --cc=stefan.popa@analog.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