Skip to contentSkip to conversation

Input: adp5589 - do not unconditionally configure as wakeup source

PATCH New Dmitry Torokhov 1 participant 2 messages Nov 20, 2020

Subsystems (2)
lore
Share & tools
lore

Dmitry Torokhov

author maintainer
#0 lore raw

PATCH 1/2 Input: adp5589 - do not unconditionally configure as wakeup source

We should not be configuring the controller as a wakeup source in the driver, but rather rely on I2C core to mark it as such by either instantiating as I2C_CLIENT_WAKEUP or specifying "wakeup-source" device property.

---
 drivers/input/keyboard/adp5589-keys.c | 2 --
 1 file changed, 2 deletions(-)
drivers/input/keyboard/adp5589-keys.c +0 -2
index e2cdf14d90cd..d76b0e4e67c4 100644
@@ -930,8 +930,6 @@ static int adp5589_keypad_add(struct adp5589_kpad *kpad, unsigned int revid)
 		return error;
 	}
 
-	device_init_wakeup(&client->dev, 1);
-
 	return 0;
 }
 
Signature · 1 line
2.29.2.454.gaff20da3a2-goog
author maintainer
#1 lore raw

PATCH 2/2 Input: adp5589-keys - do not explicitly control IRQ for wakeup

If device is set up as a wakeup source, I2C core configures the interrupt line as wake IRQ and PM core automatically configures it for waking up the system on system suspend transition, so we do not have to explicitly call enable_irq_wake() and disable_irq_wake() in suspend/resume.

---
 drivers/input/keyboard/adp5589-keys.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)
drivers/input/keyboard/adp5589-keys.c +9 -18
index d76b0e4e67c4..654e0476406b 100644
@@ -14,6 +14,7 @@
 #include <linux/workqueue.h>
 #include <linux/errno.h>
 #include <linux/pm.h>
+#include <linux/pm_wakeirq.h>
 #include <linux/platform_device.h>
 #include <linux/input.h>
 #include <linux/i2c.h>
@@ -1017,32 +1018,22 @@ static int adp5589_probe(struct i2c_client *client,
 
 static int __maybe_unused adp5589_suspend(struct device *dev)
 {
-	struct adp5589_kpad *kpad = dev_get_drvdata(dev);
-	struct i2c_client *client = kpad->client;
-
-	if (!kpad->input)
-		return 0;
-
-	disable_irq(client->irq);
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adp5589_kpad *kpad = i2c_get_clientdata(client);
 
-	if (device_may_wakeup(&client->dev))
-		enable_irq_wake(client->irq);
+	if (kpad->input)
+		disable_irq(client->irq);
 
 	return 0;
 }
 
 static int __maybe_unused adp5589_resume(struct device *dev)
 {
-	struct adp5589_kpad *kpad = dev_get_drvdata(dev);
-	struct i2c_client *client = kpad->client;
-
-	if (!kpad->input)
-		return 0;
-
-	if (device_may_wakeup(&client->dev))
-		disable_irq_wake(client->irq);
+	struct i2c_client *client = to_i2c_client(dev);
+	struct adp5589_kpad *kpad = i2c_get_clientdata(client);
 
-	enable_irq(client->irq);
+	if (kpad->input)
+		enable_irq(client->irq);
 
 	return 0;
 }
Signature · 1 line
2.29.2.454.gaff20da3a2-goog