* [PATCH v1 0/4] BMC 150 driver updates
@ 2014-10-11 3:35 Srinivas Pandruvada
2014-10-11 3:35 ` [PATCH v1 1/4] iio: accel: bmc150: Error handling when mode set fails Srinivas Pandruvada
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Srinivas Pandruvada @ 2014-10-11 3:35 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, Srinivas Pandruvada
v1
Rebase to the latest tree
Spilt the patch for event spec dir change
v0
initial submission
Srinivas Pandruvada (4):
iio: accel: bmc150: Error handling when mode set fails
iio: accel: bmc150: Send x, y and z motion separately
iio: accel: bmc150: set low default thresholds
iio: accel: bmc150: Fix iio_event_spec direction
drivers/iio/accel/bmc150-accel.c | 40 +++++++++++++++++++++++++++++++++-------
1 file changed, 33 insertions(+), 7 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v1 1/4] iio: accel: bmc150: Error handling when mode set fails
2014-10-11 3:35 [PATCH v1 0/4] BMC 150 driver updates Srinivas Pandruvada
@ 2014-10-11 3:35 ` Srinivas Pandruvada
2014-11-16 20:23 ` Jonathan Cameron
2014-10-11 3:35 ` [PATCH v1 2/4] iio: accel: bmc150: Send x, y and z motion separately Srinivas Pandruvada
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Srinivas Pandruvada @ 2014-10-11 3:35 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, Srinivas Pandruvada
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.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/accel/bmc150-accel.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c
index 22c096c..fdb101c 100644
--- a/drivers/iio/accel/bmc150-accel.c
+++ b/drivers/iio/accel/bmc150-accel.c
@@ -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)
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v1 2/4] iio: accel: bmc150: Send x, y and z motion separately
2014-10-11 3:35 [PATCH v1 0/4] BMC 150 driver updates Srinivas Pandruvada
2014-10-11 3:35 ` [PATCH v1 1/4] iio: accel: bmc150: Error handling when mode set fails Srinivas Pandruvada
@ 2014-10-11 3:35 ` Srinivas Pandruvada
2014-11-16 20:23 ` Jonathan Cameron
2014-10-11 3:35 ` [PATCH v1 3/4] iio: accel: bmc150: set low default thresholds Srinivas Pandruvada
2014-10-11 3:35 ` [PATCH v1 4/4] iio: accel: bmc150: Fix iio_event_spec direction Srinivas Pandruvada
3 siblings, 1 reply; 9+ messages in thread
From: Srinivas Pandruvada @ 2014-10-11 3:35 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, Srinivas Pandruvada
This chip is capable to identify motion across x, y and z axes. So
send different events.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/accel/bmc150-accel.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c
index fdb101c..c6df8ee 100644
--- a/drivers/iio/accel/bmc150-accel.c
+++ b/drivers/iio/accel/bmc150-accel.c
@@ -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
@@ -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)
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v1 3/4] iio: accel: bmc150: set low default thresholds
2014-10-11 3:35 [PATCH v1 0/4] BMC 150 driver updates Srinivas Pandruvada
2014-10-11 3:35 ` [PATCH v1 1/4] iio: accel: bmc150: Error handling when mode set fails Srinivas Pandruvada
2014-10-11 3:35 ` [PATCH v1 2/4] iio: accel: bmc150: Send x, y and z motion separately Srinivas Pandruvada
@ 2014-10-11 3:35 ` Srinivas Pandruvada
2014-11-16 20:24 ` Jonathan Cameron
2014-10-11 3:35 ` [PATCH v1 4/4] iio: accel: bmc150: Fix iio_event_spec direction Srinivas Pandruvada
3 siblings, 1 reply; 9+ messages in thread
From: Srinivas Pandruvada @ 2014-10-11 3:35 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, Srinivas Pandruvada
Set the threshold to low by default. With this thresholds any movement
on the device with this sensor will generate event.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/accel/bmc150-accel.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c
index c6df8ee..969cb21 100644
--- a/drivers/iio/accel/bmc150-accel.c
+++ b/drivers/iio/accel/bmc150-accel.c
@@ -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
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v1 4/4] iio: accel: bmc150: Fix iio_event_spec direction
2014-10-11 3:35 [PATCH v1 0/4] BMC 150 driver updates Srinivas Pandruvada
` (2 preceding siblings ...)
2014-10-11 3:35 ` [PATCH v1 3/4] iio: accel: bmc150: set low default thresholds Srinivas Pandruvada
@ 2014-10-11 3:35 ` Srinivas Pandruvada
2014-11-16 20:25 ` Jonathan Cameron
3 siblings, 1 reply; 9+ messages in thread
From: Srinivas Pandruvada @ 2014-10-11 3:35 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, Srinivas Pandruvada
Change event spec direction from
IIO_EV_DIR_RISING | IIO_EV_DIR_FALLING
to
IIO_EV_DIR_EITHER
Suggested-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/accel/bmc150-accel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c
index 969cb21..513bd6d 100644
--- a/drivers/iio/accel/bmc150-accel.c
+++ b/drivers/iio/accel/bmc150-accel.c
@@ -853,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)
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v1 1/4] iio: accel: bmc150: Error handling when mode set fails
2014-10-11 3:35 ` [PATCH v1 1/4] iio: accel: bmc150: Error handling when mode set fails Srinivas Pandruvada
@ 2014-11-16 20:23 ` Jonathan Cameron
0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2014-11-16 20:23 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: linux-iio
On 11/10/14 04:35, Srinivas Pandruvada wrote:
> 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.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Applied to the fixes-togreg branch of iio.git
Thanks,
Jonathan
> ---
> drivers/iio/accel/bmc150-accel.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c
> index 22c096c..fdb101c 100644
> --- a/drivers/iio/accel/bmc150-accel.c
> +++ b/drivers/iio/accel/bmc150-accel.c
> @@ -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)
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 2/4] iio: accel: bmc150: Send x, y and z motion separately
2014-10-11 3:35 ` [PATCH v1 2/4] iio: accel: bmc150: Send x, y and z motion separately Srinivas Pandruvada
@ 2014-11-16 20:23 ` Jonathan Cameron
0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2014-11-16 20:23 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: linux-iio
On 11/10/14 04:35, Srinivas Pandruvada wrote:
> This chip is capable to identify motion across x, y and z axes. So
> send different events.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Considered as an ABI 'fix' so applied to the fixes-togreg branch of iio.git
Thanks,
Jonathan
> ---
> drivers/iio/accel/bmc150-accel.c | 23 ++++++++++++++++++++---
> 1 file changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c
> index fdb101c..c6df8ee 100644
> --- a/drivers/iio/accel/bmc150-accel.c
> +++ b/drivers/iio/accel/bmc150-accel.c
> @@ -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
> @@ -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)
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 3/4] iio: accel: bmc150: set low default thresholds
2014-10-11 3:35 ` [PATCH v1 3/4] iio: accel: bmc150: set low default thresholds Srinivas Pandruvada
@ 2014-11-16 20:24 ` Jonathan Cameron
0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2014-11-16 20:24 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: linux-iio
On 11/10/14 04:35, Srinivas Pandruvada wrote:
> Set the threshold to low by default. With this thresholds any movement
> on the device with this sensor will generate event.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
This is a slightly odd one. It's not technically a 'fix' but rather a
change of default behaviour. I'll take the view the previous version
was not intuitive so this is preferred and apply it to the fixes-togreg
branch of iio.git.
Jonathan
> ---
> drivers/iio/accel/bmc150-accel.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c
> index c6df8ee..969cb21 100644
> --- a/drivers/iio/accel/bmc150-accel.c
> +++ b/drivers/iio/accel/bmc150-accel.c
> @@ -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
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v1 4/4] iio: accel: bmc150: Fix iio_event_spec direction
2014-10-11 3:35 ` [PATCH v1 4/4] iio: accel: bmc150: Fix iio_event_spec direction Srinivas Pandruvada
@ 2014-11-16 20:25 ` Jonathan Cameron
0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2014-11-16 20:25 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: linux-iio
On 11/10/14 04:35, Srinivas Pandruvada wrote:
> Change event spec direction from
> IIO_EV_DIR_RISING | IIO_EV_DIR_FALLING
> to
> IIO_EV_DIR_EITHER
>
> Suggested-by: Daniel Baluta <daniel.baluta@intel.com>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Applied to the fixes-togreg branch of iio.git
Thanks,
> ---
> drivers/iio/accel/bmc150-accel.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c
> index 969cb21..513bd6d 100644
> --- a/drivers/iio/accel/bmc150-accel.c
> +++ b/drivers/iio/accel/bmc150-accel.c
> @@ -853,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)
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-11-16 20:25 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-11 3:35 [PATCH v1 0/4] BMC 150 driver updates Srinivas Pandruvada
2014-10-11 3:35 ` [PATCH v1 1/4] iio: accel: bmc150: Error handling when mode set fails Srinivas Pandruvada
2014-11-16 20:23 ` Jonathan Cameron
2014-10-11 3:35 ` [PATCH v1 2/4] iio: accel: bmc150: Send x, y and z motion separately Srinivas Pandruvada
2014-11-16 20:23 ` Jonathan Cameron
2014-10-11 3:35 ` [PATCH v1 3/4] iio: accel: bmc150: set low default thresholds Srinivas Pandruvada
2014-11-16 20:24 ` Jonathan Cameron
2014-10-11 3:35 ` [PATCH v1 4/4] iio: accel: bmc150: Fix iio_event_spec direction Srinivas Pandruvada
2014-11-16 20:25 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).