Commit 04ca37d5 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Jonathan Cameron

iio: imu: st_lsm6dsx: rely on st_lsm6dsx_update_bits_locked configuring events

Rely on st_lsm6dsx_update_bits_locked in st_lsm6dsx_write_event and
st_lsm6dsx_event_setup routines since they can run concurrently with
sensor hub configuration

Fixes: b5969abf ("iio: imu: st_lsm6dsx: add motion events")
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 84b2e7c3
...@@ -1498,6 +1498,7 @@ static int st_lsm6dsx_write_raw(struct iio_dev *iio_dev, ...@@ -1498,6 +1498,7 @@ static int st_lsm6dsx_write_raw(struct iio_dev *iio_dev,
static int st_lsm6dsx_event_setup(struct st_lsm6dsx_hw *hw, int state) static int st_lsm6dsx_event_setup(struct st_lsm6dsx_hw *hw, int state)
{ {
const struct st_lsm6dsx_reg *reg; const struct st_lsm6dsx_reg *reg;
unsigned int data;
int err; int err;
if (!hw->settings->irq_config.irq1_func.addr) if (!hw->settings->irq_config.irq1_func.addr)
...@@ -1505,17 +1506,17 @@ static int st_lsm6dsx_event_setup(struct st_lsm6dsx_hw *hw, int state) ...@@ -1505,17 +1506,17 @@ static int st_lsm6dsx_event_setup(struct st_lsm6dsx_hw *hw, int state)
reg = &hw->settings->event_settings.enable_reg; reg = &hw->settings->event_settings.enable_reg;
if (reg->addr) { if (reg->addr) {
err = regmap_update_bits(hw->regmap, reg->addr, reg->mask, data = ST_LSM6DSX_SHIFT_VAL(state, reg->mask);
ST_LSM6DSX_SHIFT_VAL(state, reg->mask)); err = st_lsm6dsx_update_bits_locked(hw, reg->addr,
reg->mask, data);
if (err < 0) if (err < 0)
return err; return err;
} }
/* Enable wakeup interrupt */ /* Enable wakeup interrupt */
return regmap_update_bits(hw->regmap, hw->irq_routing->addr, data = ST_LSM6DSX_SHIFT_VAL(state, hw->irq_routing->mask);
hw->irq_routing->mask, return st_lsm6dsx_update_bits_locked(hw, hw->irq_routing->addr,
ST_LSM6DSX_SHIFT_VAL(state, hw->irq_routing->mask, data);
hw->irq_routing->mask));
} }
static int st_lsm6dsx_read_event(struct iio_dev *iio_dev, static int st_lsm6dsx_read_event(struct iio_dev *iio_dev,
...@@ -1546,6 +1547,8 @@ static int st_lsm6dsx_write_event(struct iio_dev *iio_dev, ...@@ -1546,6 +1547,8 @@ static int st_lsm6dsx_write_event(struct iio_dev *iio_dev,
{ {
struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev); struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);
struct st_lsm6dsx_hw *hw = sensor->hw; struct st_lsm6dsx_hw *hw = sensor->hw;
const struct st_lsm6dsx_reg *reg;
unsigned int data;
int err; int err;
if (type != IIO_EV_TYPE_THRESH) if (type != IIO_EV_TYPE_THRESH)
...@@ -1554,11 +1557,11 @@ static int st_lsm6dsx_write_event(struct iio_dev *iio_dev, ...@@ -1554,11 +1557,11 @@ static int st_lsm6dsx_write_event(struct iio_dev *iio_dev,
if (val < 0 || val > 31) if (val < 0 || val > 31)
return -EINVAL; return -EINVAL;
err = regmap_update_bits(hw->regmap, reg = &hw->settings->event_settings.wakeup_reg;
hw->settings->event_settings.wakeup_reg.addr, data = ST_LSM6DSX_SHIFT_VAL(val, reg->mask);
hw->settings->event_settings.wakeup_reg.mask, err = st_lsm6dsx_update_bits_locked(hw, reg->addr,
val); reg->mask, data);
if (err) if (err < 0)
return -EINVAL; return -EINVAL;
hw->event_threshold = val; hw->event_threshold = val;
......
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