[PATCH] ALSA: usb-audio: us144mkii: Use le16_to_cpu() for product ID comparison

Šerif Rami posted 1 patch 1 month, 2 weeks ago
sound/usb/usx2y/us144mkii.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] ALSA: usb-audio: us144mkii: Use le16_to_cpu() for product ID comparison
Posted by Šerif Rami 1 month, 2 weeks ago
The `us144mkii.c` driver was generating sparse warnings due to direct
comparisons of `dev->descriptor.idProduct` (a `__le16` type) with
integer constants. This commit resolves these warnings by explicitly
converting `idProduct` to a CPU-endian integer using `le16_to_cpu()`
before comparison.

This ensures correct handling of endianness and eliminates the sparse
warnings:
- `restricted __le16 degrades to integer`

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202508190811.tjQJZI1X-lkp@intel.com/
Signed-off-by: Šerif Rami <ramiserifpersia@gmail.com>
---
 sound/usb/usx2y/us144mkii.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/usb/usx2y/us144mkii.c b/sound/usb/usx2y/us144mkii.c
index da53c1908..3127a3206 100644
--- a/sound/usb/usx2y/us144mkii.c
+++ b/sound/usb/usx2y/us144mkii.c
@@ -514,10 +514,10 @@ static int tascam_probe(struct usb_interface *intf,
 	}
 
 	strscpy(card->driver, DRIVER_NAME, sizeof(card->driver));
-	if (dev->descriptor.idProduct == USB_PID_TASCAM_US144) {
+	if (le16_to_cpu(dev->descriptor.idProduct) == USB_PID_TASCAM_US144) {
 		strscpy(card->shortname, "TASCAM US-144",
 			sizeof(card->shortname));
-	} else if (dev->descriptor.idProduct == USB_PID_TASCAM_US144MKII) {
+	} else if (le16_to_cpu(dev->descriptor.idProduct) == USB_PID_TASCAM_US144MKII) {
 		strscpy(card->shortname, "TASCAM US-144MKII",
 			sizeof(card->shortname));
 	} else {
-- 
2.50.1

Re: [PATCH] ALSA: usb-audio: us144mkii: Use le16_to_cpu() for product ID comparison
Posted by Takashi Iwai 1 month, 2 weeks ago
On Tue, 19 Aug 2025 09:51:17 +0200,
Šerif Rami wrote:
> 
> The `us144mkii.c` driver was generating sparse warnings due to direct
> comparisons of `dev->descriptor.idProduct` (a `__le16` type) with
> integer constants. This commit resolves these warnings by explicitly
> converting `idProduct` to a CPU-endian integer using `le16_to_cpu()`
> before comparison.
> 
> This ensures correct handling of endianness and eliminates the sparse
> warnings:
> - `restricted __le16 degrades to integer`
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202508190811.tjQJZI1X-lkp@intel.com/
> Signed-off-by: Šerif Rami <ramiserifpersia@gmail.com>

Thanks, I applied now with Fixes tag.


Takashi