Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1824576imm; Mon, 3 Sep 2018 10:23:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZj+TYCl4gBD6CL4+hQJJXa89ja2zcnR0bwjMiY7PXmg65Z0m8KL6305488OhArEbOT34qT X-Received: by 2002:aa7:860b:: with SMTP id p11-v6mr30440024pfn.247.1535995412494; Mon, 03 Sep 2018 10:23:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535995412; cv=none; d=google.com; s=arc-20160816; b=GACThpfapvz5bnGCggAV40mdPne/ULNHj5Rm/DM+tMhOb/4W6+dE7oTJQz1K1suM2R 1aNwdrDQFOGg5noBFxqN3xpED2XNaUXfn+iK47+0LqGY/qVa/LfHwRag0idjs15ED7ZN n75xmlq4zbzdNSzTFVs03xDP9k7qguiNNwzYtmiGEXj2ouhekJnabc1wycV0cWHBpf7l FKeq2yRNuAMcjLIbiMKYtKo6H7i6+IpDFdqFCBW0GlpVorpqUS2eOqhtXeMU+Ljo9Xij jHFP8mY4XlhYzdy19NcFyqkB0punWzh0bsafPR4Dlz6Kq2Wwnjh6/Y7GLD3061oLbmqF VvGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=+DcTL/xVJYAQPcbSs8UFcRTbAY09i7yHFBU9TPn3Xmw=; b=PE+xiRodgS3xe4ht6WpRg3zMbjUGjHjXM5liUFiHh4ciGORnBGymf3/BIVNNl4iNnn jTE86pVf6ixeZKZnoMln6GJg6C05LWbaFSiNega4X0s+EXeRuyMcEf10bf1VokcTsBKL HrFyR8AeAuoN+wan5o/zUeaF+bGqT9Hr3OFhAy2lazHPLjtZfqiYT3YJgaco7YqhGFau xjmYy4LW6IyM7xDq5VNf5rOeYvtVTBE5W+ZF0oYbmuLWPxSUIZBQivDm82+MhGolT6Qn L9YmTPEh5rRBm8r83YFQoDhFGYk7JRW3SJsuS7z+AXpn8RiCdacBBi6st8e5KGnKdgc3 PB7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si17645511plz.220.2018.09.03.10.23.17; Mon, 03 Sep 2018 10:23:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730330AbeICVj1 (ORCPT + 99 others); Mon, 3 Sep 2018 17:39:27 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:43044 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728154AbeICVj0 (ORCPT ); Mon, 3 Sep 2018 17:39:26 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DB1DFD13; Mon, 3 Sep 2018 17:18:21 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eugeniu Rosca , Ruslan Bilovol , Felipe Balbi , Sasha Levin Subject: [PATCH 4.14 026/165] usb: gadget: f_uac2: fix endianness of struct cntrl_*_lay3 Date: Mon, 3 Sep 2018 18:55:12 +0200 Message-Id: <20180903165656.361795402@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165655.003605184@linuxfoundation.org> References: <20180903165655.003605184@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eugeniu Rosca [ Upstream commit eec24f2a0d4dc3b1d95a3ccd2feb523ede3ba775 ] 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 14e1d56cbea6 ("usb: gadget: f_uac2: endianness fixes.") commit 42370b821168 ("usb: gadget: f_uac1: endianness fixes.") commit 63afd5cc7877 ("USB: chaoskey: fix Alea quirk on big-endian hosts") commit 74098c4ac782 ("usb: gadget: acm: fix endianness in notifications") commit cdd7928df0d2 ("ACM gadget: fix endianness in notifications") commit 323ece54e076 ("cdc-wdm: fix endianness bug in debug statements") commit e102609f1072 ("usb: gadget: uvc: Fix endianness mismatches") list goes on Fixes: 132fcb460839 ("usb: gadget: Add Audio Class 2.0 Driver") Signed-off-by: Eugeniu Rosca Reviewed-by: Ruslan Bilovol Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/f_uac2.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c @@ -442,14 +442,14 @@ static struct usb_descriptor_header *hs_ }; struct cntrl_cur_lay3 { - __u32 dCUR; + __le32 dCUR; }; struct cntrl_range_lay3 { - __u16 wNumSubRanges; - __u32 dMIN; - __u32 dMAX; - __u32 dRES; + __le16 wNumSubRanges; + __le32 dMIN; + __le32 dMAX; + __le32 dRES; } __packed; static void set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts, @@ -707,9 +707,9 @@ in_rq_cur(struct usb_function *fn, const memset(&c, 0, sizeof(struct cntrl_cur_lay3)); if (entity_id == USB_IN_CLK_ID) - c.dCUR = p_srate; + c.dCUR = cpu_to_le32(p_srate); else if (entity_id == USB_OUT_CLK_ID) - c.dCUR = c_srate; + c.dCUR = cpu_to_le32(c_srate); value = min_t(unsigned, w_length, sizeof c); memcpy(req->buf, &c, value); @@ -746,15 +746,15 @@ in_rq_range(struct usb_function *fn, con if (control_selector == UAC2_CS_CONTROL_SAM_FREQ) { if (entity_id == USB_IN_CLK_ID) - r.dMIN = p_srate; + r.dMIN = cpu_to_le32(p_srate); else if (entity_id == USB_OUT_CLK_ID) - r.dMIN = c_srate; + r.dMIN = cpu_to_le32(c_srate); else return -EOPNOTSUPP; r.dMAX = r.dMIN; r.dRES = 0; - r.wNumSubRanges = 1; + r.wNumSubRanges = cpu_to_le16(1); value = min_t(unsigned, w_length, sizeof r); memcpy(req->buf, &r, value);