OSDN Git Service

iio: gyro: bmg160: fix endianness when reading axes
authorIrina Tirdea <irina.tirdea@intel.com>
Tue, 29 Mar 2016 12:37:30 +0000 (15:37 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Apr 2016 06:42:12 +0000 (15:42 +0900)
commit51789682df3111fa675c1bc0a8498e142fb97bdf
tree74dbdc99ac19fd602286f19778a862c691c148db
parent5a103e7d6bf05ff4d053ee73a001d255bbc8951a
iio: gyro: bmg160: fix endianness when reading axes

commit 95e7ff034175db7d8aefabe7716c4d42bea24fde upstream.

For big endian platforms, reading the axes will return
invalid values.

The device stores each axis value in a 16 bit little
endian register. The driver uses regmap_read_bulk to get
the axis value, resulting in a 16 bit little endian value.
This needs to be converted to cpu endianness to work
on big endian platforms.

Fix endianness for big endian platforms by converting
the values for the axes read from little endian to
cpu.

This is also partially fixed in commit 82d8e5da1a33 ("iio:
accel: bmg160: optimize transfers in trigger handler").

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/gyro/bmg160_core.c