diff mbox

[v4,6/7] Input: pixcir_i2c_ts: Implement wakeup from suspend

Message ID 1399280678-23925-7-git-send-email-rogerq@ti.com
State New
Headers show

Commit Message

Roger Quadros May 5, 2014, 9:04 a.m. UTC
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>
---
 drivers/input/touchscreen/pixcir_i2c_ts.c | 53 ++++++++++++++++++++++++++++---
 1 file changed, 49 insertions(+), 4 deletions(-)

Comments

Dmitry Torokhov May 6, 2014, 5:21 a.m. UTC | #1
On Mon, May 05, 2014 at 12:04:37PM +0300, Roger Quadros wrote:
> 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>
> ---
>  drivers/input/touchscreen/pixcir_i2c_ts.c | 53 ++++++++++++++++++++++++++++---
>  1 file changed, 49 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
> index 927aed1..5f6a27e 100644
> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> @@ -348,21 +348,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;
> +		}

I am not sure why we need to disable event processing here. Why not do

	if (device_may_wakeup(&client->dev)) {
		enable_irq_wake(client->irq); 
		ret = pixcir_int_enable(ts, true);
		...
	} else if (input->users) {
		ret = pixcir_stop(ts);
	}

like many of the drivers do?

Thanks.
Roger Quadros May 6, 2014, 8:33 a.m. UTC | #2
On 05/06/2014 08:21 AM, Dmitry Torokhov wrote:
> On Mon, May 05, 2014 at 12:04:37PM +0300, Roger Quadros wrote:
>> 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>
>> ---
>>  drivers/input/touchscreen/pixcir_i2c_ts.c | 53 ++++++++++++++++++++++++++++---
>>  1 file changed, 49 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
>> index 927aed1..5f6a27e 100644
>> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
>> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
>> @@ -348,21 +348,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;
>> +		}
> 
> I am not sure why we need to disable event processing here. Why not do
> 
> 	if (device_may_wakeup(&client->dev)) {
> 		enable_irq_wake(client->irq); 
> 		ret = pixcir_int_enable(ts, true);
> 		...
> 	} else if (input->users) {
> 		ret = pixcir_stop(ts);
> 	}
> 
> like many of the drivers do?

Seems to work without disabling event processing. I'll send a v5 with this
and patch 2 fixed as per your suggestion. Thanks.

cheers,
-roger
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
diff mbox

Patch

diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 927aed1..5f6a27e 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -348,21 +348,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