linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: dac: ad5380: Replace indio_dev->mlock with own device lock
@ 2020-05-14  9:13 Sergiu Cuciurean
  2020-05-16 15:26 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Sergiu Cuciurean @ 2020-05-14  9:13 UTC (permalink / raw)
  To: linux-kernel, linux-iio
  Cc: Sergiu Cuciurean, Lars-Peter Clausen, Michael Hennerich,
	Stefan Popa, Jonathan Cameron, Hartmut Knaack,
	Peter Meerwald-Stadler

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>
---
 drivers/iio/dac/ad5380.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c
index 2ebe08326048..b37e5675f716 100644
--- a/drivers/iio/dac/ad5380.c
+++ b/drivers/iio/dac/ad5380.c
@@ -51,6 +51,7 @@ struct ad5380_chip_info {
  * @vref_reg:		vref supply regulator
  * @vref:		actual reference voltage used in uA
  * @pwr_down:		whether the chip is currently in power down mode
+ * @lock		lock to protect the data buffer during regmap ops
  */
 
 struct ad5380_state {
@@ -59,6 +60,7 @@ struct ad5380_state {
 	struct regulator		*vref_reg;
 	int				vref;
 	bool				pwr_down;
+	struct mutex			lock;
 };
 
 enum ad5380_type {
@@ -98,7 +100,7 @@ static ssize_t ad5380_write_dac_powerdown(struct iio_dev *indio_dev,
 	if (ret)
 		return ret;
 
-	mutex_lock(&indio_dev->mlock);
+	mutex_lock(&st->lock);
 
 	if (pwr_down)
 		ret = regmap_write(st->regmap, AD5380_REG_SF_PWR_DOWN, 0);
@@ -107,7 +109,7 @@ static ssize_t ad5380_write_dac_powerdown(struct iio_dev *indio_dev,
 
 	st->pwr_down = pwr_down;
 
-	mutex_unlock(&indio_dev->mlock);
+	mutex_unlock(&st->lock);
 
 	return ret ? ret : len;
 }
@@ -390,6 +392,8 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
 	indio_dev->modes = INDIO_DIRECT_MODE;
 	indio_dev->num_channels = st->chip_info->num_channels;
 
+	mutex_init(&st->lock);
+
 	ret = ad5380_alloc_channels(indio_dev);
 	if (ret) {
 		dev_err(dev, "Failed to allocate channel spec: %d\n", ret);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: dac: ad5380: Replace indio_dev->mlock with own device lock
  2020-05-14  9:13 [PATCH] iio: dac: ad5380: Replace indio_dev->mlock with own device lock Sergiu Cuciurean
@ 2020-05-16 15:26 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2020-05-16 15:26 UTC (permalink / raw)
  To: Sergiu Cuciurean
  Cc: linux-kernel, linux-iio, Lars-Peter Clausen, Michael Hennerich,
	Stefan Popa, Hartmut Knaack, Peter Meerwald-Stadler

On Thu, 14 May 2020 12:13:11 +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/ad5380.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c
> index 2ebe08326048..b37e5675f716 100644
> --- a/drivers/iio/dac/ad5380.c
> +++ b/drivers/iio/dac/ad5380.c
> @@ -51,6 +51,7 @@ struct ad5380_chip_info {
>   * @vref_reg:		vref supply regulator
>   * @vref:		actual reference voltage used in uA
>   * @pwr_down:		whether the chip is currently in power down mode
> + * @lock		lock to protect the data buffer during regmap ops
>   */
>  
>  struct ad5380_state {
> @@ -59,6 +60,7 @@ struct ad5380_state {
>  	struct regulator		*vref_reg;
>  	int				vref;
>  	bool				pwr_down;
> +	struct mutex			lock;
>  };
>  
>  enum ad5380_type {
> @@ -98,7 +100,7 @@ static ssize_t ad5380_write_dac_powerdown(struct iio_dev *indio_dev,
>  	if (ret)
>  		return ret;
>  
> -	mutex_lock(&indio_dev->mlock);
> +	mutex_lock(&st->lock);
>  
>  	if (pwr_down)
>  		ret = regmap_write(st->regmap, AD5380_REG_SF_PWR_DOWN, 0);
> @@ -107,7 +109,7 @@ static ssize_t ad5380_write_dac_powerdown(struct iio_dev *indio_dev,
>  
>  	st->pwr_down = pwr_down;
>  
> -	mutex_unlock(&indio_dev->mlock);
> +	mutex_unlock(&st->lock);
>  
>  	return ret ? ret : len;
>  }
> @@ -390,6 +392,8 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
>  	indio_dev->modes = INDIO_DIRECT_MODE;
>  	indio_dev->num_channels = st->chip_info->num_channels;
>  
> +	mutex_init(&st->lock);
> +
>  	ret = ad5380_alloc_channels(indio_dev);
>  	if (ret) {
>  		dev_err(dev, "Failed to allocate channel spec: %d\n", ret);


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-16 15:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-14  9:13 [PATCH] iio: dac: ad5380: Replace indio_dev->mlock with own device lock Sergiu Cuciurean
2020-05-16 15:26 ` Jonathan Cameron

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).