|
@@ -264,21 +264,59 @@ static void pixcir_input_close(struct input_dev *dev)
|
|
static int pixcir_i2c_ts_suspend(struct device *dev)
|
|
static int pixcir_i2c_ts_suspend(struct device *dev)
|
|
{
|
|
{
|
|
struct i2c_client *client = to_i2c_client(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 (device_may_wakeup(&client->dev)) {
|
|
|
|
+ if (!input->users) {
|
|
|
|
+ ret = pixcir_start(ts);
|
|
|
|
+ if (ret) {
|
|
|
|
+ dev_err(dev, "Failed to start\n");
|
|
|
|
+ goto unlock;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- if (device_may_wakeup(&client->dev))
|
|
|
|
enable_irq_wake(client->irq);
|
|
enable_irq_wake(client->irq);
|
|
|
|
+ } else if (input->users) {
|
|
|
|
+ ret = pixcir_stop(ts);
|
|
|
|
+ }
|
|
|
|
|
|
- return 0;
|
|
|
|
|
|
+unlock:
|
|
|
|
+ mutex_unlock(&input->mutex);
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
static int pixcir_i2c_ts_resume(struct device *dev)
|
|
static int pixcir_i2c_ts_resume(struct device *dev)
|
|
{
|
|
{
|
|
struct i2c_client *client = to_i2c_client(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 (device_may_wakeup(&client->dev))
|
|
|
|
|
|
+ if (device_may_wakeup(&client->dev)) {
|
|
disable_irq_wake(client->irq);
|
|
disable_irq_wake(client->irq);
|
|
|
|
|
|
- return 0;
|
|
|
|
|
|
+ if (!input->users) {
|
|
|
|
+ ret = pixcir_stop(ts);
|
|
|
|
+ if (ret) {
|
|
|
|
+ dev_err(dev, "Failed to stop\n");
|
|
|
|
+ goto unlock;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (input->users) {
|
|
|
|
+ ret = pixcir_start(ts);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+unlock:
|
|
|
|
+ mutex_unlock(&input->mutex);
|
|
|
|
+
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
|
|
@@ -366,6 +404,7 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
|
|
if (error)
|
|
if (error)
|
|
return error;
|
|
return error;
|
|
|
|
|
|
|
|
+ i2c_set_clientdata(client, tsdata);
|
|
device_init_wakeup(&client->dev, 1);
|
|
device_init_wakeup(&client->dev, 1);
|
|
|
|
|
|
return 0;
|
|
return 0;
|