From patchwork Wed Aug 29 17:00:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grigor Tovmasyan X-Patchwork-Id: 10580655 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86FB65A4 for ; Wed, 29 Aug 2018 17:00:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74EC42B6FD for ; Wed, 29 Aug 2018 17:00:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6984E2B71A; Wed, 29 Aug 2018 17:00:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 200952B6FD for ; Wed, 29 Aug 2018 17:00:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727856AbeH2U6C (ORCPT ); Wed, 29 Aug 2018 16:58:02 -0400 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9]:38470 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727245AbeH2U6C (ORCPT ); Wed, 29 Aug 2018 16:58:02 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 2870724E0609; Wed, 29 Aug 2018 10:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1535562013; bh=wzIPyGGg+FNPfTMcM4jgSrue+K7D3cMhQAjTqd0Z5UI=; h=Date:In-Reply-To:References:From:Subject:To:CC:From; b=O785GXiteqJfJDI58RVoIhz/sWcCOL/E4l+t1ceSNQR2j4TD/iO3kzg9/GPIrPDPH wkQzE0ohpOKJ+a9XM+zEJqAcHCJ3ApP3MYMXzZYYT8Qw/RisYTH6w1kUBGgYPv0JD3 noB5b+nPKb1+ZiU4HAnaXB15Bpu01OHC1oAV4ywNSw2XxpXU63dv+0SEapgBGnxgm1 46if3gonIdZ1S27pWqp29DYkQBV/14O7GkQy62NyLWmk+lpz93n/M6/FqqDeWTMB7N GlyeuHOBrO6habdluFsnzHpFHp9Xu8pvyImSIeD4gAzmTktnViIdXCOkkyT0mu7A5y sxFlyIWJ7Io6A== Received: from US01WEHTC3.internal.synopsys.com (us01wehtc3.internal.synopsys.com [10.15.84.232]) by mailhost.synopsys.com (Postfix) with ESMTP id 15CEC5876; Wed, 29 Aug 2018 10:00:13 -0700 (PDT) Received: from US01WEHTC2.internal.synopsys.com (10.12.239.237) by US01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 10:00:12 -0700 Received: from tovmasya (10.13.184.20) by US01WEHTC2.internal.synopsys.com (10.12.239.238) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 10:00:08 -0700 Received: by tovmasya (sSMTP sendmail emulation); Wed, 29 Aug 2018 21:00:03 +0400 Date: Wed, 29 Aug 2018 21:00:03 +0400 Message-ID: <9c2b9d92d4457b3a34a981c5f2dd3e7dad0f871a.1535561828.git.tovmasya@synopsys.com> In-Reply-To: References: From: Grigor Tovmasyan Subject: [PATCH 3/9] usb: dwc2: Add dwc2_gadget_dec_frame_num_by_one() function To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , CC: John Youn , Grigor Tovmasyan MIME-Version: 1.0 X-Originating-IP: [10.13.184.20] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Added dwc2_gadget_dec_frame_num_by_one() function in gadget.c. This function will be used to calculate descriptor frame number field value. For service interval mode frame number in descriptor should point to last (u)frame in the interval. Signed-off-by: Grigor Tovmasyan --- drivers/usb/dwc2/gadget.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index a3129f1e87a7..58903b5c22a4 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -122,6 +122,24 @@ static inline void dwc2_gadget_incr_frame_num(struct dwc2_hsotg_ep *hs_ep) } } +/** + * dwc2_gadget_dec_frame_num_by_one - Decrements the targeted frame number + * by one. + * @hs_ep: The endpoint. + * + * This function used in service interval based scheduling flow to calculate + * descriptor frame number filed value. For service interval mode frame + * number in descriptor should point to last (u)frame in the interval. + * + */ +static inline void dwc2_gadget_dec_frame_num_by_one(struct dwc2_hsotg_ep *hs_ep) +{ + if (hs_ep->target_frame) + hs_ep->target_frame -= 1; + else + hs_ep->target_frame = DSTS_SOFFN_LIMIT; +} + /** * dwc2_hsotg_en_gsint - enable one or more of the general interrupt * @hsotg: The device state