* [PATCH v2 1/2] input: egalax_ts: free irq resource before request the line as GPIO
@ 2020-04-10 12:43 haibo.chen
2020-04-10 12:43 ` [PATCH v2 2/2] input: egalax_ts: correct the get_firmware_command haibo.chen
0 siblings, 1 reply; 4+ messages in thread
From: haibo.chen @ 2020-04-10 12:43 UTC (permalink / raw)
To: dmitry.torokhov; +Cc: linux-input, linux-imx, haibo.chen
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] input: egalax_ts: correct the get_firmware_command
2020-04-10 12:43 [PATCH v2 1/2] input: egalax_ts: free irq resource before request the line as GPIO haibo.chen
@ 2020-04-10 12:43 ` haibo.chen
2020-04-10 13:01 ` Fabio Estevam
0 siblings, 1 reply; 4+ messages in thread
From: haibo.chen @ 2020-04-10 12:43 UTC (permalink / raw)
To: dmitry.torokhov; +Cc: linux-input, linux-imx, haibo.chen
From: Haibo Chen <haibo.chen@nxp.com>
According to the User Guide, the get firmware command is
{ 0x03, 0x03, 0xa, 0x01, 'D' }, ASCII value of 'D' is 0x44.
Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
drivers/input/touchscreen/egalax_ts.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
index c816e03ba421..bb0a59d19f34 100644
--- a/drivers/input/touchscreen/egalax_ts.c
+++ b/drivers/input/touchscreen/egalax_ts.c
@@ -171,10 +171,10 @@ static int egalax_wake_up_device(struct i2c_client *client)
static int egalax_firmware_version(struct i2c_client *client)
{
- static const u8 cmd[MAX_I2C_DATA_LEN] = { 0x03, 0x03, 0xa, 0x01, 0x41 };
+ static const u8 get_firmware_cmd[MAX_I2C_DATA_LEN] = { 0x03, 0x03, 0xa, 0x01, 0x44 };
int ret;
- ret = i2c_master_send(client, cmd, MAX_I2C_DATA_LEN);
+ ret = i2c_master_send(client, get_firmware_cmd, MAX_I2C_DATA_LEN);
if (ret < 0)
return ret;
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 2/2] input: egalax_ts: correct the get_firmware_command
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
0 siblings, 1 reply; 4+ messages in thread
From: Fabio Estevam @ 2020-04-10 13:01 UTC (permalink / raw)
To: Bough Chen; +Cc: Dmitry Torokhov, linux-input, NXP Linux Team
Hi Haibo,
On Fri, Apr 10, 2020 at 9:51 AM <haibo.chen@nxp.com> wrote:
>
> From: Haibo Chen <haibo.chen@nxp.com>
>
> According to the User Guide, the get firmware command is
> { 0x03, 0x03, 0xa, 0x01, 'D' }, ASCII value of 'D' is 0x44.
>
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> ---
> drivers/input/touchscreen/egalax_ts.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
> index c816e03ba421..bb0a59d19f34 100644
> --- a/drivers/input/touchscreen/egalax_ts.c
> +++ b/drivers/input/touchscreen/egalax_ts.c
> @@ -171,10 +171,10 @@ static int egalax_wake_up_device(struct i2c_client *client)
>
> static int egalax_firmware_version(struct i2c_client *client)
> {
> - static const u8 cmd[MAX_I2C_DATA_LEN] = { 0x03, 0x03, 0xa, 0x01, 0x41 };
> + static const u8 get_firmware_cmd[MAX_I2C_DATA_LEN] = { 0x03, 0x03, 0xa, 0x01, 0x44 };
The rename from 'cmd' to 'get_firmware_cmd' is an unrelated change.
The only change I would expect to see in this patch is 0x41 to 0x44.
Since this is bug fix, please add a Fixes tag.
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH v2 2/2] input: egalax_ts: correct the get_firmware_command
2020-04-10 13:01 ` Fabio Estevam
@ 2020-04-10 13:18 ` BOUGH CHEN
0 siblings, 0 replies; 4+ messages in thread
From: BOUGH CHEN @ 2020-04-10 13:18 UTC (permalink / raw)
To: Fabio Estevam; +Cc: Dmitry Torokhov, linux-input, dl-linux-imx
> -----Original Message-----
> From: Fabio Estevam <festevam@gmail.com>
> Sent: 2020年4月10日 21:01
> To: BOUGH CHEN <haibo.chen@nxp.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>;
> linux-input@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>
> Subject: Re: [PATCH v2 2/2] input: egalax_ts: correct the
> get_firmware_command
>
> Hi Haibo,
>
> On Fri, Apr 10, 2020 at 9:51 AM <haibo.chen@nxp.com> wrote:
> >
> > From: Haibo Chen <haibo.chen@nxp.com>
> >
> > According to the User Guide, the get firmware command is { 0x03, 0x03,
> > 0xa, 0x01, 'D' }, ASCII value of 'D' is 0x44.
> >
> > Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> > ---
> > drivers/input/touchscreen/egalax_ts.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/input/touchscreen/egalax_ts.c
> > b/drivers/input/touchscreen/egalax_ts.c
> > index c816e03ba421..bb0a59d19f34 100644
> > --- a/drivers/input/touchscreen/egalax_ts.c
> > +++ b/drivers/input/touchscreen/egalax_ts.c
> > @@ -171,10 +171,10 @@ static int egalax_wake_up_device(struct
> > i2c_client *client)
> >
> > static int egalax_firmware_version(struct i2c_client *client) {
> > - static const u8 cmd[MAX_I2C_DATA_LEN] = { 0x03, 0x03, 0xa, 0x01,
> 0x41 };
> > + static const u8 get_firmware_cmd[MAX_I2C_DATA_LEN] = { 0x03,
> > + 0x03, 0xa, 0x01, 0x44 };
>
> The rename from 'cmd' to 'get_firmware_cmd' is an unrelated change.
>
> The only change I would expect to see in this patch is 0x41 to 0x44.
>
> Since this is bug fix, please add a Fixes tag.
Okay, Thanks for your review!
Best Regards
Haibo Chen
>
> Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-10 13:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-10 12:43 [PATCH v2 1/2] input: egalax_ts: free irq resource before request the line as GPIO haibo.chen
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).