2014-09-23 14:19:58 +00:00
|
|
|
From 704f062dbd28150ae22cafe590aaebe9f43d93f9 Mon Sep 17 00:00:00 2001
|
2012-02-17 21:03:23 +00:00
|
|
|
From: =?UTF-8?q?=C3=89ric=20Piel?= <eric.piel@tremplin-utc.net>
|
|
|
|
Date: Thu, 3 Nov 2011 16:22:40 +0100
|
2014-08-20 17:22:24 +00:00
|
|
|
Subject: [PATCH] lis3: improve handling of null rate
|
2012-02-17 21:03:23 +00:00
|
|
|
|
|
|
|
When obtaining a rate of 0, we would disable the device supposely
|
|
|
|
because it seems to behave incorectly. It actually only comes from the
|
|
|
|
fact that the device is off and on lis3dc it's reflected in the rate.
|
|
|
|
So handle this nicely by just waiting a safe time, and then using the
|
|
|
|
device as normally.
|
|
|
|
|
2014-08-20 17:22:24 +00:00
|
|
|
Bugzilla: 785814
|
|
|
|
Upstream-status: ??
|
|
|
|
|
2012-02-17 21:03:23 +00:00
|
|
|
Signed-off-by: ??ric Piel <eric.piel@tremplin-utc.net>
|
|
|
|
---
|
2014-08-20 17:22:24 +00:00
|
|
|
drivers/misc/lis3lv02d/lis3lv02d.c | 16 ++++++++--------
|
|
|
|
1 file changed, 8 insertions(+), 8 deletions(-)
|
2012-02-17 21:03:23 +00:00
|
|
|
|
|
|
|
diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
|
2014-08-20 17:22:24 +00:00
|
|
|
index 3ef4627f9cb1..2b2d2e8e5eeb 100644
|
2012-02-17 21:03:23 +00:00
|
|
|
--- a/drivers/misc/lis3lv02d/lis3lv02d.c
|
|
|
|
+++ b/drivers/misc/lis3lv02d/lis3lv02d.c
|
2014-08-20 17:22:24 +00:00
|
|
|
@@ -216,7 +216,8 @@ static void lis3lv02d_get_xyz(struct lis3lv02d *lis3, int *x, int *y, int *z)
|
2012-02-17 21:03:23 +00:00
|
|
|
/* conversion btw sampling rate and the register values */
|
|
|
|
static int lis3_12_rates[4] = {40, 160, 640, 2560};
|
|
|
|
static int lis3_8_rates[2] = {100, 400};
|
|
|
|
-static int lis3_3dc_rates[16] = {0, 1, 10, 25, 50, 100, 200, 400, 1600, 5000};
|
|
|
|
+/* LIS3DC: 0 = power off, above 9 = undefined */
|
|
|
|
+static int lis3_3dc_rates[16] = {0, 1, 10, 25, 50, 100, 200, 400, 1600, 5000, -1, -1, -1, -1, -1, -1};
|
2012-10-05 15:45:58 +00:00
|
|
|
static int lis3_3dlh_rates[4] = {50, 100, 400, 1000};
|
2012-02-17 21:03:23 +00:00
|
|
|
|
|
|
|
/* ODR is Output Data Rate */
|
2014-08-20 17:22:24 +00:00
|
|
|
@@ -231,12 +232,11 @@ static int lis3lv02d_get_odr(struct lis3lv02d *lis3)
|
2012-02-17 21:03:23 +00:00
|
|
|
return lis3->odrs[(ctrl >> shift)];
|
|
|
|
}
|
|
|
|
|
|
|
|
-static int lis3lv02d_get_pwron_wait(struct lis3lv02d *lis3)
|
|
|
|
+static int lis3lv02d_wait_pwron(struct lis3lv02d *lis3)
|
|
|
|
{
|
|
|
|
int div = lis3lv02d_get_odr(lis3);
|
|
|
|
-
|
|
|
|
- if (WARN_ONCE(div == 0, "device returned spurious data"))
|
|
|
|
- return -ENXIO;
|
|
|
|
+ if (div <= 0)
|
|
|
|
+ div = 1; /* maximum delay */
|
|
|
|
|
|
|
|
/* LIS3 power on delay is quite long */
|
|
|
|
msleep(lis3->pwron_delay / div);
|
2014-08-20 17:22:24 +00:00
|
|
|
@@ -303,7 +303,7 @@ static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3])
|
2012-02-17 21:03:23 +00:00
|
|
|
|
|
|
|
lis3->read(lis3, ctlreg, ®);
|
|
|
|
lis3->write(lis3, ctlreg, (reg | selftest));
|
|
|
|
- ret = lis3lv02d_get_pwron_wait(lis3);
|
|
|
|
+ ret = lis3lv02d_wait_pwron(lis3);
|
|
|
|
if (ret)
|
|
|
|
goto fail;
|
|
|
|
|
2014-08-20 17:22:24 +00:00
|
|
|
@@ -314,7 +314,7 @@ static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3])
|
2012-02-17 21:03:23 +00:00
|
|
|
|
|
|
|
/* back to normal settings */
|
|
|
|
lis3->write(lis3, ctlreg, reg);
|
|
|
|
- ret = lis3lv02d_get_pwron_wait(lis3);
|
|
|
|
+ ret = lis3lv02d_wait_pwron(lis3);
|
|
|
|
if (ret)
|
|
|
|
goto fail;
|
|
|
|
|
2014-08-20 17:22:24 +00:00
|
|
|
@@ -434,7 +434,7 @@ int lis3lv02d_poweron(struct lis3lv02d *lis3)
|
|
|
|
}
|
2012-02-17 21:03:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- err = lis3lv02d_get_pwron_wait(lis3);
|
|
|
|
+ err = lis3lv02d_wait_pwron(lis3);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
--
|
2014-08-20 17:22:24 +00:00
|
|
|
1.9.3
|
2012-02-17 21:03:23 +00:00
|
|
|
|