linux-pm.vger.kernel.org archive mirror
 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>,
	Stefan Popa <stefan.popa@analog.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	<linux-pm@vger.kernel.org>
Subject: Re: [PATCH] iio: dac: ad5686: Replace indio_dev->mlock with own device lock
Date: Sat, 16 May 2020 16:30:07 +0100	[thread overview]
Message-ID: <20200516163007.275a3da4@archlinux> (raw)
In-Reply-To: <20200514091940.81494-1-sergiu.cuciurean@analog.com>

On Thu, 14 May 2020 12:19:38 +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,

Thanks,

Jonathan

> ---
>  drivers/iio/dac/ad5686.c | 10 ++++++----
>  drivers/iio/dac/ad5686.h |  2 ++
>  2 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
> index e06b29c565b9..8dd67da0a7da 100644
> --- a/drivers/iio/dac/ad5686.c
> +++ b/drivers/iio/dac/ad5686.c
> @@ -127,9 +127,9 @@ static int ad5686_read_raw(struct iio_dev *indio_dev,
>  
>  	switch (m) {
>  	case IIO_CHAN_INFO_RAW:
> -		mutex_lock(&indio_dev->mlock);
> +		mutex_lock(&st->lock);
>  		ret = st->read(st, chan->address);
> -		mutex_unlock(&indio_dev->mlock);
> +		mutex_unlock(&st->lock);
>  		if (ret < 0)
>  			return ret;
>  		*val = (ret >> chan->scan_type.shift) &
> @@ -157,12 +157,12 @@ static int ad5686_write_raw(struct iio_dev *indio_dev,
>  		if (val > (1 << chan->scan_type.realbits) || val < 0)
>  			return -EINVAL;
>  
> -		mutex_lock(&indio_dev->mlock);
> +		mutex_lock(&st->lock);
>  		ret = st->write(st,
>  				AD5686_CMD_WRITE_INPUT_N_UPDATE_N,
>  				chan->address,
>  				val << chan->scan_type.shift);
> -		mutex_unlock(&indio_dev->mlock);
> +		mutex_unlock(&st->lock);
>  		break;
>  	default:
>  		ret = -EINVAL;
> @@ -468,6 +468,8 @@ int ad5686_probe(struct device *dev,
>  	indio_dev->channels = st->chip_info->channels;
>  	indio_dev->num_channels = st->chip_info->num_channels;
>  
> +	mutex_init(&st->lock);
> +
>  	switch (st->chip_info->regmap_type) {
>  	case AD5310_REGMAP:
>  		cmd = AD5686_CMD_CONTROL_REG;
> diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h
> index 70a779939ddb..52009b5eef88 100644
> --- a/drivers/iio/dac/ad5686.h
> +++ b/drivers/iio/dac/ad5686.h
> @@ -117,6 +117,7 @@ struct ad5686_chip_info {
>   * @pwr_down_mask:	power down mask
>   * @pwr_down_mode:	current power down mode
>   * @use_internal_vref:	set to true if the internal reference voltage is used
> + * @lock		lock to protect the data buffer during regmap ops
>   * @data:		spi transfer buffers
>   */
>  
> @@ -130,6 +131,7 @@ struct ad5686_state {
>  	ad5686_write_func		write;
>  	ad5686_read_func		read;
>  	bool				use_internal_vref;
> +	struct mutex			lock;
>  
>  	/*
>  	 * DMA (thus cache coherency maintenance) requires the


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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-14  9:19 [PATCH] iio: dac: ad5686: Replace indio_dev->mlock with own device lock Sergiu Cuciurean
2020-05-16 15:30 ` 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=20200516163007.275a3da4@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=linux-pm@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;
as well as URLs for NNTP newsgroup(s).