iio: hid-sensor-humidity: Fix alignment issue of timestamp channel

This patch ensures that, there is sufficient space and correct
alignment for the timestamp.

Fixes: d7ed89d5aa ("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>
This commit is contained in:
Ye Xiang 2021-03-03 14:36:12 +08:00 committed by Jonathan Cameron
parent b14d72ac73
commit 37e89e574d
1 changed files with 7 additions and 5 deletions

View File

@ -15,7 +15,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;
@ -125,9 +128,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;
}
@ -142,7 +144,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: