]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
iio/hid-sensors: Fix IIO_CHAN_INFO_RAW returning wrong values for signed numbers
authorHans de Goede <hdegoede@redhat.com>
Wed, 31 Oct 2018 14:20:05 +0000 (15:20 +0100)
committerSultan Alsawaf <sultan.alsawaf@canonical.com>
Wed, 24 Jul 2019 15:45:00 +0000 (09:45 -0600)
commit2af33e6f36113bf27131a719875d44a105d1a761
treea3027398bddf1b9c3c4af18fb25f7073a75a2835
parentc1ad5f22c5b747ae425f600e177f4f9d201fbcfa
iio/hid-sensors: Fix IIO_CHAN_INFO_RAW returning wrong values for signed numbers

BugLink: https://bugs.launchpad.net/bugs/1836968
commit 0145b50566e7de5637e80ecba96c7f0e6fff1aad upstream.

Before this commit sensor_hub_input_attr_get_raw_value() failed to take
the signedness of 16 and 8 bit values into account, returning e.g.
65436 instead of -100 for the z-axis reading of an accelerometer.

This commit adds a new is_signed parameter to the function and makes all
callers pass the appropriate value for this.

While at it, this commit also fixes up some neighboring lines where
statements were needlessly split over 2 lines to improve readability.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
13 files changed:
drivers/hid/hid-sensor-custom.c
drivers/hid/hid-sensor-hub.c
drivers/iio/accel/hid-sensor-accel-3d.c
drivers/iio/gyro/hid-sensor-gyro-3d.c
drivers/iio/humidity/hid-sensor-humidity.c
drivers/iio/light/hid-sensor-als.c
drivers/iio/light/hid-sensor-prox.c
drivers/iio/magnetometer/hid-sensor-magn-3d.c
drivers/iio/orientation/hid-sensor-incl-3d.c
drivers/iio/pressure/hid-sensor-press.c
drivers/iio/temperature/hid-sensor-temperature.c
drivers/rtc/rtc-hid-sensor-time.c
include/linux/hid-sensor-hub.h