lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Mon,  4 Jan 2016 14:57:50 +0800
From:	"james.chen" <james.chen@....com.tw>
To:	Dmitry Torokhov <dmitry.torokhov@...il.com>,
	Herman Lin <herman.lin@....com.tw>,
	linux-kernel@...r.kernel.org, linux-input@...r.kernel.org,
	charliemooney@...omium.org,
	Jennifer Tsai <jennifer.tsai@....com.tw>,
	Scott Liu <scott.liu@....com.tw>
Cc:	"james.chen" <james.chen@....com.tw>
Subject: [PATCH 2/2] Input: elants_i2c: fixed wake-on-touch issue

From: "james.chen" <james.chen@....com.tw>

Fix function of wake-on-touch on suspend/resume.
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).
2016.1.4: modify retry back to retry_cnt.

Signed-off-by: james.chen <james.chen@....com.tw>
---
 drivers/input/touchscreen/elants_i2c.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index 17cc20e..3739646 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -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) {
+	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_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
 			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;
 }
 
@@ -1345,13 +1346,14 @@ static int __maybe_unused elants_i2c_resume(struct device *dev)
 	int retry_cnt;
 	int error;
 
-	if (device_may_wakeup(dev) && ts->wake_irq_enabled)
-		disable_irq_wake(client->irq);
-
-	if (ts->keep_power_in_suspend) {
+	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_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
 			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

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ