diff options
author | Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> | 2014-04-18 19:22:00 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2014-05-05 05:59:45 -0400 |
commit | 9030924510a9e7d4b7d218749533840075879f2f (patch) | |
tree | 52edcc0477c21fed5c1976199c9786e52828cf4d /drivers/iio/common | |
parent | 5d02edfc3957446fd625c0b018e14c6631a791f4 (diff) |
iio: hid-sensors: Add api to get poll value
Added interface to get poll value in milli-seconds. This value is
changed by changing sampling frequency. This API allows clients
to wait for at least some poll milli seconds before reading a new sample.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/common')
-rw-r--r-- | drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c index e61b1faa1e06..372964635ccf 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c | |||
@@ -147,6 +147,26 @@ static u32 convert_to_vtf_format(int size, int exp, int val1, int val2) | |||
147 | return value; | 147 | return value; |
148 | } | 148 | } |
149 | 149 | ||
150 | s32 hid_sensor_read_poll_value(struct hid_sensor_common *st) | ||
151 | { | ||
152 | s32 value = 0; | ||
153 | int ret; | ||
154 | |||
155 | ret = sensor_hub_get_feature(st->hsdev, | ||
156 | st->poll.report_id, | ||
157 | st->poll.index, &value); | ||
158 | |||
159 | if (ret < 0 || value < 0) { | ||
160 | return -EINVAL; | ||
161 | } else { | ||
162 | if (st->poll.units == HID_USAGE_SENSOR_UNITS_SECOND) | ||
163 | value = value * 1000; | ||
164 | } | ||
165 | |||
166 | return value; | ||
167 | } | ||
168 | EXPORT_SYMBOL(hid_sensor_read_poll_value); | ||
169 | |||
150 | int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st, | 170 | int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st, |
151 | int *val1, int *val2) | 171 | int *val1, int *val2) |
152 | { | 172 | { |