diff options
author | 2025-02-01 12:39:04 +0100 | |
---|---|---|
committer | 2025-02-03 15:17:11 +0100 | |
commit | 4eb9c2ee538b62dc5dcae192297c3a4044b7ade5 (patch) | |
tree | 9a33260731fe71e9f76c3074d397623c01e8bb50 | |
parent | HID: pidff: Move all hid-pidff definitions to a dedicated header (diff) | |
download | wireguard-linux-4eb9c2ee538b62dc5dcae192297c3a4044b7ade5.tar.xz wireguard-linux-4eb9c2ee538b62dc5dcae192297c3a4044b7ade5.zip |
HID: pidff: Simplify pidff_rescale_signed
This function overrelies on ternary operators and makes it hard to parse
it mentally. New version makes it very easy to understand.
Signed-off-by: Tomasz Pakuła <tomasz.pakula.oficjalny@gmail.com>
Reviewed-by: Michał Kopeć <michal@nozomi.space>
Reviewed-by: Paul Dino Jones <paul@spacefreak18.xyz>
Tested-by: Paul Dino Jones <paul@spacefreak18.xyz>
Tested-by: Cristóferson Bueno <cbueno81@gmail.com>
Tested-by: Pablo Cisneros <patchkez@protonmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
-rw-r--r-- | drivers/hid/usbhid/hid-pidff.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index a8eaa77e80be..8083eb7684e5 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c @@ -230,9 +230,9 @@ static int pidff_rescale(int i, int max, struct hid_field *field) */ static int pidff_rescale_signed(int i, struct hid_field *field) { - return i == 0 ? 0 : i > - 0 ? i * field->logical_maximum / 0x7fff : i * - field->logical_minimum / -0x8000; + if (i > 0) return i * field->logical_maximum / 0x7fff; + if (i < 0) return i * field->logical_minimum / -0x8000; + return 0; } /* |