aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2017-04-07 20:13:17 -0400
committerJonathan Cameron <jic23@kernel.org>2017-04-08 10:13:36 -0400
commit5d9854eaea776441b38a9a45b4e6879524c4f48c (patch)
tree305609e2526bcb3432b5b0abc98efe074c822d48 /drivers/iio/common/hid-sensors/hid-sensor-trigger.c
parenta6d361404d81a03107a3475876afc22e1b84d5de (diff)
iio: hid-sensor: Store restore poll and hysteresis on S3
This change undo the change done by 'commit 3bec24747446 ("iio: hid-sensor-trigger: Change get poll value function order to avoid sensor properties losing after resume from S3")' as this breaks some USB/i2c sensor hubs. Instead of relying on HW for restoring poll and hysteresis, driver stores and restores on resume (S3). In this way user space modified settings are not lost for any kind of sensor hub behavior. In this change, whenever user space modifies sampling frequency or hysteresis driver will get the feature value from the hub and store in the per device hid_sensor_common data structure. On resume callback from S3, system will set the feature to sensor hub, if user space ever modified the feature value. Fixes: 3bec24747446 ("iio: hid-sensor-trigger: Change get poll value function order to avoid sensor properties losing after resume from S3") Reported-by: Ritesh Raj Sarraf <rrs@researchut.com> Tested-by: Ritesh Raj Sarraf <rrs@researchut.com> Tested-by: Song, Hongyan <hongyan.song@intel.com> Cc: stable@vger.kernel.org Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/common/hid-sensors/hid-sensor-trigger.c')
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-trigger.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index ecf592d69043..60829340a82e 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -51,6 +51,8 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
51 st->report_state.report_id, 51 st->report_state.report_id,
52 st->report_state.index, 52 st->report_state.index,
53 HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM); 53 HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM);
54
55 poll_value = hid_sensor_read_poll_value(st);
54 } else { 56 } else {
55 int val; 57 int val;
56 58
@@ -87,9 +89,7 @@ static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state)
87 sensor_hub_get_feature(st->hsdev, st->power_state.report_id, 89 sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
88 st->power_state.index, 90 st->power_state.index,
89 sizeof(state_val), &state_val); 91 sizeof(state_val), &state_val);
90 if (state) 92 if (state && poll_value)
91 poll_value = hid_sensor_read_poll_value(st);
92 if (poll_value > 0)
93 msleep_interruptible(poll_value * 2); 93 msleep_interruptible(poll_value * 2);
94 94
95 return 0; 95 return 0;
@@ -127,6 +127,20 @@ static void hid_sensor_set_power_work(struct work_struct *work)
127 struct hid_sensor_common *attrb = container_of(work, 127 struct hid_sensor_common *attrb = container_of(work,
128 struct hid_sensor_common, 128 struct hid_sensor_common,
129 work); 129 work);
130
131 if (attrb->poll_interval >= 0)
132 sensor_hub_set_feature(attrb->hsdev, attrb->poll.report_id,
133 attrb->poll.index,
134 sizeof(attrb->poll_interval),
135 &attrb->poll_interval);
136
137 if (attrb->raw_hystersis >= 0)
138 sensor_hub_set_feature(attrb->hsdev,
139 attrb->sensitivity.report_id,
140 attrb->sensitivity.index,
141 sizeof(attrb->raw_hystersis),
142 &attrb->raw_hystersis);
143
130 _hid_sensor_power_state(attrb, true); 144 _hid_sensor_power_state(attrb, true);
131} 145}
132 146