aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/iio/orientation/hid-sensor-incl-3d.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c
index bf11678dd04e..2478f6c2ef25 100644
--- a/drivers/iio/orientation/hid-sensor-incl-3d.c
+++ b/drivers/iio/orientation/hid-sensor-incl-3d.c
@@ -22,6 +22,7 @@
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/irq.h> 23#include <linux/irq.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/delay.h>
25#include <linux/hid-sensor-hub.h> 26#include <linux/hid-sensor-hub.h>
26#include <linux/iio/iio.h> 27#include <linux/iio/iio.h>
27#include <linux/iio/sysfs.h> 28#include <linux/iio/sysfs.h>
@@ -110,11 +111,20 @@ static int incl_3d_read_raw(struct iio_dev *indio_dev,
110 int report_id = -1; 111 int report_id = -1;
111 u32 address; 112 u32 address;
112 int ret_type; 113 int ret_type;
114 s32 poll_value;
113 115
114 *val = 0; 116 *val = 0;
115 *val2 = 0; 117 *val2 = 0;
116 switch (mask) { 118 switch (mask) {
117 case IIO_CHAN_INFO_RAW: 119 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
118 report_id = 128 report_id =
119 incl_state->incl[chan->scan_index].report_id; 129 incl_state->incl[chan->scan_index].report_id;
120 address = incl_3d_addresses[chan->scan_index]; 130 address = incl_3d_addresses[chan->scan_index];
@@ -124,8 +134,11 @@ static int incl_3d_read_raw(struct iio_dev *indio_dev,
124 HID_USAGE_SENSOR_INCLINOMETER_3D, address, 134 HID_USAGE_SENSOR_INCLINOMETER_3D, address,
125 report_id); 135 report_id);
126 else { 136 else {
137 hid_sensor_power_state(&incl_state->common_attributes,
138 false);
127 return -EINVAL; 139 return -EINVAL;
128 } 140 }
141 hid_sensor_power_state(&incl_state->common_attributes, false);
129 ret_type = IIO_VAL_INT; 142 ret_type = IIO_VAL_INT;
130 break; 143 break;
131 case IIO_CHAN_INFO_SCALE: 144 case IIO_CHAN_INFO_SCALE: