* [PATCH V2] HID: HID-rmi - ignore to rmi_hid_read_block after system resumes.
@ 2022-08-09 3:09 margeyang
2022-08-10 10:11 ` Hans de Goede
0 siblings, 1 reply; 3+ messages in thread
From: margeyang @ 2022-08-09 3:09 UTC (permalink / raw)
To: dmitry.torokhov, linux-input, linux-kernel, hdegoede, benjamin.tissoires
Cc: marge.yang, derek.cheng, vincent.huang, Marge Yang
From: Marge Yang <marge.yang@synaptics.corp-partner.google.com>
The interrupt GPIO will be pulled down once
after RMI driver reads this command(Report ID:0x0A).
It will cause "Dark resume test fail" for chromebook device.
Hence, TP driver will ignore rmi_hid_read_block function once
after system resumes.
Signed-off-by: Marge Yang<marge.yang@synaptics.corp-partner.google.com>
---
drivers/hid/hid-rmi.c | 14 ++++++++++++--
include/linux/rmi.h | 2 ++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
index 311eee599ce9..b08b74b0c140 100644
--- a/drivers/hid/hid-rmi.c
+++ b/drivers/hid/hid-rmi.c
@@ -203,7 +203,13 @@ static int rmi_hid_read_block(struct rmi_transport_dev *xport, u16 addr,
if (ret < 0)
goto exit;
}
-
+ if ((!!xport) && (xport->ignoreonce == 1)) {
+ dev_err(&hdev->dev,
+ "ignoreonce (%d)\n",
+ xport->ignoreonce);
+ xport->ignoreonce = 0;
+ goto exit;
+ }
for (retries = 5; retries > 0; retries--) {
data->writeReport[0] = RMI_READ_ADDR_REPORT_ID;
data->writeReport[1] = 0; /* old 1 byte read count */
@@ -468,8 +474,12 @@ static int rmi_post_resume(struct hid_device *hdev)
ret = hid_hw_open(hdev);
if (ret)
return ret;
-
+ // Avoid to read rmi_hid_read_block once after system resumes.
+ // The interrupt will be pulled down
+ // after RMI Read command(Report ID:0x0A).
+ data->xport.ignoreonce = 1;
ret = rmi_reset_attn_mode(hdev);
+ data->xport.ignoreonce = 0;
if (ret)
goto out;
diff --git a/include/linux/rmi.h b/include/linux/rmi.h
index ab7eea01ab42..24f63ad00970 100644
--- a/include/linux/rmi.h
+++ b/include/linux/rmi.h
@@ -270,6 +270,8 @@ struct rmi_transport_dev {
struct rmi_device_platform_data pdata;
struct input_dev *input;
+
+ int ignoreonce;
};
/**
--
2.22.0.windows.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V2] HID: HID-rmi - ignore to rmi_hid_read_block after system resumes.
2022-08-09 3:09 [PATCH V2] HID: HID-rmi - ignore to rmi_hid_read_block after system resumes margeyang
@ 2022-08-10 10:11 ` Hans de Goede
2022-08-11 3:04 ` Marge Yang
0 siblings, 1 reply; 3+ messages in thread
From: Hans de Goede @ 2022-08-10 10:11 UTC (permalink / raw)
To: margeyang, dmitry.torokhov, linux-input, linux-kernel,
benjamin.tissoires
Cc: marge.yang, derek.cheng, vincent.huang
Hi,
On 8/9/22 05:09, margeyang wrote:
> From: Marge Yang <marge.yang@synaptics.corp-partner.google.com>
>
> The interrupt GPIO will be pulled down once
> after RMI driver reads this command(Report ID:0x0A).
> It will cause "Dark resume test fail" for chromebook device.
> Hence, TP driver will ignore rmi_hid_read_block function once
> after system resumes.
>
> Signed-off-by: Marge Yang<marge.yang@synaptics.corp-partner.google.com>
> ---
> drivers/hid/hid-rmi.c | 14 ++++++++++++--
> include/linux/rmi.h | 2 ++
> 2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
> index 311eee599ce9..b08b74b0c140 100644
> --- a/drivers/hid/hid-rmi.c
> +++ b/drivers/hid/hid-rmi.c
> @@ -203,7 +203,13 @@ static int rmi_hid_read_block(struct rmi_transport_dev *xport, u16 addr,
> if (ret < 0)
> goto exit;
> }
> -
> + if ((!!xport) && (xport->ignoreonce == 1)) {
The top of this function has:
struct rmi_data *data = container_of(xport, struct rmi_data, xport);
and data gets dereferenced unconditionally in various places,
so there is no need for the xport check, please change this to just:
if (xport->ignoreonce == 1) {
Otherwise this looks good to me now.
Regards,
Hans
> + dev_err(&hdev->dev,
> + "ignoreonce (%d)\n",
> + xport->ignoreonce);
> + xport->ignoreonce = 0;
> + goto exit;
> + }
> for (retries = 5; retries > 0; retries--) {
> data->writeReport[0] = RMI_READ_ADDR_REPORT_ID;
> data->writeReport[1] = 0; /* old 1 byte read count */
> @@ -468,8 +474,12 @@ static int rmi_post_resume(struct hid_device *hdev)
> ret = hid_hw_open(hdev);
> if (ret)
> return ret;
> -
> + // Avoid to read rmi_hid_read_block once after system resumes.
> + // The interrupt will be pulled down
> + // after RMI Read command(Report ID:0x0A).
> + data->xport.ignoreonce = 1;
> ret = rmi_reset_attn_mode(hdev);
> + data->xport.ignoreonce = 0;
> if (ret)
> goto out;
>
> diff --git a/include/linux/rmi.h b/include/linux/rmi.h
> index ab7eea01ab42..24f63ad00970 100644
> --- a/include/linux/rmi.h
> +++ b/include/linux/rmi.h
> @@ -270,6 +270,8 @@ struct rmi_transport_dev {
> struct rmi_device_platform_data pdata;
>
> struct input_dev *input;
> +
> + int ignoreonce;
> };
>
> /**
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH V2] HID: HID-rmi - ignore to rmi_hid_read_block after system resumes.
2022-08-10 10:11 ` Hans de Goede
@ 2022-08-11 3:04 ` Marge Yang
0 siblings, 0 replies; 3+ messages in thread
From: Marge Yang @ 2022-08-11 3:04 UTC (permalink / raw)
To: Hans de Goede, margeyang, dmitry.torokhov, linux-input,
linux-kernel, benjamin.tissoires
Cc: Derek Cheng, Vincent Huang, David Chiu
Hi Hans,
Thanks for your suggestion.
if (xport->ignoreonce == 1) {
I have modified/verified it and sent 3rd version.
Thanks
Marge Yang
-----Original Message-----
From: Hans de Goede <hdegoede@redhat.com>
Sent: Wednesday, August 10, 2022 6:12 PM
To: margeyang <marge.yang@synaptics.corp-partner.google.com>; dmitry.torokhov@gmail.com; linux-input@vger.kernel.org; linux-kernel@vger.kernel.org; benjamin.tissoires@redhat.com
Cc: Marge Yang <Marge.Yang@tw.synaptics.com>; Derek Cheng <derek.cheng@tw.synaptics.com>; Vincent Huang <Vincent.huang@tw.synaptics.com>
Subject: Re: [PATCH V2] HID: HID-rmi - ignore to rmi_hid_read_block after system resumes.
CAUTION: Email originated externally, do not click links or open attachments unless you recognize the sender and know the content is safe.
Hi,
On 8/9/22 05:09, margeyang wrote:
> From: Marge Yang <marge.yang@synaptics.corp-partner.google.com>
>
> The interrupt GPIO will be pulled down once after RMI driver reads
> this command(Report ID:0x0A).
> It will cause "Dark resume test fail" for chromebook device.
> Hence, TP driver will ignore rmi_hid_read_block function once after
> system resumes.
>
> Signed-off-by: Marge
> Yang<marge.yang@synaptics.corp-partner.google.com>
> ---
> drivers/hid/hid-rmi.c | 14 ++++++++++++--
> include/linux/rmi.h | 2 ++
> 2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c index
> 311eee599ce9..b08b74b0c140 100644
> --- a/drivers/hid/hid-rmi.c
> +++ b/drivers/hid/hid-rmi.c
> @@ -203,7 +203,13 @@ static int rmi_hid_read_block(struct rmi_transport_dev *xport, u16 addr,
> if (ret < 0)
> goto exit;
> }
> -
> + if ((!!xport) && (xport->ignoreonce == 1)) {
The top of this function has:
struct rmi_data *data = container_of(xport, struct rmi_data, xport);
and data gets dereferenced unconditionally in various places, so there is no need for the xport check, please change this to just:
if (xport->ignoreonce == 1) {
Otherwise this looks good to me now.
Regards,
Hans
> + dev_err(&hdev->dev,
> + "ignoreonce (%d)\n",
> + xport->ignoreonce);
> + xport->ignoreonce = 0;
> + goto exit;
> + }
> for (retries = 5; retries > 0; retries--) {
> data->writeReport[0] = RMI_READ_ADDR_REPORT_ID;
> data->writeReport[1] = 0; /* old 1 byte read count */ @@
> -468,8 +474,12 @@ static int rmi_post_resume(struct hid_device *hdev)
> ret = hid_hw_open(hdev);
> if (ret)
> return ret;
> -
> + // Avoid to read rmi_hid_read_block once after system resumes.
> + // The interrupt will be pulled down
> + // after RMI Read command(Report ID:0x0A).
> + data->xport.ignoreonce = 1;
> ret = rmi_reset_attn_mode(hdev);
> + data->xport.ignoreonce = 0;
> if (ret)
> goto out;
>
> diff --git a/include/linux/rmi.h b/include/linux/rmi.h index
> ab7eea01ab42..24f63ad00970 100644
> --- a/include/linux/rmi.h
> +++ b/include/linux/rmi.h
> @@ -270,6 +270,8 @@ struct rmi_transport_dev {
> struct rmi_device_platform_data pdata;
>
> struct input_dev *input;
> +
> + int ignoreonce;
> };
>
> /**
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-11 3:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-09 3:09 [PATCH V2] HID: HID-rmi - ignore to rmi_hid_read_block after system resumes margeyang
2022-08-10 10:11 ` Hans de Goede
2022-08-11 3:04 ` Marge Yang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.