iio: hid-sensors: Add api to get poll value
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Fri, 18 Apr 2014 23:22:00 +0000 (00:22 +0100)
committerJonathan Cameron <jic23@kernel.org>
Mon, 5 May 2014 09:59:45 +0000 (10:59 +0100)
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>
drivers/iio/common/hid-sensors/hid-sensor-attributes.c
include/linux/hid-sensor-hub.h

index e61b1faa1e064f58e6b5c877196949f15750b806..372964635ccff2af7ed9e6fd0c998c59f812a310 100644 (file)
@@ -147,6 +147,26 @@ static u32 convert_to_vtf_format(int size, int exp, int val1, int val2)
        return value;
 }
 
+s32 hid_sensor_read_poll_value(struct hid_sensor_common *st)
+{
+       s32 value = 0;
+       int ret;
+
+       ret = sensor_hub_get_feature(st->hsdev,
+               st->poll.report_id,
+               st->poll.index, &value);
+
+       if (ret < 0 || value < 0) {
+               return -EINVAL;
+       } else {
+               if (st->poll.units == HID_USAGE_SENSOR_UNITS_SECOND)
+                       value = value * 1000;
+       }
+
+       return value;
+}
+EXPORT_SYMBOL(hid_sensor_read_poll_value);
+
 int hid_sensor_read_samp_freq_value(struct hid_sensor_common *st,
                                int *val1, int *val2)
 {
index 89626b23c246bfc489f0645b5007614c427d5389..88d8d636a68f6e4e0bac29fd3d1e5087349183cb 100644 (file)
@@ -227,4 +227,6 @@ int hid_sensor_format_scale(u32 usage_id,
                            struct hid_sensor_hub_attribute_info *attr_info,
                            int *val0, int *val1);
 
+s32 hid_sensor_read_poll_value(struct hid_sensor_common *st);
+
 #endif