diff mbox series

[RESEND] HID: hid-steam: Use clamp() macro

Message ID 20240731135003.80609-2-thorsten.blum@toblux.com (mailing list archive)
State New
Delegated to: Jiri Kosina
Headers show
Series [RESEND] HID: hid-steam: Use clamp() macro | expand

Commit Message

Thorsten Blum July 31, 2024, 1:50 p.m. UTC
Use clamp() to actually clamp the value to the range [-32767, 32767]
(as mentioned in the function comment) instead of manually mapping
one specific value.

Compile-tested only.

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 drivers/hid/hid-steam.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c
index bf8b633114be..3442985d52ce 100644
--- a/drivers/hid/hid-steam.c
+++ b/drivers/hid/hid-steam.c
@@ -1341,7 +1341,7 @@  static inline s16 steam_le16(u8 *data)
 {
 	s16 x = (s16) le16_to_cpup((__le16 *)data);
 
-	return x == -32768 ? -32767 : x;
+	return clamp(x, -32767, 32767);
 }
 
 /*