Skip to content

Commit 4eb9c2e

Browse files
LawstorantJiri Kosina
authored andcommitted
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>
1 parent 0d24d4b commit 4eb9c2e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/hid/usbhid/hid-pidff.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ static int pidff_rescale(int i, int max, struct hid_field *field)
230230
*/
231231
static int pidff_rescale_signed(int i, struct hid_field *field)
232232
{
233-
return i == 0 ? 0 : i >
234-
0 ? i * field->logical_maximum / 0x7fff : i *
235-
field->logical_minimum / -0x8000;
233+
if (i > 0) return i * field->logical_maximum / 0x7fff;
234+
if (i < 0) return i * field->logical_minimum / -0x8000;
235+
return 0;
236236
}
237237

238238
/*

0 commit comments

Comments
 (0)