hitmoon / rpms / kernel

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