Commit d8f48935 authored by Takashi Iwai's avatar Takashi Iwai

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: 9e4d5c1b ("ALSA: usb-audio: Scarlett Gen 2 mixer interface")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200201080530.22390-2-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent f8e5f90b
...@@ -558,11 +558,11 @@ static const struct scarlett2_config ...@@ -558,11 +558,11 @@ static const struct scarlett2_config
/* proprietary request/response format */ /* proprietary request/response format */
struct scarlett2_usb_packet { struct scarlett2_usb_packet {
u32 cmd; __le32 cmd;
u16 size; __le16 size;
u16 seq; __le16 seq;
u32 error; __le32 error;
u32 pad; __le32 pad;
u8 data[]; u8 data[];
}; };
...@@ -664,11 +664,11 @@ static int scarlett2_usb( ...@@ -664,11 +664,11 @@ static int scarlett2_usb(
"Scarlett Gen 2 USB invalid response; " "Scarlett Gen 2 USB invalid response; "
"cmd tx/rx %d/%d seq %d/%d size %d/%d " "cmd tx/rx %d/%d seq %d/%d size %d/%d "
"error %d pad %d\n", "error %d pad %d\n",
le16_to_cpu(req->cmd), le16_to_cpu(resp->cmd), le32_to_cpu(req->cmd), le32_to_cpu(resp->cmd),
le16_to_cpu(req->seq), le16_to_cpu(resp->seq), le16_to_cpu(req->seq), le16_to_cpu(resp->seq),
resp_size, le16_to_cpu(resp->size), resp_size, le16_to_cpu(resp->size),
le16_to_cpu(resp->error), le32_to_cpu(resp->error),
le16_to_cpu(resp->pad)); le32_to_cpu(resp->pad));
err = -EINVAL; err = -EINVAL;
goto unlock; goto unlock;
} }
...@@ -687,7 +687,7 @@ static int scarlett2_usb( ...@@ -687,7 +687,7 @@ static int scarlett2_usb(
/* Send SCARLETT2_USB_DATA_CMD SCARLETT2_USB_CONFIG_SAVE */ /* Send SCARLETT2_USB_DATA_CMD SCARLETT2_USB_CONFIG_SAVE */
static void scarlett2_config_save(struct usb_mixer_interface *mixer) static void scarlett2_config_save(struct usb_mixer_interface *mixer)
{ {
u32 req = cpu_to_le32(SCARLETT2_USB_CONFIG_SAVE); __le32 req = cpu_to_le32(SCARLETT2_USB_CONFIG_SAVE);
scarlett2_usb(mixer, SCARLETT2_USB_DATA_CMD, scarlett2_usb(mixer, SCARLETT2_USB_DATA_CMD,
&req, sizeof(u32), &req, sizeof(u32),
...@@ -713,11 +713,11 @@ static int scarlett2_usb_set_config( ...@@ -713,11 +713,11 @@ static int scarlett2_usb_set_config(
const struct scarlett2_config config_item = const struct scarlett2_config config_item =
scarlett2_config_items[config_item_num]; scarlett2_config_items[config_item_num];
struct { struct {
u32 offset; __le32 offset;
u32 bytes; __le32 bytes;
s32 value; __le32 value;
} __packed req; } __packed req;
u32 req2; __le32 req2;
int err; int err;
struct scarlett2_mixer_data *private = mixer->private_data; struct scarlett2_mixer_data *private = mixer->private_data;
...@@ -753,8 +753,8 @@ static int scarlett2_usb_get( ...@@ -753,8 +753,8 @@ static int scarlett2_usb_get(
int offset, void *buf, int size) int offset, void *buf, int size)
{ {
struct { struct {
u32 offset; __le32 offset;
u32 size; __le32 size;
} __packed req; } __packed req;
req.offset = cpu_to_le32(offset); req.offset = cpu_to_le32(offset);
...@@ -794,8 +794,8 @@ static int scarlett2_usb_set_mix(struct usb_mixer_interface *mixer, ...@@ -794,8 +794,8 @@ static int scarlett2_usb_set_mix(struct usb_mixer_interface *mixer,
const struct scarlett2_device_info *info = private->info; const struct scarlett2_device_info *info = private->info;
struct { struct {
u16 mix_num; __le16 mix_num;
u16 data[SCARLETT2_INPUT_MIX_MAX]; __le16 data[SCARLETT2_INPUT_MIX_MAX];
} __packed req; } __packed req;
int i, j; int i, j;
...@@ -850,9 +850,9 @@ static int scarlett2_usb_set_mux(struct usb_mixer_interface *mixer) ...@@ -850,9 +850,9 @@ static int scarlett2_usb_set_mux(struct usb_mixer_interface *mixer)
}; };
struct { struct {
u16 pad; __le16 pad;
u16 num; __le16 num;
u32 data[SCARLETT2_MUX_MAX]; __le32 data[SCARLETT2_MUX_MAX];
} __packed req; } __packed req;
req.pad = 0; req.pad = 0;
...@@ -911,9 +911,9 @@ static int scarlett2_usb_get_meter_levels(struct usb_mixer_interface *mixer, ...@@ -911,9 +911,9 @@ static int scarlett2_usb_get_meter_levels(struct usb_mixer_interface *mixer,
u16 *levels) u16 *levels)
{ {
struct { struct {
u16 pad; __le16 pad;
u16 num_meters; __le16 num_meters;
u32 magic; __le32 magic;
} __packed req; } __packed req;
u32 resp[SCARLETT2_NUM_METERS]; u32 resp[SCARLETT2_NUM_METERS];
int i, err; int i, err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment