mirror of
https://github.com/Dasharo/linux.git
synced 2026-03-06 15:25:10 -08:00
iio: cros_ec: Reapply range at resume
EC does not currently preserve range across sensor reinit. If sensor is powered down at suspend, it will default to the EC default range at resume, not the range set by the host. Save range if modified, and apply at resume. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
committed by
Jonathan Cameron
parent
79846e33aa
commit
e7e3b9d23f
@@ -200,6 +200,10 @@ static int cros_ec_sensors_write(struct iio_dev *indio_dev,
|
||||
st->core.param.sensor_range.roundup = 1;
|
||||
|
||||
ret = cros_ec_motion_send_host_cmd(&st->core, 0);
|
||||
if (ret == 0) {
|
||||
st->core.range_updated = true;
|
||||
st->core.curr_range = val;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ret = cros_ec_sensors_core_write(
|
||||
@@ -315,6 +319,7 @@ MODULE_DEVICE_TABLE(platform, cros_ec_sensors_ids);
|
||||
static struct platform_driver cros_ec_sensors_platform_driver = {
|
||||
.driver = {
|
||||
.name = "cros-ec-sensors",
|
||||
.pm = &cros_ec_sensors_pm_ops,
|
||||
},
|
||||
.probe = cros_ec_sensors_probe,
|
||||
.id_table = cros_ec_sensors_ids,
|
||||
|
||||
@@ -824,5 +824,26 @@ int cros_ec_sensors_core_write(struct cros_ec_sensors_core_state *st,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cros_ec_sensors_core_write);
|
||||
|
||||
static int __maybe_unused cros_ec_sensors_resume(struct device *dev)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
|
||||
struct cros_ec_sensors_core_state *st = iio_priv(indio_dev);
|
||||
int ret = 0;
|
||||
|
||||
if (st->range_updated) {
|
||||
mutex_lock(&st->cmd_lock);
|
||||
st->param.cmd = MOTIONSENSE_CMD_SENSOR_RANGE;
|
||||
st->param.sensor_range.data = st->curr_range;
|
||||
st->param.sensor_range.roundup = 1;
|
||||
ret = cros_ec_motion_send_host_cmd(st, 0);
|
||||
mutex_unlock(&st->cmd_lock);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
SIMPLE_DEV_PM_OPS(cros_ec_sensors_pm_ops, NULL, cros_ec_sensors_resume);
|
||||
EXPORT_SYMBOL_GPL(cros_ec_sensors_pm_ops);
|
||||
|
||||
MODULE_DESCRIPTION("ChromeOS EC sensor hub core functions");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
||||
Reference in New Issue
Block a user