Skip to content
Commit 84e2f6f9 authored by Linus Walleij's avatar Linus Walleij Committed by Jonathan Cameron
Browse files

iio: accel: kxsd9: Fix up offset and scaling



This fixes several errors in the offset and scaling of the raw
values from the KXSD9 sensor:

- The code did not convert the big endian value from the sensor
  into the endianness of the host CPU. Fix this with
  be16_to_cpu() on the raw obtained value.

- The code did not regard the fact that only the upper 12 bits of
  the accelerometer values are valid. Shift these
  down four bits to yield the real raw value.

- Further the sensor provides 2048 at zero g. This means that an
  offset of 2048 must be subtracted from the raw value before
  scaling. This was not taken into account by the driver,
  yielding a weird value. Fix this by providing this offset in
  sysfs.

To house the scaling code better, the value reading code was
factored into the raw reading function.

This proper scaling and offseting is necessary to get proper
values out of triggered buffer by offsetting, shifting and scaling
them.

Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Tested-by: default avatarJonathan Cameron <jic23@kernel.org>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent dc6ac050
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment