Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: usb-audio: Annotate endianess in Scarlett gen2 quirk

The Scarlett gen2 mixer quirk code defines a few record types to
communicate via USB hub, and those must be all little-endian.
This patch changes the field types to LE to annotate endianess
properly. It also fixes the incorrect usage of leXX_to_cpu() in a
couple of places, which was caught by sparse after this change.

Fixes: 9e4d5c1be21f ("ALSA: usb-audio: Scarlett Gen 2 mixer interface")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200201080530.22390-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+23 -23
+23 -23
sound/usb/mixer_scarlett_gen2.c
··· 558 558 559 559 /* proprietary request/response format */ 560 560 struct scarlett2_usb_packet { 561 - u32 cmd; 562 - u16 size; 563 - u16 seq; 564 - u32 error; 565 - u32 pad; 561 + __le32 cmd; 562 + __le16 size; 563 + __le16 seq; 564 + __le32 error; 565 + __le32 pad; 566 566 u8 data[]; 567 567 }; 568 568 ··· 664 664 "Scarlett Gen 2 USB invalid response; " 665 665 "cmd tx/rx %d/%d seq %d/%d size %d/%d " 666 666 "error %d pad %d\n", 667 - le16_to_cpu(req->cmd), le16_to_cpu(resp->cmd), 667 + le32_to_cpu(req->cmd), le32_to_cpu(resp->cmd), 668 668 le16_to_cpu(req->seq), le16_to_cpu(resp->seq), 669 669 resp_size, le16_to_cpu(resp->size), 670 - le16_to_cpu(resp->error), 671 - le16_to_cpu(resp->pad)); 670 + le32_to_cpu(resp->error), 671 + le32_to_cpu(resp->pad)); 672 672 err = -EINVAL; 673 673 goto unlock; 674 674 } ··· 687 687 /* Send SCARLETT2_USB_DATA_CMD SCARLETT2_USB_CONFIG_SAVE */ 688 688 static void scarlett2_config_save(struct usb_mixer_interface *mixer) 689 689 { 690 - u32 req = cpu_to_le32(SCARLETT2_USB_CONFIG_SAVE); 690 + __le32 req = cpu_to_le32(SCARLETT2_USB_CONFIG_SAVE); 691 691 692 692 scarlett2_usb(mixer, SCARLETT2_USB_DATA_CMD, 693 693 &req, sizeof(u32), ··· 713 713 const struct scarlett2_config config_item = 714 714 scarlett2_config_items[config_item_num]; 715 715 struct { 716 - u32 offset; 717 - u32 bytes; 718 - s32 value; 716 + __le32 offset; 717 + __le32 bytes; 718 + __le32 value; 719 719 } __packed req; 720 - u32 req2; 720 + __le32 req2; 721 721 int err; 722 722 struct scarlett2_mixer_data *private = mixer->private_data; 723 723 ··· 753 753 int offset, void *buf, int size) 754 754 { 755 755 struct { 756 - u32 offset; 757 - u32 size; 756 + __le32 offset; 757 + __le32 size; 758 758 } __packed req; 759 759 760 760 req.offset = cpu_to_le32(offset); ··· 794 794 const struct scarlett2_device_info *info = private->info; 795 795 796 796 struct { 797 - u16 mix_num; 798 - u16 data[SCARLETT2_INPUT_MIX_MAX]; 797 + __le16 mix_num; 798 + __le16 data[SCARLETT2_INPUT_MIX_MAX]; 799 799 } __packed req; 800 800 801 801 int i, j; ··· 850 850 }; 851 851 852 852 struct { 853 - u16 pad; 854 - u16 num; 855 - u32 data[SCARLETT2_MUX_MAX]; 853 + __le16 pad; 854 + __le16 num; 855 + __le32 data[SCARLETT2_MUX_MAX]; 856 856 } __packed req; 857 857 858 858 req.pad = 0; ··· 911 911 u16 *levels) 912 912 { 913 913 struct { 914 - u16 pad; 915 - u16 num_meters; 916 - u32 magic; 914 + __le16 pad; 915 + __le16 num_meters; 916 + __le32 magic; 917 917 } __packed req; 918 918 u32 resp[SCARLETT2_NUM_METERS]; 919 919 int i, err;