Re: [PATCH v2] iio: adc: max1363: replace mlock with own lock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 29 Feb 2020 00:01:37 +0530
Rohit Sarkar <rohitsarkar5398@xxxxxxxxx> wrote:

> This change replaces indio_dev's mlock with the drivers own lock. In
> each case the lock is needed to protect the driver's own state.
> 
> Signed-off-by: Rohit Sarkar <rohitsarkar5398@xxxxxxxxx>
So this deals with the simpler cases where we want to change the lock.
Makes sense to separate the two.

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to have a poke at it. I'll do a pull request in the
next few days and when that gets taken by Greg KH these will then show
up in next and be queued up by him for the merge window that will open
in perhaps 3 weeks time.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/max1363.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c
> index 5c2cc61b666e..198094ad79a1 100644
> --- a/drivers/iio/adc/max1363.c
> +++ b/drivers/iio/adc/max1363.c
> @@ -169,6 +169,7 @@ struct max1363_state {
>  	const struct max1363_mode	*current_mode;
>  	u32				requestedmask;
>  	struct regulator		*reg;
> +	struct mutex			lock;
>  
>  	/* Using monitor modes and buffer at the same time is
>  	   currently not supported */
> @@ -364,7 +365,7 @@ static int max1363_read_single_chan(struct iio_dev *indio_dev,
>  	struct max1363_state *st = iio_priv(indio_dev);
>  	struct i2c_client *client = st->client;
>  
> -	mutex_lock(&indio_dev->mlock);
> +	mutex_lock(&st->lock);
>  	/*
>  	 * If monitor mode is enabled, the method for reading a single
>  	 * channel will have to be rather different and has not yet
> @@ -405,7 +406,7 @@ static int max1363_read_single_chan(struct iio_dev *indio_dev,
>  	}
>  	*val = data;
>  error_ret:
> -	mutex_unlock(&indio_dev->mlock);
> +	mutex_unlock(&st->lock);
>  	return ret;
>  
>  }
> @@ -705,9 +706,9 @@ static ssize_t max1363_monitor_store_freq(struct device *dev,
>  	if (!found)
>  		return -EINVAL;
>  
> -	mutex_lock(&indio_dev->mlock);
> +	mutex_lock(&st->mlock);
>  	st->monitor_speed = i;
> -	mutex_unlock(&indio_dev->mlock);
> +	mutex_unlock(&st->mlock);
>  
>  	return 0;
>  }
> @@ -810,12 +811,12 @@ static int max1363_read_event_config(struct iio_dev *indio_dev,
>  	int val;
>  	int number = chan->channel;
>  
> -	mutex_lock(&indio_dev->mlock);
> +	mutex_lock(&st->mlock);
>  	if (dir == IIO_EV_DIR_FALLING)
>  		val = (1 << number) & st->mask_low;
>  	else
>  		val = (1 << number) & st->mask_high;
> -	mutex_unlock(&indio_dev->mlock);
> +	mutex_unlock(&st->mlock);
>  
>  	return val;
>  }
> @@ -1587,6 +1588,7 @@ static int max1363_probe(struct i2c_client *client,
>  
>  	st = iio_priv(indio_dev);
>  
> +	mutex_init(&st->lock);
>  	st->reg = devm_regulator_get(&client->dev, "vcc");
>  	if (IS_ERR(st->reg)) {
>  		ret = PTR_ERR(st->reg);




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux