From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: haibo.chen@nxp.com
Cc: linux-input@vger.kernel.org, linux-imx@nxp.com
Subject: Re: [PATCH 2/2] input: egalax_ts: free irq resource before request the line as GPIO
Date: Mon, 9 Mar 2020 21:26:43 -0700 [thread overview]
Message-ID: <20200310042643.GB192640@dtor-ws> (raw)
In-Reply-To: <1581410472-3225-2-git-send-email-haibo.chen@nxp.com>
On Tue, Feb 11, 2020 at 04:41:12PM +0800, haibo.chen@nxp.com wrote:
> 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 | 44 +++++++++++++++++++--------
> 1 file changed, 31 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
> index 5e35ca5edc7b..c7983104a0b9 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)
> {
> @@ -225,19 +245,15 @@ 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;
> }
>
> @@ -253,11 +269,10 @@ static int __maybe_unused egalax_ts_suspend(struct device *dev)
> 0x3, 0x6, 0xa, 0x3, 0x36, 0x3f, 0x2, 0, 0, 0
> };
> struct i2c_client *client = to_i2c_client(dev);
> + struct egalax_ts *ts = i2c_get_clientdata(client);
> int ret;
>
> - if (device_may_wakeup(dev))
> - return enable_irq_wake(client->irq);
> -
Why are you removing handling of the interrupt as a wakeup source if
device is configured for wakeup? I guess it is a noop and I2C core does
it for us on newer kernels anyways, but such cleanup should be in a
separate patch. Still, you do not want to put the controller to sleep if
it is supposed to be a wakeup source.
> + egalax_free_irq(ts);
It sounds to me you want simply disable interrupts in suspend. Does not
calling disable_irq() here suffice?
Thanks.
--
Dmitry
next prev parent reply other threads:[~2020-03-10 4:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-11 8:41 [PATCH 1/2] input: egalax_ts: switch to i2c interface before wake up haibo.chen
2020-02-11 8:41 ` [PATCH 2/2] input: egalax_ts: free irq resource before request the line as GPIO haibo.chen
2020-03-10 4:26 ` Dmitry Torokhov [this message]
2020-03-10 7:15 ` BOUGH CHEN
2020-04-19 18:10 ` Dmitry Torokhov
2020-04-19 21:27 ` Andy Shevchenko
2020-04-28 11:21 ` Linus Walleij
2020-03-10 1:58 ` [PATCH 1/2] input: egalax_ts: switch to i2c interface before wake up BOUGH CHEN
2020-03-10 4:22 ` Dmitry Torokhov
2020-03-10 7:01 ` 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=20200310042643.GB192640@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=haibo.chen@nxp.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