diff options
author | Octavian Purdila <octavian.purdila@intel.com> | 2015-01-31 02:00:05 +0200 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-02-08 10:40:25 +0000 |
commit | 14ee64f438b8e85d1c78939d301956d9a775cc9a (patch) | |
tree | e73c5e7181cd6f60aeadcb5abad2345f338fee2c /drivers/iio | |
parent | 8e22f477e1432ace88b762f5f66e0f96631a1462 (diff) |
iio: bmc150: exit early if event / trigger state is not changed
Previous of this patch the check was only done if we enabled the event
and it was already enabled. We can do the same if the event is
disabled and we want to disable it.
The patch also adds the same check on the trigger code.
Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/accel/bmc150-accel.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c index 087392514e54..f040f405d826 100644 --- a/drivers/iio/accel/bmc150-accel.c +++ b/drivers/iio/accel/bmc150-accel.c @@ -748,7 +748,7 @@ static int bmc150_accel_write_event_config(struct iio_dev *indio_dev, struct bmc150_accel_data *data = iio_priv(indio_dev); int ret; - if (state && data->ev_enable_state) + if (state == data->ev_enable_state) return 0; mutex_lock(&data->mutex); @@ -984,6 +984,18 @@ static int bmc150_accel_data_rdy_trigger_set_state(struct iio_trigger *trig, mutex_lock(&data->mutex); + if (data->motion_trig == trig) { + if (data->motion_trigger_on == state) { + mutex_unlock(&data->mutex); + return 0; + } + } else { + if (data->dready_trigger_on == state) { + mutex_unlock(&data->mutex); + return 0; + } + } + if (!state && data->ev_enable_state && data->motion_trigger_on) { data->motion_trigger_on = false; mutex_unlock(&data->mutex); |