aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;