[kernel/f16] improve handling of null rate in LIS3LV02Dx accelerometer driver. (rhbz 785814)

Dave Jones davej at fedoraproject.org
Fri Feb 17 21:00:12 UTC 2012


commit b995bdd158bb5e2461261f7116a6a0d1e0788517
Author: Dave Jones <davej at redhat.com>
Date:   Fri Feb 17 16:00:02 2012 -0500

    improve handling of null rate in LIS3LV02Dx accelerometer driver. (rhbz 785814)

 kernel.spec                              |    7 +++
 lis3-improve-handling-of-null-rate.patch |   79 ++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+), 0 deletions(-)
---
diff --git a/kernel.spec b/kernel.spec
index 503c4f1..556a7f1 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -754,6 +754,8 @@ Patch13003: efi-dont-map-boot-services-on-32bit.patch
 
 Patch14000: hibernate-freeze-filesystems.patch
 
+Patch14010: lis3-improve-handling-of-null-rate.patch
+
 Patch20000: utrace.patch
 
 # Flattened devicetree support
@@ -1480,6 +1482,8 @@ ApplyPatch efi-dont-map-boot-services-on-32bit.patch
 
 ApplyPatch hibernate-freeze-filesystems.patch
 
+ApplyPatch lis3-improve-handling-of-null-rate.patch
+
 # utrace.
 ApplyPatch utrace.patch
 
@@ -2337,6 +2341,9 @@ fi
 
 %changelog
 * Fri Feb 17 2012 Dave Jones <davej at redhat.com>
+- improve handling of null rate in LIS3LV02Dx accelerometer driver. (rhbz 785814)
+
+* Fri Feb 17 2012 Dave Jones <davej at redhat.com>
 - Reenable radio drivers. (rhbz 784824)
 
 * Thu Feb 16 2012 Dave Jones <davej at redhat.com> 3.2.6-4
diff --git a/lis3-improve-handling-of-null-rate.patch b/lis3-improve-handling-of-null-rate.patch
new file mode 100644
index 0000000..9851256
--- /dev/null
+++ b/lis3-improve-handling-of-null-rate.patch
@@ -0,0 +1,79 @@
+>From 56fb161a9ca0129f8e266e4dbe79346552ff8089 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?=C3=89ric=20Piel?= <eric.piel at tremplin-utc.net>
+Date: Thu, 3 Nov 2011 16:22:40 +0100
+Subject: [PATCH] lis3: Improve handling of null rate
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+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.
+
+Signed-off-by: ??ric Piel <eric.piel at tremplin-utc.net>
+---
+ drivers/misc/lis3lv02d/lis3lv02d.c |   16 ++++++++--------
+ 1 files changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
+index 35c67e0..42dce2a 100644
+--- a/drivers/misc/lis3lv02d/lis3lv02d.c
++++ b/drivers/misc/lis3lv02d/lis3lv02d.c
+@@ -188,7 +188,8 @@ static void lis3lv02d_get_xyz(struct lis3lv02d *lis3, int *x, int *y, int *z)
+ /* 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};
+ 
+ /* ODR is Output Data Rate */
+ static int lis3lv02d_get_odr(struct lis3lv02d *lis3)
+@@ -202,12 +203,11 @@ static int lis3lv02d_get_odr(struct lis3lv02d *lis3)
+ 	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);
+@@ -274,7 +274,7 @@ static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3])
+ 
+ 	lis3->read(lis3, ctlreg, &reg);
+ 	lis3->write(lis3, ctlreg, (reg | selftest));
+-	ret = lis3lv02d_get_pwron_wait(lis3);
++	ret = lis3lv02d_wait_pwron(lis3);
+ 	if (ret)
+ 		goto fail;
+ 
+@@ -285,7 +285,7 @@ static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3])
+ 
+ 	/* back to normal settings */
+ 	lis3->write(lis3, ctlreg, reg);
+-	ret = lis3lv02d_get_pwron_wait(lis3);
++	ret = lis3lv02d_wait_pwron(lis3);
+ 	if (ret)
+ 		goto fail;
+ 
+@@ -397,7 +397,7 @@ int lis3lv02d_poweron(struct lis3lv02d *lis3)
+ 		lis3->write(lis3, CTRL_REG2, reg);
+ 	}
+ 
+-	err = lis3lv02d_get_pwron_wait(lis3);
++	err = lis3lv02d_wait_pwron(lis3);
+ 	if (err)
+ 		return err;
+ 
+-- 
+1.7.7.1
+


More information about the scm-commits mailing list