@@ -352,21 +352,66 @@ static void pixcir_input_close(struct input_dev *dev)
static int pixcir_i2c_ts_suspend(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
+ struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client);
+ struct input_dev *input = ts->input;
+ int ret = 0;
+
+ mutex_lock(&input->mutex);
+
+ if (input->users) {
+ ret = pixcir_stop(ts);
+ if (ret)
+ goto unlock;
+ }
+
+ /*
+ * If wakeup is enabled we need to enable interrupt generation
+ * but don't need to process any reports i.e. ts->exiting must be true.
+ */
+ if (device_may_wakeup(&client->dev)) {
+ /* enable wakeup interrupt generation */
+ ret = pixcir_int_enable(ts, 1);
+ if (ret) {
+ dev_err(dev, "Failed to enable interrupt generation\n");
+ goto unlock;
+ }
- if (device_may_wakeup(&client->dev))
enable_irq_wake(client->irq);
+ }
- return 0;
+unlock:
+ mutex_unlock(&input->mutex);
+
+ return ret;
}
static int pixcir_i2c_ts_resume(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
+ struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client);
+ struct input_dev *input = ts->input;
+ int ret = 0;
- if (device_may_wakeup(&client->dev))
+ mutex_lock(&input->mutex);
+
+ if (device_may_wakeup(&client->dev)) {
disable_irq_wake(client->irq);
- return 0;
+ /* disable wakeup interrupt generation */
+ ret = pixcir_int_enable(ts, 0);
+ if (ret) {
+ dev_err(dev, "Failed to disable interrupt generation\n");
+ goto unlock;
+ }
+ }
+
+ if (input->users)
+ ret = pixcir_start(ts);
+
+unlock:
+ mutex_unlock(&input->mutex);
+
+ return ret;
}
#endif