Skip to content

Commit c7f4dec

Browse files
ndyerehristev
authored andcommitted
Input: atmel_mxt_ts - delay enabling IRQ when not using regulators
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. Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk> [cyrille.pitchen@atmel.com: adapt original patch to mainline] Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com> [eugen.hristev@microchip.com: adapt original patch to 4.14] Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
1 parent 77ec2a3 commit c7f4dec

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

drivers/input/touchscreen/atmel_mxt_ts.c

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,11 +1184,27 @@ static int mxt_acquire_irq(struct mxt_data *data)
11841184
{
11851185
int error;
11861186

1187-
enable_irq(data->irq);
1187+
if (!data->irq) {
1188+
error = request_threaded_irq(data->client->irq, NULL,
1189+
mxt_interrupt,
1190+
data->pdata->irqflags | IRQF_ONESHOT,
1191+
data->client->name, data);
1192+
if (error) {
1193+
dev_err(&data->client->dev, "Error requesting irq\n");
1194+
return error;
1195+
}
11881196

1189-
error = mxt_process_messages_until_invalid(data);
1190-
if (error)
1191-
return error;
1197+
/* Presence of data->irq means IRQ initialised */
1198+
data->irq = data->client->irq;
1199+
} else {
1200+
enable_irq(data->irq);
1201+
}
1202+
1203+
if (data->object_table) {
1204+
error = mxt_process_messages_until_invalid(data);
1205+
if (error)
1206+
return error;
1207+
}
11921208

11931209
return 0;
11941210
}
@@ -2878,7 +2894,7 @@ static int mxt_load_fw(struct device *dev, const char *fn)
28782894
mxt_free_input_device(data);
28792895
mxt_free_object_table(data);
28802896
} else {
2881-
enable_irq(data->irq);
2897+
mxt_acquire_irq(data);
28822898
}
28832899

28842900
reinit_completion(&data->chg_completion);
@@ -3322,7 +3338,6 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
33223338

33233339
data->client = client;
33243340
data->pdata = pdata;
3325-
data->irq = client->irq;
33263341
i2c_set_clientdata(client, data);
33273342

33283343
init_completion(&data->chg_completion);
@@ -3359,15 +3374,17 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
33593374
}
33603375

33613376
if (pdata->suspend_mode == MXT_SUSPEND_REGULATOR) {
3377+
error = mxt_acquire_irq(data);
3378+
if (error)
3379+
return error;
3380+
33623381
error = mxt_probe_regulators(data);
33633382
if (error)
33643383
return error;
33653384

33663385
disable_irq(data->irq);
33673386
}
33683387

3369-
disable_irq(data->irq);
3370-
33713388
error = mxt_initialize(data);
33723389
if (error) {
33733390
/* Wait and try a second time */

0 commit comments

Comments
 (0)