iio:adc:berlin2-adc: enable interrupts with mutex locked
Move the call to enable channel interrupts into its _read() function to have it protected by a mutex. This ensures that only one channel is sampled at a time. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
Родитель
4b308e8c39
Коммит
3ac065224f
|
@ -111,6 +111,10 @@ static int berlin2_adc_read(struct iio_dev *indio_dev, int channel)
|
||||||
|
|
||||||
mutex_lock(&priv->lock);
|
mutex_lock(&priv->lock);
|
||||||
|
|
||||||
|
/* Enable the interrupts */
|
||||||
|
regmap_write(priv->regmap, BERLIN2_SM_ADC_STATUS,
|
||||||
|
BERLIN2_SM_ADC_STATUS_INT_EN(channel));
|
||||||
|
|
||||||
/* Configure the ADC */
|
/* Configure the ADC */
|
||||||
regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL,
|
regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL,
|
||||||
BERLIN2_SM_CTRL_ADC_RESET | BERLIN2_SM_CTRL_ADC_SEL_MASK
|
BERLIN2_SM_CTRL_ADC_RESET | BERLIN2_SM_CTRL_ADC_SEL_MASK
|
||||||
|
@ -149,6 +153,10 @@ static int berlin2_adc_tsen_read(struct iio_dev *indio_dev)
|
||||||
|
|
||||||
mutex_lock(&priv->lock);
|
mutex_lock(&priv->lock);
|
||||||
|
|
||||||
|
/* Enable interrupts */
|
||||||
|
regmap_write(priv->regmap, BERLIN2_SM_TSEN_STATUS,
|
||||||
|
BERLIN2_SM_TSEN_STATUS_INT_EN);
|
||||||
|
|
||||||
/* Configure the ADC */
|
/* Configure the ADC */
|
||||||
regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL,
|
regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL,
|
||||||
BERLIN2_SM_CTRL_TSEN_RESET | BERLIN2_SM_CTRL_ADC_ROTATE,
|
BERLIN2_SM_CTRL_TSEN_RESET | BERLIN2_SM_CTRL_ADC_ROTATE,
|
||||||
|
@ -190,7 +198,6 @@ static int berlin2_adc_read_raw(struct iio_dev *indio_dev,
|
||||||
struct iio_chan_spec const *chan, int *val, int *val2,
|
struct iio_chan_spec const *chan, int *val, int *val2,
|
||||||
long mask)
|
long mask)
|
||||||
{
|
{
|
||||||
struct berlin2_adc_priv *priv = iio_priv(indio_dev);
|
|
||||||
int temp;
|
int temp;
|
||||||
|
|
||||||
switch (mask) {
|
switch (mask) {
|
||||||
|
@ -198,10 +205,6 @@ static int berlin2_adc_read_raw(struct iio_dev *indio_dev,
|
||||||
if (chan->type != IIO_VOLTAGE)
|
if (chan->type != IIO_VOLTAGE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* Enable the interrupts */
|
|
||||||
regmap_write(priv->regmap, BERLIN2_SM_ADC_STATUS,
|
|
||||||
BERLIN2_SM_ADC_STATUS_INT_EN(chan->channel));
|
|
||||||
|
|
||||||
*val = berlin2_adc_read(indio_dev, chan->channel);
|
*val = berlin2_adc_read(indio_dev, chan->channel);
|
||||||
if (*val < 0)
|
if (*val < 0)
|
||||||
return *val;
|
return *val;
|
||||||
|
@ -211,10 +214,6 @@ static int berlin2_adc_read_raw(struct iio_dev *indio_dev,
|
||||||
if (chan->type != IIO_TEMP)
|
if (chan->type != IIO_TEMP)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* Enable interrupts */
|
|
||||||
regmap_write(priv->regmap, BERLIN2_SM_TSEN_STATUS,
|
|
||||||
BERLIN2_SM_TSEN_STATUS_INT_EN);
|
|
||||||
|
|
||||||
temp = berlin2_adc_tsen_read(indio_dev);
|
temp = berlin2_adc_tsen_read(indio_dev);
|
||||||
if (temp < 0)
|
if (temp < 0)
|
||||||
return temp;
|
return temp;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче