aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Quadros <rogerq@ti.com>2014-05-19 01:49:20 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2014-05-19 02:25:57 -0400
commit7cdcb8d104e6f0ec5d253d29e4849cdb2cf03aed (patch)
treef01aa0053843adc022f7569c1d44d42ff65b629b
parent0dfc8d41bfa091a61354eea73199a5af0eaae9c0 (diff)
Input: pixcir_i2c_ts - implement wakeup from suspend
Improve the suspend and resume handlers to allow the device to wakeup the system from suspend. Signed-off-by: Roger Quadros <rogerq@ti.com> Acked-by: Mugunthan V N <mugunthanvnm@ti.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/touchscreen/pixcir_i2c_ts.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index f2c0ae18e24a..19c6c0fdc94b 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -264,21 +264,59 @@ static void pixcir_input_close(struct input_dev *dev)
264static int pixcir_i2c_ts_suspend(struct device *dev) 264static int pixcir_i2c_ts_suspend(struct device *dev)
265{ 265{
266 struct i2c_client *client = to_i2c_client(dev); 266 struct i2c_client *client = to_i2c_client(dev);
267 struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client);
268 struct input_dev *input = ts->input;
269 int ret = 0;
270
271 mutex_lock(&input->mutex);
272
273 if (device_may_wakeup(&client->dev)) {
274 if (!input->users) {
275 ret = pixcir_start(ts);
276 if (ret) {
277 dev_err(dev, "Failed to start\n");
278 goto unlock;
279 }
280 }
267 281
268 if (device_may_wakeup(&client->dev))
269 enable_irq_wake(client->irq); 282 enable_irq_wake(client->irq);
283 } else if (input->users) {
284 ret = pixcir_stop(ts);
285 }
270 286
271 return 0; 287unlock:
288 mutex_unlock(&input->mutex);
289
290 return ret;
272} 291}
273 292
274static int pixcir_i2c_ts_resume(struct device *dev) 293static int pixcir_i2c_ts_resume(struct device *dev)
275{ 294{
276 struct i2c_client *client = to_i2c_client(dev); 295 struct i2c_client *client = to_i2c_client(dev);
296 struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client);
297 struct input_dev *input = ts->input;
298 int ret = 0;
299
300 mutex_lock(&input->mutex);
277 301
278 if (device_may_wakeup(&client->dev)) 302 if (device_may_wakeup(&client->dev)) {
279 disable_irq_wake(client->irq); 303 disable_irq_wake(client->irq);
280 304
281 return 0; 305 if (!input->users) {
306 ret = pixcir_stop(ts);
307 if (ret) {
308 dev_err(dev, "Failed to stop\n");
309 goto unlock;
310 }
311 }
312 } else if (input->users) {
313 ret = pixcir_start(ts);
314 }
315
316unlock:
317 mutex_unlock(&input->mutex);
318
319 return ret;
282} 320}
283#endif 321#endif
284 322
@@ -366,6 +404,7 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
366 if (error) 404 if (error)
367 return error; 405 return error;
368 406
407 i2c_set_clientdata(client, tsdata);
369 device_init_wakeup(&client->dev, 1); 408 device_init_wakeup(&client->dev, 1);
370 409
371 return 0; 410 return 0;