[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220929093200.v6.3.I5862429ee3e4de0f9ad5ba01ce07ad99eec10cf0@changeid>
Date: Thu, 29 Sep 2022 10:19:07 -0600
From: Raul E Rangel <rrangel@...omium.org>
To: linux-acpi@...r.kernel.org, linux-input@...r.kernel.org
Cc: andriy.shevchenko@...ux.intel.com, dmitry.torokhov@...il.com,
hdegoede@...hat.com, rafael@...nel.org,
mika.westerberg@...ux.intel.com, mario.limonciello@....com,
timvp@...gle.com, linus.walleij@...aro.org, jingle.wu@....com.tw,
Raul E Rangel <rrangel@...omium.org>,
Douglas Anderson <dianders@...omium.org>,
Guenter Roeck <groeck@...omium.org>,
Johnny Chuang <johnny.chuang.emc@...il.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH v6 03/13] Input: elants_i2c - Use PM subsystem to manage wake irq
The Elan I2C touchscreen driver is currently manually managing the wake
IRQ. This change removes the explicit enable_irq_wake/disable_irq_wake
and instead relies on the PM subsystem. This is done by calling
dev_pm_set_wake_irq.
i2c_device_probe already calls dev_pm_set_wake_irq when using device
tree, and i2c_device_remove also already calls dev_pm_clear_wake_irq.
There could be some device tree systems that have incorrectly declared
`wake` capabilities, so this change will set the wake irq if one is
missing. This matches the previous behavior.
Signed-off-by: Raul E Rangel <rrangel@...omium.org>
---
(no changes since v2)
Changes in v2:
- Added elants_i2c to series
drivers/input/touchscreen/elants_i2c.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index a56f042adf9d829..80e16b533c452a0 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -36,6 +36,7 @@
#include <linux/input/touchscreen.h>
#include <linux/acpi.h>
#include <linux/of.h>
+#include <linux/pm_wakeirq.h>
#include <linux/gpio/consumer.h>
#include <linux/regulator/consumer.h>
#include <linux/uuid.h>
@@ -180,7 +181,6 @@ struct elants_data {
u8 cmd_resp[HEADER_SIZE];
struct completion cmd_done;
- bool wake_irq_enabled;
bool keep_power_in_suspend;
/* Must be last to be used for DMA operations */
@@ -1582,6 +1582,15 @@ static int elants_i2c_probe(struct i2c_client *client)
if (!client->dev.of_node)
device_init_wakeup(&client->dev, true);
+ /*
+ * The wake IRQ should be declared via device tree instead of assuming
+ * the IRQ can wake the system. This is here for legacy reasons and
+ * will be removed once the i2c-core supports querying ACPI for wake
+ * capabilities.
+ */
+ if (!client->dev.power.wakeirq)
+ dev_pm_set_wake_irq(&client->dev, client->irq);
+
error = devm_device_add_group(&client->dev, &elants_attribute_group);
if (error) {
dev_err(&client->dev, "failed to create sysfs attributes: %d\n",
@@ -1626,7 +1635,7 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev)
* The device will automatically enter idle mode
* that has reduced power consumption.
*/
- ts->wake_irq_enabled = (enable_irq_wake(client->irq) == 0);
+ return 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,
@@ -1655,8 +1664,6 @@ static int __maybe_unused elants_i2c_resume(struct device *dev)
int error;
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++) {
--
2.37.3.998.g577e59143f-goog
Powered by blists - more mailing lists