aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYe Xiang <xiang.ye@intel.com>2021-03-03 14:36:12 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-03-24 11:26:42 +0100
commit3fa27c8749cfcae8dd6f87c1b674e9011fcea3bb (patch)
treed412a2fefe2b15738707844d0c92c40bbaf21912
parent4458ae8d4001d9345a83e55389acb7a4ab7bf615 (diff)
downloadlinux-yocto-3fa27c8749cfcae8dd6f87c1b674e9011fcea3bb.tar.gz
linux-yocto-3fa27c8749cfcae8dd6f87c1b674e9011fcea3bb.tar.bz2
linux-yocto-3fa27c8749cfcae8dd6f87c1b674e9011fcea3bb.zip
iio: hid-sensor-humidity: Fix alignment issue of timestamp channel
commit 37e89e574dc238a4ebe439543c5ab4fbb2f0311b upstream. This patch ensures that, there is sufficient space and correct alignment for the timestamp. Fixes: d7ed89d5aadf ("iio: hid: Add humidity sensor support") Signed-off-by: Ye Xiang <xiang.ye@intel.com> Cc: <Stable@vger.kernel.org> Link: https://lore.kernel.org/r/20210303063615.12130-2-xiang.ye@intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/iio/humidity/hid-sensor-humidity.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/iio/humidity/hid-sensor-humidity.c b/drivers/iio/humidity/hid-sensor-humidity.c
index c99b54b0568d..969e16f5eeb6 100644
--- a/drivers/iio/humidity/hid-sensor-humidity.c
+++ b/drivers/iio/humidity/hid-sensor-humidity.c
@@ -17,7 +17,10 @@
struct hid_humidity_state {
struct hid_sensor_common common_attributes;
struct hid_sensor_hub_attribute_info humidity_attr;
- s32 humidity_data;
+ struct {
+ s32 humidity_data;
+ u64 timestamp __aligned(8);
+ } scan;
int scale_pre_decml;
int scale_post_decml;
int scale_precision;
@@ -127,9 +130,8 @@ static int humidity_proc_event(struct hid_sensor_hub_device *hsdev,
struct hid_humidity_state *humid_st = iio_priv(indio_dev);
if (atomic_read(&humid_st->common_attributes.data_ready))
- iio_push_to_buffers_with_timestamp(indio_dev,
- &humid_st->humidity_data,
- iio_get_time_ns(indio_dev));
+ iio_push_to_buffers_with_timestamp(indio_dev, &humid_st->scan,
+ iio_get_time_ns(indio_dev));
return 0;
}
@@ -144,7 +146,7 @@ static int humidity_capture_sample(struct hid_sensor_hub_device *hsdev,
switch (usage_id) {
case HID_USAGE_SENSOR_ATMOSPHERIC_HUMIDITY:
- humid_st->humidity_data = *(s32 *)raw_data;
+ humid_st->scan.humidity_data = *(s32 *)raw_data;
return 0;
default: