Received: by 10.223.185.116 with SMTP id b49csp821685wrg; Sat, 10 Feb 2018 21:11:05 -0800 (PST) X-Google-Smtp-Source: AH8x227cYHIpkOo9uLX55+4FQNssYDBqLT68ziE8di4EgLKOoJ0sARUEENNqaYOMd3EFAHjbHQdU X-Received: by 10.99.109.70 with SMTP id i67mr1300866pgc.190.1518325865037; Sat, 10 Feb 2018 21:11:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518325864; cv=none; d=google.com; s=arc-20160816; b=eZvUZX0DHk+b75BhsUuF6mWhNBO8I1xKC8BmnV2Ft5+cDUrjz08vvuJXExjEImzTQ+ BwWyLsSNSsPKGDuA9fObvB4nGFQot0amjAs+EMpyoF48HQNNc9kyRaCDD+9ciDUDc9zx W6w6TVmrqDasx+Y9NpoUGy70AHOzTO5eGoEOmb44wdJEGabeDZjASDtSEU18X39acNEU mZc25WujCpEtedMByLKF5XyN+KD1B+FBclaHXOkq8lkSbKu9bZN+wUmSNgoAsGk4sNEI V9BBU++y+l7Dmg7HVM8/Hk/uxBKuSJzuD1oh55X/em3k7/7SspVwzFsCVUE8EXk4IlAh ryCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=aG6/P4xuObV5J5Q5Ucx49nNizrmmI2h3RPv34sOoSvU=; b=YUqx89MCLPratGJiWRy2i1RCxE7jsiA/ntOGfcSQJgn9iJzuKygNpdWP6aIolqN4em dF2Kr1IldYuKvxETast4oUkrD3xWWdm288f6wWyH46LGswoI8nikksd9fPICUwt5rlfD biFQV4FzrzNtAhloUrODqexVtpK+RbnEkmn7kpqtBZotX0nbjcAO1mUdiQ3qlHOwwSH9 3N/ydAjeauezp3XVo3zEtNDsm500f8bqWM1d2vmQ6Exoj3T0JfSg/PZl9UZcIQ+D79cQ ZEtODD+onOhoaj2Dcpwya0vYUBq396VSucOF4y0jhjgX2m/2t0TKDIlaBFCean9A9GE8 sshg== 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 d21-v6si3956391pll.268.2018.02.10.21.10.51; Sat, 10 Feb 2018 21:11:04 -0800 (PST) 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 S1753910AbeBKFJb (ORCPT + 99 others); Sun, 11 Feb 2018 00:09:31 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41441 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752648AbeBKEdm (ORCPT ); Sat, 10 Feb 2018 23:33:42 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ekjKc-0002hG-Sy; Sun, 11 Feb 2018 04:33:39 +0000 Received: from ben by deadeye with local (Exim 4.90) (envelope-from ) id 1ekjKY-0004XE-TM; Sun, 11 Feb 2018 04:33:34 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Felipe Balbi" Date: Sun, 11 Feb 2018 04:20:06 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.2 72/79] usb: add helper to extract bits 12:11 of wMaxPacketSize In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.2.99-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Felipe Balbi commit 541b6fe63023f3059cf85d47ff2767a3e42a8e44 upstream. According to USB Specification 2.0 table 9-4, wMaxPacketSize is a bitfield. Endpoint's maxpacket is laid out in bits 10:0. For high-speed, high-bandwidth isochronous endpoints, bits 12:11 contain a multiplier to tell us how many transactions we want to try per uframe. This means that if we want an isochronous endpoint to issue 3 transfers of 1024 bytes per uframe, wMaxPacketSize should contain the value: 1024 | (2 << 11) or 5120 (0x1400). In order to make Host and Peripheral controller drivers' life easier, we're adding a helper which returns bits 12:11. Note that no care is made WRT to checking endpoint type and gadget's speed. That's left for drivers to handle. Signed-off-by: Felipe Balbi [bwh: Backported to 3.2: adjust filename, context] Signed-off-by: Ben Hutchings --- include/linux/usb/ch9.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h @@ -390,6 +390,11 @@ struct usb_endpoint_descriptor { #define USB_ENDPOINT_XFER_INT 3 #define USB_ENDPOINT_MAX_ADJUSTABLE 0x80 +#define USB_EP_MAXP_MULT_SHIFT 11 +#define USB_EP_MAXP_MULT_MASK (3 << USB_EP_MAXP_MULT_SHIFT) +#define USB_EP_MAXP_MULT(m) \ + (((m) & USB_EP_MAXP_MULT_MASK) >> USB_EP_MAXP_MULT_SHIFT) + #define USB_ENDPOINT_SYNCTYPE 0x0c #define USB_ENDPOINT_SYNC_NONE (0 << 2) #define USB_ENDPOINT_SYNC_ASYNC (1 << 2) @@ -592,6 +597,20 @@ static inline int usb_endpoint_maxp(cons return __le16_to_cpu(epd->wMaxPacketSize); } +/** + * usb_endpoint_maxp_mult - get endpoint's transactional opportunities + * @epd: endpoint to be checked + * + * Return @epd's wMaxPacketSize[12:11] + 1 + */ +static inline int +usb_endpoint_maxp_mult(const struct usb_endpoint_descriptor *epd) +{ + int maxp = __le16_to_cpu(epd->wMaxPacketSize); + + return USB_EP_MAXP_MULT(maxp) + 1; +} + /*-------------------------------------------------------------------------*/ /* USB_DT_SS_ENDPOINT_COMP: SuperSpeed Endpoint Companion descriptor */