Skip to content

Commit af4768b

Browse files
rbilovolnumbqq
authored andcommitted
UPSTREAM: usb: gadget: f_uac1: endianness fixes.
As per USB spec, multiple-bytes fields are stored in little-endian order. Use CPU<->LE helpers for such fields. Change-Id: I5515940cc0553c1a86dc5072bab7d2516b4bcec3 Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com> Signed-off-by: William Wu <william.wu@rock-chips.com> (cherry picked from commit 42370b8)
1 parent 1a73ec6 commit af4768b

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

drivers/usb/gadget/function/f_uac1.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ static struct uac_input_terminal_descriptor usb_out_it_desc = {
9292
.bDescriptorType = USB_DT_CS_INTERFACE,
9393
.bDescriptorSubtype = UAC_INPUT_TERMINAL,
9494
.bTerminalID = USB_OUT_IT_ID,
95-
.wTerminalType = UAC_TERMINAL_STREAMING,
95+
.wTerminalType = cpu_to_le16(UAC_TERMINAL_STREAMING),
9696
.bAssocTerminal = 0,
97-
.wChannelConfig = 0x3,
97+
.wChannelConfig = cpu_to_le16(0x3),
9898
};
9999

100100
#define IO_OUT_OT_ID 2
@@ -103,7 +103,7 @@ static struct uac1_output_terminal_descriptor io_out_ot_desc = {
103103
.bDescriptorType = USB_DT_CS_INTERFACE,
104104
.bDescriptorSubtype = UAC_OUTPUT_TERMINAL,
105105
.bTerminalID = IO_OUT_OT_ID,
106-
.wTerminalType = UAC_OUTPUT_TERMINAL_SPEAKER,
106+
.wTerminalType = cpu_to_le16(UAC_OUTPUT_TERMINAL_SPEAKER),
107107
.bAssocTerminal = 0,
108108
.bSourceID = USB_OUT_IT_ID,
109109
};
@@ -114,9 +114,9 @@ static struct uac_input_terminal_descriptor io_in_it_desc = {
114114
.bDescriptorType = USB_DT_CS_INTERFACE,
115115
.bDescriptorSubtype = UAC_INPUT_TERMINAL,
116116
.bTerminalID = IO_IN_IT_ID,
117-
.wTerminalType = UAC_INPUT_TERMINAL_MICROPHONE,
117+
.wTerminalType = cpu_to_le16(UAC_INPUT_TERMINAL_MICROPHONE),
118118
.bAssocTerminal = 0,
119-
.wChannelConfig = 0x3,
119+
.wChannelConfig = cpu_to_le16(0x3),
120120
};
121121

122122
#define USB_IN_OT_ID 4
@@ -125,7 +125,7 @@ static struct uac1_output_terminal_descriptor usb_in_ot_desc = {
125125
.bDescriptorType = USB_DT_CS_INTERFACE,
126126
.bDescriptorSubtype = UAC_OUTPUT_TERMINAL,
127127
.bTerminalID = USB_IN_OT_ID,
128-
.wTerminalType = UAC_TERMINAL_STREAMING,
128+
.wTerminalType = cpu_to_le16(UAC_TERMINAL_STREAMING),
129129
.bAssocTerminal = 0,
130130
.bSourceID = IO_IN_IT_ID,
131131
};
@@ -174,7 +174,7 @@ static struct uac1_as_header_descriptor as_out_header_desc = {
174174
.bDescriptorSubtype = UAC_AS_GENERAL,
175175
.bTerminalLink = USB_OUT_IT_ID,
176176
.bDelay = 1,
177-
.wFormatTag = UAC_FORMAT_TYPE_I_PCM,
177+
.wFormatTag = cpu_to_le16(UAC_FORMAT_TYPE_I_PCM),
178178
};
179179

180180
static struct uac1_as_header_descriptor as_in_header_desc = {
@@ -183,7 +183,7 @@ static struct uac1_as_header_descriptor as_in_header_desc = {
183183
.bDescriptorSubtype = UAC_AS_GENERAL,
184184
.bTerminalLink = USB_IN_OT_ID,
185185
.bDelay = 1,
186-
.wFormatTag = UAC_FORMAT_TYPE_I_PCM,
186+
.wFormatTag = cpu_to_le16(UAC_FORMAT_TYPE_I_PCM),
187187
};
188188

189189
DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(1);
@@ -605,8 +605,8 @@ static int f_audio_bind(struct usb_configuration *c, struct usb_function *f)
605605
if (status)
606606
goto fail;
607607

608-
audio->out_ep_maxpsize = as_out_ep_desc.wMaxPacketSize;
609-
audio->in_ep_maxpsize = as_in_ep_desc.wMaxPacketSize;
608+
audio->out_ep_maxpsize = le16_to_cpu(as_out_ep_desc.wMaxPacketSize);
609+
audio->in_ep_maxpsize = le16_to_cpu(as_in_ep_desc.wMaxPacketSize);
610610
audio->params.c_chmask = audio_opts->c_chmask;
611611
audio->params.c_srate = audio_opts->c_srate;
612612
audio->params.c_ssize = audio_opts->c_ssize;

0 commit comments

Comments
 (0)