summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaga RADHESH Y <naga.radheshy@stericsson.com>2012-02-14 07:46:57 +0100
committerPhilippe Langlais <philippe.langlais@linaro.org>2012-02-15 09:35:33 +0100
commit17231e3a1220ba94af776624bf2e5d0fc64c76e4 (patch)
tree9ce3eb61e7c834ecb2e48d38c5950b319060d1b6
parent4c11ec40c9738bceccd4529cb90a2a4e600a80f9 (diff)
lsm303dlh_m: Check for DLHC device to invert y,z
Invert y,z co-ordinates as specified in data sheet if device is LSM303DLHC ST-Ericsson ID: 374970 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id:I45e706e3f783dd58e02f23d9579f3422ef7fc984 Signed-off-by: Naga Radhesh <naga.radheshy@stericsson.com>
-rw-r--r--drivers/hwmon/lsm303dlh_m.c23
-rw-r--r--include/linux/lsm303dlh.h2
2 files changed, 15 insertions, 10 deletions
diff --git a/drivers/hwmon/lsm303dlh_m.c b/drivers/hwmon/lsm303dlh_m.c
index 75d22e82e86..af486d23ee1 100644
--- a/drivers/hwmon/lsm303dlh_m.c
+++ b/drivers/hwmon/lsm303dlh_m.c
@@ -133,6 +133,9 @@
#define DEVICE_ON 1
#define DEVICE_SUSPENDED 2
+/* device CHIP ID defines */
+#define LSM303DLHC_CHIP_ID 51
+
/**
* struct lsm303dlh_m_data - data structure used by lsm303dlh_m driver
* @client: i2c client
@@ -340,16 +343,16 @@ static int lsm303dlh_m_xyz_read(struct lsm303dlh_m_data *ddata)
ddata->data[2] = (short)
(((xyz_data[4]) << 8) | xyz_data[5]);
-#ifdef SENSORS_LSM303DLHC
- /*
- * the out registers are in x, z and y order
- * so swap y and z values
- */
- temp = ddata->data[1];
- ddata->data[1] = ddata->data[2];
- ddata->data[2] = temp;
-#endif
-
+ /* check if chip is DHLC */
+ if (ddata->pdata.chip_id == LSM303DLHC_CHIP_ID) {
+ /*
+ * the out registers are in x, z and y order
+ * so swap y and z values
+ */
+ temp = ddata->data[1];
+ ddata->data[1] = ddata->data[2];
+ ddata->data[2] = temp;
+ }
/* taking orientation of x,y,z axis into account*/
ddata->data[ddata->pdata.axis_map_x] = ddata->pdata.negative_x ?
diff --git a/include/linux/lsm303dlh.h b/include/linux/lsm303dlh.h
index ad369b1fbd5..a565faa79ba 100644
--- a/include/linux/lsm303dlh.h
+++ b/include/linux/lsm303dlh.h
@@ -42,6 +42,7 @@
* @negative_x: x axis is orientation, 0 or 1
* @negative_y: y axis is orientation, 0 or 1
* @negative_z: z axis is orientation, 0 or 1
+ * @chip_id: to store ID of the LSM chip
*/
struct lsm303dlh_platform_data {
const char *name_a;
@@ -55,6 +56,7 @@ struct lsm303dlh_platform_data {
u8 negative_x;
u8 negative_y;
u8 negative_z;
+ u32 chip_id;
};
#endif /* __KERNEL__ */