From e38b899c7d35e03ad9a66e40a7ca0092e34aa969 Mon Sep 17 00:00:00 2001 From: Naga Radhesh Date: Tue, 8 Nov 2011 17:21:03 +0530 Subject: 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 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/36886 Reviewed-by: QATOOLS Reviewed-by: QABUILD Reviewed-by: Srinidhi KASAGAR Reviewed-by: QATEST Reviewed-by: Jonas ABERG --- drivers/hwmon/lsm303dlh_m.c | 23 +++++++++++++---------- include/linux/lsm303dlh.h | 2 ++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/hwmon/lsm303dlh_m.c b/drivers/hwmon/lsm303dlh_m.c index 311e88fb58c..abc91ccb032 100644 --- a/drivers/hwmon/lsm303dlh_m.c +++ b/drivers/hwmon/lsm303dlh_m.c @@ -130,6 +130,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 @@ -334,16 +337,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__ */ -- cgit v1.2.3