Commit 2e758f53 authored by Raul E Rangel's avatar Raul E Rangel Committed by Dmitry Torokhov

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: default avatarRaul E Rangel <rrangel@chromium.org>
Link: https://lore.kernel.org/r/20220929093200.v6.3.I5862429ee3e4de0f9ad5ba01ce07ad99eec10cf0@changeidSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent a6d4439a
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <linux/input/touchscreen.h> #include <linux/input/touchscreen.h>
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/pm_wakeirq.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/uuid.h> #include <linux/uuid.h>
...@@ -180,7 +181,6 @@ struct elants_data { ...@@ -180,7 +181,6 @@ struct elants_data {
u8 cmd_resp[HEADER_SIZE]; u8 cmd_resp[HEADER_SIZE];
struct completion cmd_done; struct completion cmd_done;
bool wake_irq_enabled;
bool keep_power_in_suspend; bool keep_power_in_suspend;
/* Must be last to be used for DMA operations */ /* Must be last to be used for DMA operations */
...@@ -1571,6 +1571,15 @@ static int elants_i2c_probe(struct i2c_client *client) ...@@ -1571,6 +1571,15 @@ static int elants_i2c_probe(struct i2c_client *client)
if (!client->dev.of_node) if (!client->dev.of_node)
device_init_wakeup(&client->dev, true); 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); error = devm_device_add_group(&client->dev, &elants_attribute_group);
if (error) { if (error) {
dev_err(&client->dev, "failed to create sysfs attributes: %d\n", dev_err(&client->dev, "failed to create sysfs attributes: %d\n",
...@@ -1602,7 +1611,7 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev) ...@@ -1602,7 +1611,7 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev)
* The device will automatically enter idle mode * The device will automatically enter idle mode
* that has reduced power consumption. * that has reduced power consumption.
*/ */
ts->wake_irq_enabled = (enable_irq_wake(client->irq) == 0); return 0;
} else if (ts->keep_power_in_suspend) { } else if (ts->keep_power_in_suspend) {
for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) { for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
error = elants_i2c_send(client, set_sleep_cmd, error = elants_i2c_send(client, set_sleep_cmd,
...@@ -1631,8 +1640,6 @@ static int __maybe_unused elants_i2c_resume(struct device *dev) ...@@ -1631,8 +1640,6 @@ static int __maybe_unused elants_i2c_resume(struct device *dev)
int error; int error;
if (device_may_wakeup(dev)) { if (device_may_wakeup(dev)) {
if (ts->wake_irq_enabled)
disable_irq_wake(client->irq);
elants_i2c_sw_reset(client); elants_i2c_sw_reset(client);
} else if (ts->keep_power_in_suspend) { } else if (ts->keep_power_in_suspend) {
for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) { for (retry_cnt = 0; retry_cnt < MAX_RETRIES; retry_cnt++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment