Skip to content

Commit 6fe588e

Browse files
spandruvadajic23
authored andcommitted
iio: hid-sensors: Inclinometer 3D: Raw read support
Added support for raw reading of channel. If the sensor is powered off, it will turn on for reading value. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent 8009c59 commit 6fe588e

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎drivers/iio/orientation/hid-sensor-incl-3d.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/interrupt.h>
2323
#include <linux/irq.h>
2424
#include <linux/slab.h>
25+
#include <linux/delay.h>
2526
#include <linux/hid-sensor-hub.h>
2627
#include <linux/iio/iio.h>
2728
#include <linux/iio/sysfs.h>
@@ -110,11 +111,20 @@ static int incl_3d_read_raw(struct iio_dev *indio_dev,
110111
int report_id = -1;
111112
u32 address;
112113
int ret_type;
114+
s32 poll_value;
113115

114116
*val = 0;
115117
*val2 = 0;
116118
switch (mask) {
117119
case IIO_CHAN_INFO_RAW:
120+
poll_value = hid_sensor_read_poll_value(
121+
&incl_state->common_attributes);
122+
if (poll_value < 0)
123+
return -EINVAL;
124+
125+
hid_sensor_power_state(&incl_state->common_attributes, true);
126+
msleep_interruptible(poll_value * 2);
127+
118128
report_id =
119129
incl_state->incl[chan->scan_index].report_id;
120130
address = incl_3d_addresses[chan->scan_index];
@@ -124,8 +134,11 @@ static int incl_3d_read_raw(struct iio_dev *indio_dev,
124134
HID_USAGE_SENSOR_INCLINOMETER_3D, address,
125135
report_id);
126136
else {
137+
hid_sensor_power_state(&incl_state->common_attributes,
138+
false);
127139
return -EINVAL;
128140
}
141+
hid_sensor_power_state(&incl_state->common_attributes, false);
129142
ret_type = IIO_VAL_INT;
130143
break;
131144
case IIO_CHAN_INFO_SCALE:

0 commit comments

Comments
 (0)