diff options
author | Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> | 2016-08-15 15:12:47 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2016-08-21 15:12:32 -0400 |
commit | 7f6cf7414538181f4091b06e905d19a23a451108 (patch) | |
tree | 53f546cc1a513f77d17db76ef8b7799bf739d6b5 /drivers/iio/common | |
parent | ace4cdfe67be24463ad694105533e5319674f022 (diff) |
iio: hid-sensors: use asynchronous resume
Some platforms power off sensor hubs during S3 suspend, which will require
longer time to resume. This hurts system resume time, so resume
asynchronously.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/common')
-rw-r--r-- | drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c index 5b41f9d0d4f3..5264ed6e03e5 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c | |||
@@ -122,6 +122,14 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state) | |||
122 | #endif | 122 | #endif |
123 | } | 123 | } |
124 | 124 | ||
125 | static void hid_sensor_set_power_work(struct work_struct *work) | ||
126 | { | ||
127 | struct hid_sensor_common *attrb = container_of(work, | ||
128 | struct hid_sensor_common, | ||
129 | work); | ||
130 | _hid_sensor_power_state(attrb, true); | ||
131 | } | ||
132 | |||
125 | static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, | 133 | static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, |
126 | bool state) | 134 | bool state) |
127 | { | 135 | { |
@@ -130,6 +138,7 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig, | |||
130 | 138 | ||
131 | void hid_sensor_remove_trigger(struct hid_sensor_common *attrb) | 139 | void hid_sensor_remove_trigger(struct hid_sensor_common *attrb) |
132 | { | 140 | { |
141 | cancel_work_sync(&attrb->work); | ||
133 | iio_trigger_unregister(attrb->trigger); | 142 | iio_trigger_unregister(attrb->trigger); |
134 | iio_trigger_free(attrb->trigger); | 143 | iio_trigger_free(attrb->trigger); |
135 | } | 144 | } |
@@ -170,6 +179,9 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, | |||
170 | goto error_unreg_trigger; | 179 | goto error_unreg_trigger; |
171 | 180 | ||
172 | iio_device_set_drvdata(indio_dev, attrb); | 181 | iio_device_set_drvdata(indio_dev, attrb); |
182 | |||
183 | INIT_WORK(&attrb->work, hid_sensor_set_power_work); | ||
184 | |||
173 | pm_suspend_ignore_children(&attrb->pdev->dev, true); | 185 | pm_suspend_ignore_children(&attrb->pdev->dev, true); |
174 | pm_runtime_enable(&attrb->pdev->dev); | 186 | pm_runtime_enable(&attrb->pdev->dev); |
175 | /* Default to 3 seconds, but can be changed from sysfs */ | 187 | /* Default to 3 seconds, but can be changed from sysfs */ |
@@ -202,7 +214,15 @@ static int hid_sensor_resume(struct device *dev) | |||
202 | struct platform_device *pdev = to_platform_device(dev); | 214 | struct platform_device *pdev = to_platform_device(dev); |
203 | struct iio_dev *indio_dev = platform_get_drvdata(pdev); | 215 | struct iio_dev *indio_dev = platform_get_drvdata(pdev); |
204 | struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev); | 216 | struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev); |
217 | schedule_work(&attrb->work); | ||
218 | return 0; | ||
219 | } | ||
205 | 220 | ||
221 | static int hid_sensor_runtime_resume(struct device *dev) | ||
222 | { | ||
223 | struct platform_device *pdev = to_platform_device(dev); | ||
224 | struct iio_dev *indio_dev = platform_get_drvdata(pdev); | ||
225 | struct hid_sensor_common *attrb = iio_device_get_drvdata(indio_dev); | ||
206 | return _hid_sensor_power_state(attrb, true); | 226 | return _hid_sensor_power_state(attrb, true); |
207 | } | 227 | } |
208 | 228 | ||
@@ -211,7 +231,7 @@ static int hid_sensor_resume(struct device *dev) | |||
211 | const struct dev_pm_ops hid_sensor_pm_ops = { | 231 | const struct dev_pm_ops hid_sensor_pm_ops = { |
212 | SET_SYSTEM_SLEEP_PM_OPS(hid_sensor_suspend, hid_sensor_resume) | 232 | SET_SYSTEM_SLEEP_PM_OPS(hid_sensor_suspend, hid_sensor_resume) |
213 | SET_RUNTIME_PM_OPS(hid_sensor_suspend, | 233 | SET_RUNTIME_PM_OPS(hid_sensor_suspend, |
214 | hid_sensor_resume, NULL) | 234 | hid_sensor_runtime_resume, NULL) |
215 | }; | 235 | }; |
216 | EXPORT_SYMBOL(hid_sensor_pm_ops); | 236 | EXPORT_SYMBOL(hid_sensor_pm_ops); |
217 | 237 | ||