diff mbox series

[6/6] media: touchscreen: sur40: convert le16 to cpu before use

Message ID 20240410-smatch-v1-6-785d009a852b@chromium.org (mailing list archive)
State Mainlined
Commit ba2ec9c4f0c8ab59befc7f62e1606a840347f020
Headers show
Series media: Fix warnings for smatch and sparse | expand

Commit Message

Ricardo Ribalda April 10, 2024, 9:54 p.m. UTC
Smatch found this issue:
drivers/input/touchscreen/sur40.c:424:55: warning: incorrect type in argument 2 (different base types)
drivers/input/touchscreen/sur40.c:424:55:    expected int key
drivers/input/touchscreen/sur40.c:424:55:    got restricted __le16 [usertype] blob_id

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/input/touchscreen/sur40.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dmitry Torokhov April 15, 2024, 9:52 p.m. UTC | #1
On Wed, Apr 10, 2024 at 09:54:43PM +0000, Ricardo Ribalda wrote:
> Smatch found this issue:
> drivers/input/touchscreen/sur40.c:424:55: warning: incorrect type in argument 2 (different base types)
> drivers/input/touchscreen/sur40.c:424:55:    expected int key
> drivers/input/touchscreen/sur40.c:424:55:    got restricted __le16 [usertype] blob_id
> 
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>  drivers/input/touchscreen/sur40.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
> index ae3aab4283370..5f2cf8881e724 100644
> --- a/drivers/input/touchscreen/sur40.c
> +++ b/drivers/input/touchscreen/sur40.c
> @@ -421,7 +421,7 @@ static void sur40_report_blob(struct sur40_blob *blob, struct input_dev *input)
>  	if (blob->type != SUR40_TOUCH)
>  		return;
>  
> -	slotnum = input_mt_get_slot_by_key(input, blob->blob_id);
> +	slotnum = input_mt_get_slot_by_key(input, le16_to_cpu(blob->blob_id));

We are not really using the real value of the ID for computations but only
as an opaque "key", so doing the conversion is not strictly necessary,
but it is cheap so we may as well do it.

>  	if (slotnum < 0 || slotnum >= MAX_CONTACTS)
>  		return;

Applied, thank you.
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index ae3aab4283370..5f2cf8881e724 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -421,7 +421,7 @@  static void sur40_report_blob(struct sur40_blob *blob, struct input_dev *input)
 	if (blob->type != SUR40_TOUCH)
 		return;
 
-	slotnum = input_mt_get_slot_by_key(input, blob->blob_id);
+	slotnum = input_mt_get_slot_by_key(input, le16_to_cpu(blob->blob_id));
 	if (slotnum < 0 || slotnum >= MAX_CONTACTS)
 		return;