imperfectism / rpms / kernel

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