iio: accel: bmc150: Error handling when mode set fails
PATCH 2/3 iio: accel: bmc150: Send x, y and z motion separately
In reply to Srinivas PandruvadaThis chip is capable to identify motion across x, y and z axes. So send different events.
--- drivers/iio/accel/bmc150-accel.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)
drivers/iio/accel/bmc150-accel.c +21 -4
@@ -44,6 +44,9 @@#define BMC150_ACCEL_REG_INT_STATUS_2 0x0B#define BMC150_ACCEL_ANY_MOTION_MASK 0x07 +#define BMC150_ACCEL_ANY_MOTION_BIT_X BIT(0) +#define BMC150_ACCEL_ANY_MOTION_BIT_Y BIT(1) +#define BMC150_ACCEL_ANY_MOTION_BIT_Z BIT(2)#define BMC150_ACCEL_ANY_MOTION_BIT_SIGN BIT(3)#define BMC150_ACCEL_REG_PMU_LPW 0x11
@@ -850,7 +853,7 @@ static const struct attribute_group bmc150_accel_attrs_group = {static const struct iio_event_spec bmc150_accel_event = { .type =IIO_EV_TYPE_ROC , - .dir =IIO_EV_DIR_RISING |IIO_EV_DIR_FALLING , + .dir =IIO_EV_DIR_EITHER , .mask_separate =BIT (IIO_EV_INFO_VALUE ) |BIT (IIO_EV_INFO_ENABLE ) |BIT (IIO_EV_INFO_PERIOD )
@@ -1097,12 +1100,26 @@ static irqreturn_t bmc150_accel_event_handler(int irq, void *private)else dir =IIO_EV_DIR_RISING ; -if (ret &BMC150_ACCEL_ANY_MOTION_MASK ) +if (ret &BMC150_ACCEL_ANY_MOTION_BIT_X )iio_push_event (indio_dev,IIO_MOD_EVENT_CODE (IIO_ACCEL ,0 , -IIO_MOD_X_OR_Y_OR_Z , +IIO_MOD_X ,IIO_EV_TYPE_ROC , -IIO_EV_DIR_EITHER ), + dir), + data->timestamp); +if (ret &BMC150_ACCEL_ANY_MOTION_BIT_Y ) +iio_push_event (indio_dev,IIO_MOD_EVENT_CODE (IIO_ACCEL , +0 , +IIO_MOD_Y , +IIO_EV_TYPE_ROC , + dir), + data->timestamp); +if (ret &BMC150_ACCEL_ANY_MOTION_BIT_Z ) +iio_push_event (indio_dev,IIO_MOD_EVENT_CODE (IIO_ACCEL , +0 , +IIO_MOD_Z , +IIO_EV_TYPE_ROC , + dir), data->timestamp); ack_intr_status:if (!data->dready_trigger_on)
Signature · 1 line
1.9.3
PATCH 3/3 iio: accel: bmc150: set low default thresholds
In reply to Srinivas PandruvadaSet the threshold to low by default. With this thresholds any movement on the device with this sensor will generate event.
--- drivers/iio/accel/bmc150-accel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/accel/bmc150-accel.c +2 -2
@@ -95,9 +95,9 @@#define BMC150_ACCEL_SLOPE_THRES_MASK 0xFF/* Slope duration in terms of number of samples */ -#define BMC150_ACCEL_DEF_SLOPE_DURATION 2 +#define BMC150_ACCEL_DEF_SLOPE_DURATION 1/* in terms of multiples of g's/LSB, based on range */ -#define BMC150_ACCEL_DEF_SLOPE_THRESHOLD 5 +#define BMC150_ACCEL_DEF_SLOPE_THRESHOLD 1#define BMC150_ACCEL_REG_XOUT_L 0x02
Signature · 1 line
1.9.3
PATCH 1/3 iio: accel: bmc150: Error handling when mode set fails
When mode set fails due to some transient failures, it will atleast reset the state of runtime usage count and also let the runtime suspend retry from the driver framework.
--- drivers/iio/accel/bmc150-accel.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/iio/accel/bmc150-accel.c +10 -1
@@ -536,6 +536,9 @@ static int bmc150_accel_set_power_state(struct bmc150_accel_data *data, bool on)if (ret <0 ) {dev_err (&data->client->dev,"Failed: bmc150_accel_set_power_state for %d\n" , on); +if (on) +pm_runtime_put_noidle (&data->client->dev); +return ret; }
@@ -811,6 +814,7 @@ static int bmc150_accel_write_event_config(struct iio_dev *indio_dev, ret =bmc150_accel_setup_any_motion_interrupt (data, state);if (ret <0 ) { +bmc150_accel_set_power_state (data, false);mutex_unlock (&data->mutex);return ret; }
@@ -1054,6 +1058,7 @@ static int bmc150_accel_data_rdy_trigger_set_state(struct iio_trigger *trig,else ret =bmc150_accel_setup_new_data_interrupt (data, state);if (ret <0 ) { +bmc150_accel_set_power_state (data, false);mutex_unlock (&data->mutex);return ret; }
@@ -1354,10 +1359,14 @@ static int bmc150_accel_runtime_suspend(struct device *dev) {struct iio_dev *indio_dev =i2c_get_clientdata (to_i2c_client (dev));struct bmc150_accel_data *data =iio_priv (indio_dev); +int ret;dev_dbg (&data->client->dev, __func__); + ret =bmc150_accel_set_mode (data,BMC150_ACCEL_SLEEP_MODE_SUSPEND ,0 ); +if (ret <0 ) +return -EAGAIN ; -return bmc150_accel_set_mode (data,BMC150_ACCEL_SLEEP_MODE_SUSPEND ,0 ); +return 0 ; }static int bmc150_accel_runtime_resume (struct device *dev)
Signature · 1 line
1.9.3
Jonathan Cameron
maintainerRe: [PATCH 2/3] iio: accel: bmc150: Send x, y and z motion separately
In reply to Srinivas PandruvadaQuoted 4 lines · Srinivas Pandruvada
This chip is capable to identify motion across x, y and z axes. So send different events.
Signed-off-by Srinivas Pandruvada <[email protected]>
This is an odd mix of a true fix and change of functionality. It probably wants
to be broken up into clearer sections. We 'could' take this through
the fixes branch... I'm just not entirely sure if we want to.
I suppose it probably makes sense as it is an abi change and the driver is just working it's way towards a mainline release.
Can't take it just yet via that route due to backlogged pull request.
J
Quoted 19 lines
--- drivers/iio/accel/bmc150-accel.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)drivers/iio/accel/bmc150-accel.c +3
-0@@ -44,6 +44,9 @@#define BMC150_ACCEL_REG_INT_STATUS_2 0x0B#define BMC150_ACCEL_ANY_MOTION_MASK 0x07 +#define BMC150_ACCEL_ANY_MOTION_BIT_X BIT(0) +#define BMC150_ACCEL_ANY_MOTION_BIT_Y BIT(1) +#define BMC150_ACCEL_ANY_MOTION_BIT_Z BIT(2)#define BMC150_ACCEL_ANY_MOTION_BIT_SIGN BIT(3)#define BMC150_ACCEL_REG_PMU_LPW 0x11
drivers/iio/accel/bmc150-accel.c static const struct attribute_group bmc150_accel_attrs_group = { · line 856
Quoted 5 lines
drivers/iio/accel/bmc150-accel.c +1
-1@@ -850,7 +853,7 @@ static const struct attribute_group bmc150_accel_attrs_group = {static const struct iio_event_spec bmc150_accel_event = { .type =IIO_EV_TYPE_ROC , - .dir =IIO_EV_DIR_RISING |IIO_EV_DIR_FALLING , + .dir =IIO_EV_DIR_EITHER ,
T
Quoted 34 lines
drivers/iio/accel/bmc150-accel.c +17
-3.mask_separate = BIT(IIO_EV_INFO_VALUE) |BIT (IIO_EV_INFO_ENABLE ) |BIT (IIO_EV_INFO_PERIOD )@@ -1097,12 +1100,26 @@ static irqreturn_t bmc150_accel_event_handler(int irq, void *private)else dir =IIO_EV_DIR_RISING ; -if (ret &BMC150_ACCEL_ANY_MOTION_MASK ) +if (ret &BMC150_ACCEL_ANY_MOTION_BIT_X )iio_push_event (indio_dev,IIO_MOD_EVENT_CODE (IIO_ACCEL ,0 , -IIO_MOD_X_OR_Y_OR_Z , +IIO_MOD_X ,IIO_EV_TYPE_ROC , -IIO_EV_DIR_EITHER ), + dir), + data->timestamp); +if (ret &BMC150_ACCEL_ANY_MOTION_BIT_Y ) +iio_push_event (indio_dev,IIO_MOD_EVENT_CODE (IIO_ACCEL , +0 , +IIO_MOD_Y , +IIO_EV_TYPE_ROC , + dir), + data->timestamp); +if (ret &BMC150_ACCEL_ANY_MOTION_BIT_Z ) +iio_push_event (indio_dev,IIO_MOD_EVENT_CODE (IIO_ACCEL , +0 , +IIO_MOD_Z , +IIO_EV_TYPE_ROC , + dir), data->timestamp); ack_intr_status:if (!data->dready_trigger_on)
Re: [PATCH 2/3] iio: accel: bmc150: Send x, y and z motion separately
Quoted 5 lines · Jonathan Cameron
Quoted 4 lines · Srinivas Pandruvada
This chip is capable to identify motion across x, y and z axes. So send different events.
Signed-off-by Srinivas Pandruvada <[email protected]>
Quoted 9 lines
This is an odd mix of a true fix and change of functionality. It probably wants
to be broken up into clearer sections. We 'could' take this through
the fixes branch... I'm just not entirely sure if we want to.I suppose it probably makes sense as it is an abi change and the driver is just working it's way towards a mainline release.
Can't take it just yet via that route due to backlogged pull request.
I realized that and I have already sent updated version on 10/10/14, broken this into two parts: One fix and one enhancement.
Thanks,
Srinivas
Quoted 61 lines
J
Quoted 19 lines
--- drivers/iio/accel/bmc150-accel.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)drivers/iio/accel/bmc150-accel.c +3
-0@@ -44,6 +44,9 @@#define BMC150_ACCEL_REG_INT_STATUS_2 0x0B#define BMC150_ACCEL_ANY_MOTION_MASK 0x07 +#define BMC150_ACCEL_ANY_MOTION_BIT_X BIT(0) +#define BMC150_ACCEL_ANY_MOTION_BIT_Y BIT(1) +#define BMC150_ACCEL_ANY_MOTION_BIT_Z BIT(2)#define BMC150_ACCEL_ANY_MOTION_BIT_SIGN BIT(3)#define BMC150_ACCEL_REG_PMU_LPW 0x11drivers/iio/accel/bmc150-accel.c static const struct attribute_group bmc150_accel_attrs_group = { · line 856
Quoted 5 lines
drivers/iio/accel/bmc150-accel.c +1
-1@@ -850,7 +853,7 @@ static const struct attribute_group bmc150_accel_attrs_group = {static const struct iio_event_spec bmc150_accel_event = { .type =IIO_EV_TYPE_ROC , - .dir =IIO_EV_DIR_RISING |IIO_EV_DIR_FALLING , + .dir =IIO_EV_DIR_EITHER ,T
Quoted 34 lines
drivers/iio/accel/bmc150-accel.c +17
-3.mask_separate = BIT(IIO_EV_INFO_VALUE) |BIT (IIO_EV_INFO_ENABLE ) |BIT (IIO_EV_INFO_PERIOD )@@ -1097,12 +1100,26 @@ static irqreturn_t bmc150_accel_event_handler(int irq, void *private)else dir =IIO_EV_DIR_RISING ; -if (ret &BMC150_ACCEL_ANY_MOTION_MASK ) +if (ret &BMC150_ACCEL_ANY_MOTION_BIT_X )iio_push_event (indio_dev,IIO_MOD_EVENT_CODE (IIO_ACCEL ,0 , -IIO_MOD_X_OR_Y_OR_Z , +IIO_MOD_X ,IIO_EV_TYPE_ROC , -IIO_EV_DIR_EITHER ), + dir), + data->timestamp); +if (ret &BMC150_ACCEL_ANY_MOTION_BIT_Y ) +iio_push_event (indio_dev,IIO_MOD_EVENT_CODE (IIO_ACCEL , +0 , +IIO_MOD_Y , +IIO_EV_TYPE_ROC , + dir), + data->timestamp); +if (ret &BMC150_ACCEL_ANY_MOTION_BIT_Z ) +iio_push_event (indio_dev,IIO_MOD_EVENT_CODE (IIO_ACCEL , +0 , +IIO_MOD_Z , +IIO_EV_TYPE_ROC , + dir), data->timestamp); ack_intr_status:if (!data->dready_trigger_on)