* [PATCH] CHROMIUM: Input: elants_i2c: fixed wake-on-touch issue
@ 2015-12-18 2:48 james.chen
2015-12-19 0:25 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: james.chen @ 2015-12-18 2:48 UTC (permalink / raw)
To: Jennifer Tsai, Herman Lin, Scott Liu, Charlie Mooney,
Dmitry Torokhov, linux-kernel, linux-input
Cc: Jeff Chuang, Agnes Cheng, james.chen
From: "james.chen" <james.chen@emc.com.tw>
Something wrong in suspend/resume of kernel v3.14 for the function of
wake-on-touch. The function of device_may_wakeup will return true if
the device supports wake-on-touch (for example, kitty and buddy).
So, modify the code from "if (device_may_wakeup(dev))" to
"if (!device_may_wakeup(dev))". And adjust the condition check of
keep_power_in_suspend (designed for minnie).
Signed-off-by: James Chen <james.chen@emc.com.tw>
---
drivers/input/touchscreen/elants_i2c.c | 37 +++++++++++++++++-----------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index 17cc20e..06ee814 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -1307,7 +1307,7 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct elants_data *ts = i2c_get_clientdata(client);
const u8 set_sleep_cmd[] = { 0x54, 0x50, 0x00, 0x01 };
- int retry_cnt;
+ int retry;
int error;
/* Command not support in IAP recovery mode */
@@ -1316,24 +1316,25 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev)
disable_irq(client->irq);
- if (device_may_wakeup(dev) || ts->keep_power_in_suspend) {
- for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
+ if (device_may_wakeup(dev)) {
+ /*
+ * The device will automatically enter idle mode
+ * that has reduced power consumption.
+ */
+ ts->wake_irq_enabled = (enable_irq_wake(client->irq) == 0);
+ } else if (ts->keep_power_in_suspend) {
+ for (retry = 0; retry < MAX_RETRIES; retry++) {
error = elants_i2c_send(client, set_sleep_cmd,
- sizeof(set_sleep_cmd));
+ sizeof(set_sleep_cmd));
if (!error)
break;
dev_err(&client->dev,
"suspend command failed: %d\n", error);
}
-
- if (device_may_wakeup(dev))
- ts->wake_irq_enabled =
- (enable_irq_wake(client->irq) == 0);
} else {
- elants_i2c_power_off(ts);
+ elants_i2c_power_off(ts);
}
-
return 0;
}
@@ -1342,16 +1343,17 @@ static int __maybe_unused elants_i2c_resume(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct elants_data *ts = i2c_get_clientdata(client);
const u8 set_active_cmd[] = { 0x54, 0x58, 0x00, 0x01 };
- int retry_cnt;
+ int retry;
int error;
- if (device_may_wakeup(dev) && ts->wake_irq_enabled)
- disable_irq_wake(client->irq);
-
- if (ts->keep_power_in_suspend) {
- for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
+ if (device_may_wakeup(dev)) {
+ if (ts->wake_irq_enabled)
+ disable_irq_wake(client->irq);
+ elants_i2c_sw_reset(client);
+ } else if (ts->keep_power_in_suspend) {
+ for (retry = 0; retry < MAX_RETRIES; retry++) {
error = elants_i2c_send(client, set_active_cmd,
- sizeof(set_active_cmd));
+ sizeof(set_active_cmd));
if (!error)
break;
@@ -1362,7 +1364,6 @@ static int __maybe_unused elants_i2c_resume(struct device *dev)
elants_i2c_power_on(ts);
elants_i2c_initialize(ts);
}
-
ts->state = ELAN_STATE_NORMAL;
enable_irq(client->irq);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] CHROMIUM: Input: elants_i2c: fixed wake-on-touch issue
2015-12-18 2:48 [PATCH] CHROMIUM: Input: elants_i2c: fixed wake-on-touch issue james.chen
@ 2015-12-19 0:25 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2015-12-19 0:25 UTC (permalink / raw)
To: james.chen
Cc: Jennifer Tsai, Herman Lin, Scott Liu, Charlie Mooney,
linux-kernel, linux-input, Jeff Chuang, Agnes Cheng
Hi James,
On Fri, Dec 18, 2015 at 10:48:48AM +0800, james.chen wrote:
> From: "james.chen" <james.chen@emc.com.tw>
>
> Something wrong in suspend/resume of kernel v3.14 for the function of
> wake-on-touch. The function of device_may_wakeup will return true if
> the device supports wake-on-touch (for example, kitty and buddy).
> So, modify the code from "if (device_may_wakeup(dev))" to
> "if (!device_may_wakeup(dev))". And adjust the condition check of
> keep_power_in_suspend (designed for minnie).
>
> Signed-off-by: James Chen <james.chen@emc.com.tw>
Adjusted commit message and dropped rename retry_cnt -> retry and
applied.
Thank you.
> ---
> drivers/input/touchscreen/elants_i2c.c | 37 +++++++++++++++++-----------------
> 1 file changed, 19 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
> index 17cc20e..06ee814 100644
> --- a/drivers/input/touchscreen/elants_i2c.c
> +++ b/drivers/input/touchscreen/elants_i2c.c
> @@ -1307,7 +1307,7 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev)
> struct i2c_client *client = to_i2c_client(dev);
> struct elants_data *ts = i2c_get_clientdata(client);
> const u8 set_sleep_cmd[] = { 0x54, 0x50, 0x00, 0x01 };
> - int retry_cnt;
> + int retry;
> int error;
>
> /* Command not support in IAP recovery mode */
> @@ -1316,24 +1316,25 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev)
>
> disable_irq(client->irq);
>
> - if (device_may_wakeup(dev) || ts->keep_power_in_suspend) {
> - for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
> + if (device_may_wakeup(dev)) {
> + /*
> + * The device will automatically enter idle mode
> + * that has reduced power consumption.
> + */
> + ts->wake_irq_enabled = (enable_irq_wake(client->irq) == 0);
> + } else if (ts->keep_power_in_suspend) {
> + for (retry = 0; retry < MAX_RETRIES; retry++) {
> error = elants_i2c_send(client, set_sleep_cmd,
> - sizeof(set_sleep_cmd));
> + sizeof(set_sleep_cmd));
> if (!error)
> break;
>
> dev_err(&client->dev,
> "suspend command failed: %d\n", error);
> }
> -
> - if (device_may_wakeup(dev))
> - ts->wake_irq_enabled =
> - (enable_irq_wake(client->irq) == 0);
> } else {
> - elants_i2c_power_off(ts);
> + elants_i2c_power_off(ts);
> }
> -
> return 0;
> }
>
> @@ -1342,16 +1343,17 @@ static int __maybe_unused elants_i2c_resume(struct device *dev)
> struct i2c_client *client = to_i2c_client(dev);
> struct elants_data *ts = i2c_get_clientdata(client);
> const u8 set_active_cmd[] = { 0x54, 0x58, 0x00, 0x01 };
> - int retry_cnt;
> + int retry;
> int error;
>
> - if (device_may_wakeup(dev) && ts->wake_irq_enabled)
> - disable_irq_wake(client->irq);
> -
> - if (ts->keep_power_in_suspend) {
> - for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
> + if (device_may_wakeup(dev)) {
> + if (ts->wake_irq_enabled)
> + disable_irq_wake(client->irq);
> + elants_i2c_sw_reset(client);
> + } else if (ts->keep_power_in_suspend) {
> + for (retry = 0; retry < MAX_RETRIES; retry++) {
> error = elants_i2c_send(client, set_active_cmd,
> - sizeof(set_active_cmd));
> + sizeof(set_active_cmd));
> if (!error)
> break;
>
> @@ -1362,7 +1364,6 @@ static int __maybe_unused elants_i2c_resume(struct device *dev)
> elants_i2c_power_on(ts);
> elants_i2c_initialize(ts);
> }
> -
> ts->state = ELAN_STATE_NORMAL;
> enable_irq(client->irq);
>
> --
> 1.8.3.2
>
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-19 0:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-18 2:48 [PATCH] CHROMIUM: Input: elants_i2c: fixed wake-on-touch issue james.chen
2015-12-19 0:25 ` Dmitry Torokhov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.