Skip to content

Commit 7cdcb8d

Browse files
Roger Quadrosdtor
authored andcommitted
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>
1 parent 0dfc8d4 commit 7cdcb8d

1 file changed

Lines changed: 43 additions & 4 deletions

File tree

‎drivers/input/touchscreen/pixcir_i2c_ts.c‎

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,21 +264,59 @@ static void pixcir_input_close(struct input_dev *dev)
264264
static int pixcir_i2c_ts_suspend(struct device *dev)
265265
{
266266
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+
}
267281

268-
if (device_may_wakeup(&client->dev))
269282
enable_irq_wake(client->irq);
283+
} else if (input->users) {
284+
ret = pixcir_stop(ts);
285+
}
270286

271-
return 0;
287+
unlock:
288+
mutex_unlock(&input->mutex);
289+
290+
return ret;
272291
}
273292

274293
static int pixcir_i2c_ts_resume(struct device *dev)
275294
{
276295
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);
277301

278-
if (device_may_wakeup(&client->dev))
302+
if (device_may_wakeup(&client->dev)) {
279303
disable_irq_wake(client->irq);
280304

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+
316+
unlock:
317+
mutex_unlock(&input->mutex);
318+
319+
return ret;
282320
}
283321
#endif
284322

@@ -366,6 +404,7 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
366404
if (error)
367405
return error;
368406

407+
i2c_set_clientdata(client, tsdata);
369408
device_init_wakeup(&client->dev, 1);
370409

371410
return 0;

0 commit comments

Comments
 (0)