Skip to content

Commit d8f4893

Browse files
committed
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: 9e4d5c1 ("ALSA: usb-audio: Scarlett Gen 2 mixer interface") Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent f8e5f90 commit d8f4893

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

sound/usb/mixer_scarlett_gen2.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -558,11 +558,11 @@ static const struct scarlett2_config
558558

559559
/* proprietary request/response format */
560560
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;
566566
u8 data[];
567567
};
568568

@@ -664,11 +664,11 @@ static int scarlett2_usb(
664664
"Scarlett Gen 2 USB invalid response; "
665665
"cmd tx/rx %d/%d seq %d/%d size %d/%d "
666666
"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),
668668
le16_to_cpu(req->seq), le16_to_cpu(resp->seq),
669669
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));
672672
err = -EINVAL;
673673
goto unlock;
674674
}
@@ -687,7 +687,7 @@ static int scarlett2_usb(
687687
/* Send SCARLETT2_USB_DATA_CMD SCARLETT2_USB_CONFIG_SAVE */
688688
static void scarlett2_config_save(struct usb_mixer_interface *mixer)
689689
{
690-
u32 req = cpu_to_le32(SCARLETT2_USB_CONFIG_SAVE);
690+
__le32 req = cpu_to_le32(SCARLETT2_USB_CONFIG_SAVE);
691691

692692
scarlett2_usb(mixer, SCARLETT2_USB_DATA_CMD,
693693
&req, sizeof(u32),
@@ -713,11 +713,11 @@ static int scarlett2_usb_set_config(
713713
const struct scarlett2_config config_item =
714714
scarlett2_config_items[config_item_num];
715715
struct {
716-
u32 offset;
717-
u32 bytes;
718-
s32 value;
716+
__le32 offset;
717+
__le32 bytes;
718+
__le32 value;
719719
} __packed req;
720-
u32 req2;
720+
__le32 req2;
721721
int err;
722722
struct scarlett2_mixer_data *private = mixer->private_data;
723723

@@ -753,8 +753,8 @@ static int scarlett2_usb_get(
753753
int offset, void *buf, int size)
754754
{
755755
struct {
756-
u32 offset;
757-
u32 size;
756+
__le32 offset;
757+
__le32 size;
758758
} __packed req;
759759

760760
req.offset = cpu_to_le32(offset);
@@ -794,8 +794,8 @@ static int scarlett2_usb_set_mix(struct usb_mixer_interface *mixer,
794794
const struct scarlett2_device_info *info = private->info;
795795

796796
struct {
797-
u16 mix_num;
798-
u16 data[SCARLETT2_INPUT_MIX_MAX];
797+
__le16 mix_num;
798+
__le16 data[SCARLETT2_INPUT_MIX_MAX];
799799
} __packed req;
800800

801801
int i, j;
@@ -850,9 +850,9 @@ static int scarlett2_usb_set_mux(struct usb_mixer_interface *mixer)
850850
};
851851

852852
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];
856856
} __packed req;
857857

858858
req.pad = 0;
@@ -911,9 +911,9 @@ static int scarlett2_usb_get_meter_levels(struct usb_mixer_interface *mixer,
911911
u16 *levels)
912912
{
913913
struct {
914-
u16 pad;
915-
u16 num_meters;
916-
u32 magic;
914+
__le16 pad;
915+
__le16 num_meters;
916+
__le32 magic;
917917
} __packed req;
918918
u32 resp[SCARLETT2_NUM_METERS];
919919
int i, err;

0 commit comments

Comments
 (0)