Commit 100bfa38 authored by Alexandru Ardelean's avatar Alexandru Ardelean Committed by Jonathan Cameron

iio: imu: adis[16480]: group RW into a single lock in adis_enable_irq()

The adis_enable_irq() does a read & a write. This change keeps a lock for
the duration of both operations vs for each op.

The change is also needed in adis16480, since that has it's own
implementation for adis_enable_irq().
Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 770d4656
...@@ -250,12 +250,16 @@ int adis_enable_irq(struct adis *adis, bool enable) ...@@ -250,12 +250,16 @@ int adis_enable_irq(struct adis *adis, bool enable)
int ret = 0; int ret = 0;
uint16_t msc; uint16_t msc;
if (adis->data->enable_irq) mutex_lock(&adis->state_lock);
return adis->data->enable_irq(adis, enable);
ret = adis_read_reg_16(adis, adis->data->msc_ctrl_reg, &msc); if (adis->data->enable_irq) {
ret = adis->data->enable_irq(adis, enable);
goto out_unlock;
}
ret = __adis_read_reg_16(adis, adis->data->msc_ctrl_reg, &msc);
if (ret) if (ret)
goto error_ret; goto out_unlock;
msc |= ADIS_MSC_CTRL_DATA_RDY_POL_HIGH; msc |= ADIS_MSC_CTRL_DATA_RDY_POL_HIGH;
msc &= ~ADIS_MSC_CTRL_DATA_RDY_DIO2; msc &= ~ADIS_MSC_CTRL_DATA_RDY_DIO2;
...@@ -264,9 +268,10 @@ int adis_enable_irq(struct adis *adis, bool enable) ...@@ -264,9 +268,10 @@ int adis_enable_irq(struct adis *adis, bool enable)
else else
msc &= ~ADIS_MSC_CTRL_DATA_RDY_EN; msc &= ~ADIS_MSC_CTRL_DATA_RDY_EN;
ret = adis_write_reg_16(adis, adis->data->msc_ctrl_reg, msc); ret = __adis_write_reg_16(adis, adis->data->msc_ctrl_reg, msc);
error_ret: out_unlock:
mutex_unlock(&adis->state_lock);
return ret; return ret;
} }
EXPORT_SYMBOL(adis_enable_irq); EXPORT_SYMBOL(adis_enable_irq);
......
...@@ -947,14 +947,14 @@ static int adis16480_enable_irq(struct adis *adis, bool enable) ...@@ -947,14 +947,14 @@ static int adis16480_enable_irq(struct adis *adis, bool enable)
uint16_t val; uint16_t val;
int ret; int ret;
ret = adis_read_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, &val); ret = __adis_read_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, &val);
if (ret) if (ret)
return ret; return ret;
val &= ~ADIS16480_DRDY_EN_MSK; val &= ~ADIS16480_DRDY_EN_MSK;
val |= ADIS16480_DRDY_EN(enable); val |= ADIS16480_DRDY_EN(enable);
return adis_write_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, val); return __adis_write_reg_16(adis, ADIS16480_REG_FNCTIO_CTRL, val);
} }
static int adis16480_initial_setup(struct iio_dev *indio_dev) static int adis16480_initial_setup(struct iio_dev *indio_dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment