HID: pidff: Compute INFINITE value instead of using hardcoded 0xffff

[ Upstream commit 1a575044d516972a1d036d54c0180b9085e21dc6 ]

As per USB PID standard:
INFINITE - Referrers to the maximum value of a range. i.e. if in an 8
bit unsigned field the value of 255 would indicate INFINITE.

Detecting 0xffff (U16_MAX) is still important as we MIGHT get this value
as infinite from some native software as 0 was never actually defined
in Linux' FF api as the infinite value. I'm working on it though.

Signed-off-by: Tomasz Pakuła <tomasz.pakula.oficjalny@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Tomasz Pakuła
2025-02-25 23:30:02 +01:00
committed by Greg Kroah-Hartman
parent b15301f289
commit 5318556ed3

View File

@@ -283,8 +283,9 @@ static void pidff_set_duration(struct pidff_usage *usage, u16 duration)
if (duration == FF_INFINITE)
duration = PID_INFINITE;
/* PID defines INFINITE as the max possible value for duration field */
if (duration == PID_INFINITE) {
usage->value[0] = PID_INFINITE;
usage->value[0] = (1U << usage->field->report_size) - 1;
return;
}