From: "Tomasz Pakuła" <tomasz.pakula.oficjalny@gmail.com>
To: jikos@kernel.org, bentiss@kernel.org
Cc: oleg@makarenk.ooo, linux-input@vger.kernel.org,
linux-usb@vger.kernel.org
Subject: [PATCH v4 2/6] HID: pidff: Make sure to fetch pool before checking SIMULTANEOUS_MAX
Date: Tue, 11 Feb 2025 15:35:08 +0100 [thread overview]
Message-ID: <20250211143512.720818-3-tomasz.pakula.oficjalny@gmail.com> (raw)
In-Reply-To: <20250211143512.720818-1-tomasz.pakula.oficjalny@gmail.com>
As noted by Anssi some 20 years ago, pool report is sometimes messed up.
This worked fine on many devices but casued oops on VRS DirectForce PRO.
Here, we're making sure pool report is refetched before trying to access
any of it's fields. While loop was replaced with a for loop + exit
conditions were moved aroud to decrease the possibility of creating an
infinite loop scenario.
Signed-off-by: Tomasz Pakuła <tomasz.pakula.oficjalny@gmail.com>
---
drivers/hid/usbhid/hid-pidff.c | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c
index f23381b6e344..503f643b59ca 100644
--- a/drivers/hid/usbhid/hid-pidff.c
+++ b/drivers/hid/usbhid/hid-pidff.c
@@ -604,28 +604,25 @@ static void pidff_reset(struct pidff_device *pidff)
}
/*
- * Refetch pool report
+ * Fetch pool report
*/
static void pidff_fetch_pool(struct pidff_device *pidff)
{
- if (!pidff->pool[PID_SIMULTANEOUS_MAX].value)
- return;
+ int i;
+ struct hid_device *hid = pidff->hid;
- int i = 0;
- while (pidff->pool[PID_SIMULTANEOUS_MAX].value[0] < 2) {
- hid_dbg(pidff->hid, "pid_pool requested again\n");
- hid_hw_request(pidff->hid, pidff->reports[PID_POOL],
- HID_REQ_GET_REPORT);
- hid_hw_wait(pidff->hid);
+ /* Repeat if PID_SIMULTANEOUS_MAX < 2 to make sure it's correct */
+ for(i = 0; i < 20; i++) {
+ hid_hw_request(hid, pidff->reports[PID_POOL], HID_REQ_GET_REPORT);
+ hid_hw_wait(hid);
- /* break after 20 tries with SIMULTANEOUS_MAX < 2 */
- if (i++ > 20) {
- hid_warn(pidff->hid,
- "device reports %d simultaneous effects\n",
- pidff->pool[PID_SIMULTANEOUS_MAX].value[0]);
- break;
- }
+ if (!pidff->pool[PID_SIMULTANEOUS_MAX].value)
+ return;
+ if (pidff->pool[PID_SIMULTANEOUS_MAX].value[0] >= 2)
+ return;
}
+ hid_warn(hid, "device reports %d simultaneous effects\n",
+ pidff->pool[PID_SIMULTANEOUS_MAX].value[0]);
}
/*
--
2.48.1
next prev parent reply other threads:[~2025-02-11 14:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-11 14:35 [PATCH v4 0/6] HID: pidff: Compatibility update and new devices Tomasz Pakuła
2025-02-11 14:35 ` [PATCH v4 1/6] MAINTAINERS: Update hid-universal-pidff entry Tomasz Pakuła
2025-02-11 15:34 ` Oleg Makarenko
2025-02-11 14:35 ` Tomasz Pakuła [this message]
2025-02-11 14:35 ` [PATCH v4 3/6] HID: hid-universal-pidff: Add Asetek wheelbases support Tomasz Pakuła
2025-02-11 14:35 ` [PATCH v4 4/6] HID: pidff: Comment and code style update Tomasz Pakuła
2025-02-11 14:35 ` [PATCH v4 5/6] HID: pidff: Support device error response from PID_BLOCK_LOAD Tomasz Pakuła
2025-02-11 14:35 ` [PATCH v4 6/6] HID: pidff: Remove redundant call to pidff_find_special_keys Tomasz Pakuła
2025-02-11 22:16 ` [PATCH v4 0/6] HID: pidff: Compatibility update and new devices Jiri Kosina
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=20250211143512.720818-3-tomasz.pakula.oficjalny@gmail.com \
--to=tomasz.pakula.oficjalny@gmail.com \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oleg@makarenk.ooo \
/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