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:53 -0400 |
commit | cd5b700f998d9e1d8e6dbc62aeb0351bb2216e22 (patch) | |
tree | bc9e26999e72d727a886713ae18d2f1f84497c1a /drivers/iio/pressure | |
parent | 6fe588e59935f3cb3a1e1cd3d49fa756f28cb2b3 (diff) |
iio: hid-sensors: Pressure: 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>
Diffstat (limited to 'drivers/iio/pressure')
-rw-r--r-- | drivers/iio/pressure/hid-sensor-press.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c index 39df50c45dab..1cd190c73788 100644 --- a/drivers/iio/pressure/hid-sensor-press.c +++ b/drivers/iio/pressure/hid-sensor-press.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
22 | #include <linux/irq.h> | 22 | #include <linux/irq.h> |
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/delay.h> | ||
24 | #include <linux/hid-sensor-hub.h> | 25 | #include <linux/hid-sensor-hub.h> |
25 | #include <linux/iio/iio.h> | 26 | #include <linux/iio/iio.h> |
26 | #include <linux/iio/sysfs.h> | 27 | #include <linux/iio/sysfs.h> |
@@ -79,6 +80,7 @@ static int press_read_raw(struct iio_dev *indio_dev, | |||
79 | u32 address; | 80 | u32 address; |
80 | int ret; | 81 | int ret; |
81 | int ret_type; | 82 | int ret_type; |
83 | s32 poll_value; | ||
82 | 84 | ||
83 | *val = 0; | 85 | *val = 0; |
84 | *val2 = 0; | 86 | *val2 = 0; |
@@ -94,12 +96,23 @@ static int press_read_raw(struct iio_dev *indio_dev, | |||
94 | report_id = -1; | 96 | report_id = -1; |
95 | break; | 97 | break; |
96 | } | 98 | } |
97 | if (report_id >= 0) | 99 | if (report_id >= 0) { |
100 | poll_value = hid_sensor_read_poll_value( | ||
101 | &press_state->common_attributes); | ||
102 | if (poll_value < 0) | ||
103 | return -EINVAL; | ||
104 | hid_sensor_power_state(&press_state->common_attributes, | ||
105 | true); | ||
106 | |||
107 | msleep_interruptible(poll_value * 2); | ||
108 | |||
98 | *val = sensor_hub_input_attr_get_raw_value( | 109 | *val = sensor_hub_input_attr_get_raw_value( |
99 | press_state->common_attributes.hsdev, | 110 | press_state->common_attributes.hsdev, |
100 | HID_USAGE_SENSOR_PRESSURE, address, | 111 | HID_USAGE_SENSOR_PRESSURE, address, |
101 | report_id); | 112 | report_id); |
102 | else { | 113 | hid_sensor_power_state(&press_state->common_attributes, |
114 | false); | ||
115 | } else { | ||
103 | *val = 0; | 116 | *val = 0; |
104 | return -EINVAL; | 117 | return -EINVAL; |
105 | } | 118 | } |