[PATCH v11 33/56] Input: atmel_mxt_ts - delay enabling IRQ when not using regulators

Jiada Wang
2020-05-08T05:59:11Z

The path of enabling the IRQ in the probe function is not safe in level
triggered operation, if it was already powered up and there is a message
waiting on the device (eg finger down) because the object table has not yet
been read. This forces the ISR into a hard loop.

Delay enabling the interrupt until it is first needed, by set flag
IRQ_NOAUTOEN.

Signed-off-by: Jiada Wang <jiada_wang@mentor.com>
CC: Dmitry Osipenko <digetx@gmail.com>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 7c9a738e633a..ab4eceac8fe7 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -3822,6 +3822,7 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
return error;
}

+ irq_set_status_flags(client->irq, IRQ_NOAUTOEN);
error = devm_request_threaded_irq(&client->dev, client->irq,
NULL, mxt_interrupt, IRQF_ONESHOT,
client->name, data);
@@ -3831,17 +3832,19 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
}

if (data->suspend_mode == MXT_SUSPEND_REGULATOR) {
+ enable_irq(data->irq);
+
error = mxt_probe_regulators(data);
if (error)
return error;
+
+ disable_irq(data->irq);
} else if (data->reset_gpio) {
msleep(MXT_RESET_GPIO_TIME);
gpiod_set_value(data->reset_gpio, 1);
msleep(MXT_RESET_INVALID_CHG);
}

- disable_irq(data->irq);
-
error = mxt_initialize(data);
if (error)
return error;
--
2.17.1