aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOctavian Purdila <octavian.purdila@intel.com>2015-01-30 19:00:05 -0500
committerJonathan Cameron <jic23@kernel.org>2015-02-08 05:40:25 -0500
commit14ee64f438b8e85d1c78939d301956d9a775cc9a (patch)
treee73c5e7181cd6f60aeadcb5abad2345f338fee2c
parent8e22f477e1432ace88b762f5f66e0f96631a1462 (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>
-rw-r--r--drivers/iio/accel/bmc150-accel.c14
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,
748 struct bmc150_accel_data *data = iio_priv(indio_dev); 748 struct bmc150_accel_data *data = iio_priv(indio_dev);
749 int ret; 749 int ret;
750 750
751 if (state && data->ev_enable_state) 751 if (state == data->ev_enable_state)
752 return 0; 752 return 0;
753 753
754 mutex_lock(&data->mutex); 754 mutex_lock(&data->mutex);
@@ -984,6 +984,18 @@ static int bmc150_accel_data_rdy_trigger_set_state(struct iio_trigger *trig,
984 984
985 mutex_lock(&data->mutex); 985 mutex_lock(&data->mutex);
986 986
987 if (data->motion_trig == trig) {
988 if (data->motion_trigger_on == state) {
989 mutex_unlock(&data->mutex);
990 return 0;
991 }
992 } else {
993 if (data->dready_trigger_on == state) {
994 mutex_unlock(&data->mutex);
995 return 0;
996 }
997 }
998
987 if (!state && data->ev_enable_state && data->motion_trigger_on) { 999 if (!state && data->ev_enable_state && data->motion_trigger_on) {
988 data->motion_trigger_on = false; 1000 data->motion_trigger_on = false;
989 mutex_unlock(&data->mutex); 1001 mutex_unlock(&data->mutex);