From: haibo.chen@nxp.com
To: dmitry.torokhov@gmail.com
Cc: linux-input@vger.kernel.org, linux-imx@nxp.com, haibo.chen@nxp.com
Subject: [PATCH v2 1/2] input: egalax_ts: free irq resource before request the line as GPIO
Date: Fri, 10 Apr 2020 20:43:04 +0800 [thread overview]
Message-ID: <1586522585-14296-1-git-send-email-haibo.chen@nxp.com> (raw)
From: Haibo Chen <haibo.chen@nxp.com>
If GPIO is connected to an IRQ then it should not request it as
GPIO function only when free its IRQ resource.
Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
drivers/input/touchscreen/egalax_ts.c | 46 ++++++++++++++++++++++-----
1 file changed, 38 insertions(+), 8 deletions(-)
diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
index 83ac8c128192..c816e03ba421 100644
--- a/drivers/input/touchscreen/egalax_ts.c
+++ b/drivers/input/touchscreen/egalax_ts.c
@@ -116,6 +116,26 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
return IRQ_HANDLED;
}
+static int egalax_irq_request(struct egalax_ts *ts)
+{
+ int ret;
+ struct i2c_client *client = ts->client;
+
+ ret = devm_request_threaded_irq(&client->dev, client->irq, NULL,
+ egalax_ts_interrupt,
+ IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+ "egalax_ts", ts);
+ if (ret < 0)
+ dev_err(&client->dev, "Failed to register interrupt\n");
+
+ return ret;
+}
+
+static void egalax_free_irq(struct egalax_ts *ts)
+{
+ devm_free_irq(&ts->client->dev, ts->client->irq, ts);
+}
+
/* wake up controller by an falling edge of interrupt gpio. */
static int egalax_wake_up_device(struct i2c_client *client)
{
@@ -211,19 +231,16 @@ static int egalax_ts_probe(struct i2c_client *client,
ABS_MT_POSITION_Y, 0, EGALAX_MAX_Y, 0, 0);
input_mt_init_slots(input_dev, MAX_SUPPORT_POINTS, 0);
- error = devm_request_threaded_irq(&client->dev, client->irq, NULL,
- egalax_ts_interrupt,
- IRQF_TRIGGER_LOW | IRQF_ONESHOT,
- "egalax_ts", ts);
- if (error < 0) {
- dev_err(&client->dev, "Failed to register interrupt\n");
+ error = egalax_irq_request(ts);
+ if (error)
return error;
- }
error = input_register_device(ts->input_dev);
if (error)
return error;
+ i2c_set_clientdata(client, ts);
+
return 0;
}
@@ -251,11 +268,24 @@ static int __maybe_unused egalax_ts_suspend(struct device *dev)
static int __maybe_unused egalax_ts_resume(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
+ struct egalax_ts *ts = i2c_get_clientdata(client);
+ int error;
if (device_may_wakeup(dev))
return disable_irq_wake(client->irq);
- return egalax_wake_up_device(client);
+ /* Free IRQ as IRQ pin is used as output in the suspend sequence */
+ egalax_free_irq(ts);
+
+ error = egalax_wake_up_device(client);
+ if (error) {
+ dev_err(&client->dev, "Failed to wake up the controller\n");
+ return error;
+ }
+
+ error = egalax_irq_request(ts);
+
+ return error;
}
static SIMPLE_DEV_PM_OPS(egalax_ts_pm_ops, egalax_ts_suspend, egalax_ts_resume);
--
2.17.1
next reply other threads:[~2020-04-10 12:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-10 12:43 haibo.chen [this message]
2020-04-10 12:43 ` [PATCH v2 2/2] input: egalax_ts: correct the get_firmware_command haibo.chen
2020-04-10 13:01 ` Fabio Estevam
2020-04-10 13:18 ` BOUGH CHEN
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1586522585-14296-1-git-send-email-haibo.chen@nxp.com \
--to=haibo.chen@nxp.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-imx@nxp.com \
--cc=linux-input@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox