This way is more efficient and can reduce interrupts from i2c bus driver. Also changes the output formatting. Note this is a staging driver so the output formatting will probably change further once there is some kind of consensus on format.
Signed-off-by: Hong Liu <[email protected]> --- drivers/staging/mfld-sensors/ak8974.c | 18 ++++++------------ 1 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/mfld-sensors/ak8974.c b/drivers/staging/mfld-sensors/ak8974.c index d0ecff6..83f6933 100644 --- a/drivers/staging/mfld-sensors/ak8974.c +++ b/drivers/staging/mfld-sensors/ak8974.c @@ -81,8 +81,8 @@ static ssize_t curr_xyz_show(struct device *dev, { struct i2c_client *client = to_i2c_client(dev); struct compass_data *data = i2c_get_clientdata(client); - unsigned short x, y, z; - u8 temp; + int i; + s16 values[3]; pm_runtime_get_sync(dev); mutex_lock(&data->write_lock); @@ -94,20 +94,14 @@ static ssize_t curr_xyz_show(struct device *dev, msleep(15); /*Force Read*/ - x = i2c_smbus_read_byte_data(client, DATA_XM); - temp = i2c_smbus_read_byte_data(client, DATA_XL); - x = x << 8 | temp; - y = i2c_smbus_read_byte_data(client, DATA_YM); - temp = i2c_smbus_read_byte_data(client, DATA_YL); - y = y << 8 | temp; - z = i2c_smbus_read_byte_data(client, DATA_ZM); - temp = i2c_smbus_read_byte_data(client, DATA_ZL); - z = z << 8 | temp; + i2c_smbus_read_i2c_block_data(client, DATA_XL, 6, (u8 *)values); + for (i = 0; i < 3; i++) + values[i] = le16_to_cpu(values[i]); mutex_unlock(&data->write_lock); pm_runtime_put_sync(dev); - return sprintf(buf, "%x:%x:%x\n", x, y, z); + return sprintf(buf, "(%d,%d,%d)\n", values[0], values[1], values[2]); } /* change to active mode and do some default config */ -- 1.7.2.3 _______________________________________________ MeeGo-kernel mailing list [email protected] http://lists.meego.com/listinfo/meego-kernel
