diff options
author | Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> | 2014-01-23 21:50:22 -0500 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2014-02-17 09:09:47 -0500 |
commit | 1a214ae5d1a66ead18c5e8c3a8d03b969b0ee647 (patch) | |
tree | 7839c6acba3c7f1e2f86c2a88e2d167f1d234c56 /drivers/iio | |
parent | e02cee4819ae51f26333471c8eed50678b08572a (diff) |
iio: hid-sensor-hub: Remove hard coded indexes
Remove the hard coded indexes, instead search for usage id and
use the index to set the power and report state.
This will fix issue, where the report descriptor doesn't contain
the full list of possible selector for power and report state.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c index 7dcf83998e6f..dbefbdaf7cd1 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c | |||
@@ -38,29 +38,40 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, | |||
38 | if (state) { | 38 | if (state) { |
39 | if (sensor_hub_device_open(st->hsdev)) | 39 | if (sensor_hub_device_open(st->hsdev)) |
40 | return -EIO; | 40 | return -EIO; |
41 | state_val = | 41 | state_val = hid_sensor_get_usage_index(st->hsdev, |
42 | HID_USAGE_SENSOR_PROP_POWER_STATE_D0_FULL_POWER_ENUM; | 42 | st->power_state.report_id, |
43 | report_val = | 43 | st->power_state.index, |
44 | HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM; | 44 | HID_USAGE_SENSOR_PROP_POWER_STATE_D0_FULL_POWER_ENUM); |
45 | 45 | report_val = hid_sensor_get_usage_index(st->hsdev, | |
46 | st->report_state.report_id, | ||
47 | st->report_state.index, | ||
48 | HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM); | ||
46 | } else { | 49 | } else { |
47 | sensor_hub_device_close(st->hsdev); | 50 | sensor_hub_device_close(st->hsdev); |
48 | state_val = | 51 | state_val = hid_sensor_get_usage_index(st->hsdev, |
49 | HID_USAGE_SENSOR_PROP_POWER_STATE_D4_POWER_OFF_ENUM; | 52 | st->power_state.report_id, |
50 | report_val = | 53 | st->power_state.index, |
51 | HID_USAGE_SENSOR_PROP_REPORTING_STATE_NO_EVENTS_ENUM; | 54 | HID_USAGE_SENSOR_PROP_POWER_STATE_D4_POWER_OFF_ENUM); |
55 | report_val = hid_sensor_get_usage_index(st->hsdev, | ||
56 | st->report_state.report_id, | ||
57 | st->report_state.index, | ||
58 | HID_USAGE_SENSOR_PROP_REPORTING_STATE_NO_EVENTS_ENUM); | ||
52 | } | 59 | } |
53 | |||
54 | st->data_ready = state; | 60 | st->data_ready = state; |
55 | state_val += st->power_state.logical_minimum; | 61 | |
56 | report_val += st->report_state.logical_minimum; | 62 | if (state_val >= 0) { |
57 | sensor_hub_set_feature(st->hsdev, st->power_state.report_id, | 63 | state_val += st->power_state.logical_minimum; |
64 | sensor_hub_set_feature(st->hsdev, st->power_state.report_id, | ||
58 | st->power_state.index, | 65 | st->power_state.index, |
59 | (s32)state_val); | 66 | (s32)state_val); |
67 | } | ||
60 | 68 | ||
61 | sensor_hub_set_feature(st->hsdev, st->report_state.report_id, | 69 | if (report_val >= 0) { |
70 | report_val += st->report_state.logical_minimum; | ||
71 | sensor_hub_set_feature(st->hsdev, st->report_state.report_id, | ||
62 | st->report_state.index, | 72 | st->report_state.index, |
63 | (s32)report_val); | 73 | (s32)report_val); |
74 | } | ||
64 | 75 | ||
65 | return 0; | 76 | return 0; |
66 | } | 77 | } |