Skip to content

Commit 37e89e5

Browse files
yeapajic23
authored andcommitted
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: d7ed89d ("iio: hid: Add humidity sensor support") Signed-off-by: Ye Xiang <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
1 parent b14d72a commit 37e89e5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/iio/humidity/hid-sensor-humidity.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
struct hid_humidity_state {
1616
struct hid_sensor_common common_attributes;
1717
struct hid_sensor_hub_attribute_info humidity_attr;
18-
s32 humidity_data;
18+
struct {
19+
s32 humidity_data;
20+
u64 timestamp __aligned(8);
21+
} scan;
1922
int scale_pre_decml;
2023
int scale_post_decml;
2124
int scale_precision;
@@ -125,9 +128,8 @@ static int humidity_proc_event(struct hid_sensor_hub_device *hsdev,
125128
struct hid_humidity_state *humid_st = iio_priv(indio_dev);
126129

127130
if (atomic_read(&humid_st->common_attributes.data_ready))
128-
iio_push_to_buffers_with_timestamp(indio_dev,
129-
&humid_st->humidity_data,
130-
iio_get_time_ns(indio_dev));
131+
iio_push_to_buffers_with_timestamp(indio_dev, &humid_st->scan,
132+
iio_get_time_ns(indio_dev));
131133

132134
return 0;
133135
}
@@ -142,7 +144,7 @@ static int humidity_capture_sample(struct hid_sensor_hub_device *hsdev,
142144

143145
switch (usage_id) {
144146
case HID_USAGE_SENSOR_ATMOSPHERIC_HUMIDITY:
145-
humid_st->humidity_data = *(s32 *)raw_data;
147+
humid_st->scan.humidity_data = *(s32 *)raw_data;
146148

147149
return 0;
148150
default:

0 commit comments

Comments
 (0)