aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/common/hid-sensors/hid-sensor-attributes.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-attributes.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-attributes.c')
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-attributes.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
index 01e02b9926d4..ca742ac8f128 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c
@@ -221,7 +221,15 @@ int hid_sensor_write_samp_freq_value(struct hid_sensor_common *st,
221 if (ret < 0 || value < 0) 221 if (ret < 0 || value < 0)
222 ret = -EINVAL; 222 ret = -EINVAL;
223 223
224 return ret; 224 ret = sensor_hub_get_feature(st->hsdev,
225 st->poll.report_id,
226 st->poll.index, sizeof(value), &value);
227 if (ret < 0 || value < 0)
228 return -EINVAL;
229
230 st->poll_interval = value;
231
232 return 0;
225} 233}
226EXPORT_SYMBOL(hid_sensor_write_samp_freq_value); 234EXPORT_SYMBOL(hid_sensor_write_samp_freq_value);
227 235
@@ -266,7 +274,16 @@ int hid_sensor_write_raw_hyst_value(struct hid_sensor_common *st,
266 if (ret < 0 || value < 0) 274 if (ret < 0 || value < 0)
267 ret = -EINVAL; 275 ret = -EINVAL;
268 276
269 return ret; 277 ret = sensor_hub_get_feature(st->hsdev,
278 st->sensitivity.report_id,
279 st->sensitivity.index, sizeof(value),
280 &value);
281 if (ret < 0 || value < 0)
282 return -EINVAL;
283
284 st->raw_hystersis = value;
285
286 return 0;
270} 287}
271EXPORT_SYMBOL(hid_sensor_write_raw_hyst_value); 288EXPORT_SYMBOL(hid_sensor_write_raw_hyst_value);
272 289
@@ -369,6 +386,9 @@ int hid_sensor_get_reporting_interval(struct hid_sensor_hub_device *hsdev,
369 /* Default unit of measure is milliseconds */ 386 /* Default unit of measure is milliseconds */
370 if (st->poll.units == 0) 387 if (st->poll.units == 0)
371 st->poll.units = HID_USAGE_SENSOR_UNITS_MILLISECOND; 388 st->poll.units = HID_USAGE_SENSOR_UNITS_MILLISECOND;
389
390 st->poll_interval = -1;
391
372 return 0; 392 return 0;
373 393
374} 394}
@@ -399,6 +419,8 @@ int hid_sensor_parse_common_attributes(struct hid_sensor_hub_device *hsdev,
399 HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS, 419 HID_USAGE_SENSOR_PROP_SENSITIVITY_ABS,
400 &st->sensitivity); 420 &st->sensitivity);
401 421
422 st->raw_hystersis = -1;
423
402 sensor_hub_input_get_attribute_info(hsdev, 424 sensor_hub_input_get_attribute_info(hsdev,
403 HID_INPUT_REPORT, usage_id, 425 HID_INPUT_REPORT, usage_id,
404 HID_USAGE_SENSOR_TIME_TIMESTAMP, 426 HID_USAGE_SENSOR_TIME_TIMESTAMP,