Skip to content

Commit eec24f2

Browse files
eroscaFelipe Balbi
authored andcommitted
usb: gadget: f_uac2: fix endianness of 'struct cntrl_*_lay3'
The list [1] of commits doing endianness fixes in USB subsystem is long due to below quote from USB spec Revision 2.0 from April 27, 2000: ------------ 8.1 Byte/Bit Ordering Multiple byte fields in standard descriptors, requests, and responses are interpreted as and moved over the bus in little-endian order, i.e. LSB to MSB. ------------ This commit belongs to the same family. [1] Example of endianness fixes in USB subsystem: commit 14e1d56 ("usb: gadget: f_uac2: endianness fixes.") commit 42370b8 ("usb: gadget: f_uac1: endianness fixes.") commit 63afd5c ("USB: chaoskey: fix Alea quirk on big-endian hosts") commit 74098c4 ("usb: gadget: acm: fix endianness in notifications") commit cdd7928 ("ACM gadget: fix endianness in notifications") commit 323ece5 ("cdc-wdm: fix endianness bug in debug statements") commit e102609 ("usb: gadget: uvc: Fix endianness mismatches") list goes on Fixes: 132fcb4 ("usb: gadget: Add Audio Class 2.0 Driver") Signed-off-by: Eugeniu Rosca <[email protected]> Reviewed-by: Ruslan Bilovol <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent 1e111e8 commit eec24f2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/usb/gadget/function/f_uac2.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -438,14 +438,14 @@ static struct usb_descriptor_header *hs_audio_desc[] = {
438438
};
439439

440440
struct cntrl_cur_lay3 {
441-
__u32 dCUR;
441+
__le32 dCUR;
442442
};
443443

444444
struct cntrl_range_lay3 {
445-
__u16 wNumSubRanges;
446-
__u32 dMIN;
447-
__u32 dMAX;
448-
__u32 dRES;
445+
__le16 wNumSubRanges;
446+
__le32 dMIN;
447+
__le32 dMAX;
448+
__le32 dRES;
449449
} __packed;
450450

451451
static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts,
@@ -703,9 +703,9 @@ in_rq_cur(struct usb_function *fn, const struct usb_ctrlrequest *cr)
703703
memset(&c, 0, sizeof(struct cntrl_cur_lay3));
704704

705705
if (entity_id == USB_IN_CLK_ID)
706-
c.dCUR = p_srate;
706+
c.dCUR = cpu_to_le32(p_srate);
707707
else if (entity_id == USB_OUT_CLK_ID)
708-
c.dCUR = c_srate;
708+
c.dCUR = cpu_to_le32(c_srate);
709709

710710
value = min_t(unsigned, w_length, sizeof c);
711711
memcpy(req->buf, &c, value);
@@ -742,15 +742,15 @@ in_rq_range(struct usb_function *fn, const struct usb_ctrlrequest *cr)
742742

743743
if (control_selector == UAC2_CS_CONTROL_SAM_FREQ) {
744744
if (entity_id == USB_IN_CLK_ID)
745-
r.dMIN = p_srate;
745+
r.dMIN = cpu_to_le32(p_srate);
746746
else if (entity_id == USB_OUT_CLK_ID)
747-
r.dMIN = c_srate;
747+
r.dMIN = cpu_to_le32(c_srate);
748748
else
749749
return -EOPNOTSUPP;
750750

751751
r.dMAX = r.dMIN;
752752
r.dRES = 0;
753-
r.wNumSubRanges = 1;
753+
r.wNumSubRanges = cpu_to_le16(1);
754754

755755
value = min_t(unsigned, w_length, sizeof r);
756756
memcpy(req->buf, &r, value);

0 commit comments

Comments
 (0)