From patchwork Fri Feb 19 21:40:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 102725 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp40491lbl; Fri, 19 Feb 2016 13:41:56 -0800 (PST) X-Received: by 10.98.65.14 with SMTP id o14mr21085840pfa.151.1455918116099; Fri, 19 Feb 2016 13:41:56 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z89si18802010pfa.143.2016.02.19.13.41.55; Fri, 19 Feb 2016 13:41:56 -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 S1428086AbcBSVlx (ORCPT + 30 others); Fri, 19 Feb 2016 16:41:53 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:50542 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424914AbcBSVlu (ORCPT ); Fri, 19 Feb 2016 16:41:50 -0500 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue001) with ESMTPA (Nemesis) id 0LcK74-1a4jVT2Zfy-00jq0X; Fri, 19 Feb 2016 22:41:09 +0100 From: Arnd Bergmann To: Felipe Balbi , Greg Kroah-Hartman Cc: linux-arm-kernel@lists.infradead.org, Arnd Bergmann , Douglas Anderson , Heiko Stuebner , Stefan Wahren , Felipe Balbi , Heikki Krogerus , Mathias Nyman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: move usb_calc_bus_time into common code Date: Fri, 19 Feb 2016 22:40:28 +0100 Message-Id: <1455918064-410571-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:30F233rraDn+n2LYmjgoIIYy6uUvG7dBkxf/Cf3ZLwCPzwF9dIC 3MtIZumgt/5kHSvenSPQhRqYlPLxxzMvMH/iylaYWTCA7Pj2lisXuQmLOZVq4XgzhpOuXOw bEva3pUj6gT4CqLkVE9HKhKTjruiBjtWWle34qqd+PgvmU2OjchdZW15KqW6uOZURVfo0PY L67kdWoqCcWsXzim0jCFQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:KFnBcLGc/cc=:9UgcxVUQ4y2VWJ71dIMxrP NJOlXbKlzD4Zvhccrc6i+NoeRrvA1Jb3NKzbxTsrDVoHUELsvHKGLXRHebJ2Jui5p51py4IO6 xtMcQJXMA4r5GTORygCqJgvuRTjaoYSvE7HYkGgDb42k/so7DE1uOtevmttfJJwVA3v+7QBzm XHNd7XelsD33UJeOxYcuql5/SvB/pJFt2yDDtBk0LURQ/y9gzm4g/w5JfWITYAt0IfPVL/+i1 Wm845qSUuHOZ/n/6Bppev0LSLQMkYV3b1kBdstTg64i2QNsCd5LBiOakwXrvCD0cApkwrMs9I JCv7EndPmuCa4+sCyk43pqUyYNiHunqAK2JjFOKUz3S+GHR5G4wGDU6gvA/PYHS8uNp7iLOOA /f0Uy8/uDV/ergSYb9ETBEAZaqw1zIbQDouL7LcF/VkCgxKgqZpVM1H6k8YQzZ7zp8C7rDrQ3 Iui92qlHHytPSuAW0yxKjoEilj8ohL1UO9dyRusRexLp1VmcWOa6MFLC+pya3ZjEyz+P5+C5G 2+BwX+WKJN4/CtWw5VRBKp0ErmGf2EKKyHtFmpj1P5jfsz9/DKZ3JmEfP1A6HFiuZf9bqQdAW 4M7U17VB+oDt2vo1hrG5Xk3t+tYH+PIRsSkBV5DzglBxUhPd+SewnQdd2mDJ+CdegbwXahCCk VPEK51JQI+WYRJWRGfQt/bJEG7wQza9zagUeZTKOAyqImZS39G5LPReBlJECTpfRoJ30= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The dwc2 dual-role USB controller driver has started calling usb_calc_bus_time, and does so regardless of whether it is being built as a host controller or gadget. In case all USB host support is disabled (CONFIG_USB=n), this now causes a link error: ERROR: "usb_calc_bus_time" [drivers/usb/dwc2/dwc2.ko] undefined! Moving the function that is called from the USB HCD specific code into the shared USB code avoids this problem. Signed-off-by: Arnd Bergmann Fixes: f889904b25df ("usb: dwc2: host: Properly set even/odd frame") --- I have no idea if this is the correct solution for the problem, it just seemed like the easiest way to avoid the build failure. drivers/usb/common/common.c | 51 +++++++++++++++++++++++++++++++++++++++++++++ drivers/usb/core/hcd.c | 51 --------------------------------------------- 2 files changed, 51 insertions(+), 51 deletions(-) -- 2.7.0 diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index e3d01619d6b3..654fd37f89d5 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c @@ -17,6 +17,7 @@ #include #include #include +#include #include const char *usb_otg_state_string(enum usb_otg_state state) @@ -126,6 +127,56 @@ enum usb_dr_mode usb_get_dr_mode(struct device *dev) } EXPORT_SYMBOL_GPL(usb_get_dr_mode); +/*-------------------------------------------------------------------------*/ + +/** + * usb_calc_bus_time - approximate periodic transaction time in nanoseconds + * @speed: from dev->speed; USB_SPEED_{LOW,FULL,HIGH} + * @is_input: true iff the transaction sends data to the host + * @isoc: true for isochronous transactions, false for interrupt ones + * @bytecount: how many bytes in the transaction. + * + * Return: Approximate bus time in nanoseconds for a periodic transaction. + * + * Note: + * See USB 2.0 spec section 5.11.3; only periodic transfers need to be + * scheduled in software, this function is only used for such scheduling. + */ +long usb_calc_bus_time (int speed, int is_input, int isoc, int bytecount) +{ + unsigned long tmp; + + switch (speed) { + case USB_SPEED_LOW: /* INTR only */ + if (is_input) { + tmp = (67667L * (31L + 10L * BitTime (bytecount))) / 1000L; + return 64060L + (2 * BW_HUB_LS_SETUP) + BW_HOST_DELAY + tmp; + } else { + tmp = (66700L * (31L + 10L * BitTime (bytecount))) / 1000L; + return 64107L + (2 * BW_HUB_LS_SETUP) + BW_HOST_DELAY + tmp; + } + case USB_SPEED_FULL: /* ISOC or INTR */ + if (isoc) { + tmp = (8354L * (31L + 10L * BitTime (bytecount))) / 1000L; + return ((is_input) ? 7268L : 6265L) + BW_HOST_DELAY + tmp; + } else { + tmp = (8354L * (31L + 10L * BitTime (bytecount))) / 1000L; + return 9107L + BW_HOST_DELAY + tmp; + } + case USB_SPEED_HIGH: /* ISOC or INTR */ + /* FIXME adjust for input vs output */ + if (isoc) + tmp = HS_NSECS_ISO (bytecount); + else + tmp = HS_NSECS (bytecount); + return tmp; + default: + pr_debug ("%s: bogus device speed!\n", __func__); + return -1; + } +} +EXPORT_SYMBOL_GPL(usb_calc_bus_time); + #ifdef CONFIG_OF /** * of_usb_get_dr_mode_by_phy - Get dual role mode for the controller device diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 0b8a91004737..cbaa78043793 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -1170,57 +1170,6 @@ EXPORT_SYMBOL_GPL(usb_hcd_end_port_resume); /*-------------------------------------------------------------------------*/ -/** - * usb_calc_bus_time - approximate periodic transaction time in nanoseconds - * @speed: from dev->speed; USB_SPEED_{LOW,FULL,HIGH} - * @is_input: true iff the transaction sends data to the host - * @isoc: true for isochronous transactions, false for interrupt ones - * @bytecount: how many bytes in the transaction. - * - * Return: Approximate bus time in nanoseconds for a periodic transaction. - * - * Note: - * See USB 2.0 spec section 5.11.3; only periodic transfers need to be - * scheduled in software, this function is only used for such scheduling. - */ -long usb_calc_bus_time (int speed, int is_input, int isoc, int bytecount) -{ - unsigned long tmp; - - switch (speed) { - case USB_SPEED_LOW: /* INTR only */ - if (is_input) { - tmp = (67667L * (31L + 10L * BitTime (bytecount))) / 1000L; - return 64060L + (2 * BW_HUB_LS_SETUP) + BW_HOST_DELAY + tmp; - } else { - tmp = (66700L * (31L + 10L * BitTime (bytecount))) / 1000L; - return 64107L + (2 * BW_HUB_LS_SETUP) + BW_HOST_DELAY + tmp; - } - case USB_SPEED_FULL: /* ISOC or INTR */ - if (isoc) { - tmp = (8354L * (31L + 10L * BitTime (bytecount))) / 1000L; - return ((is_input) ? 7268L : 6265L) + BW_HOST_DELAY + tmp; - } else { - tmp = (8354L * (31L + 10L * BitTime (bytecount))) / 1000L; - return 9107L + BW_HOST_DELAY + tmp; - } - case USB_SPEED_HIGH: /* ISOC or INTR */ - /* FIXME adjust for input vs output */ - if (isoc) - tmp = HS_NSECS_ISO (bytecount); - else - tmp = HS_NSECS (bytecount); - return tmp; - default: - pr_debug ("%s: bogus device speed!\n", usbcore_name); - return -1; - } -} -EXPORT_SYMBOL_GPL(usb_calc_bus_time); - - -/*-------------------------------------------------------------------------*/ - /* * Generic HC operations. */