From patchwork Tue Apr 16 10:58:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: manjunath.goudar@linaro.org X-Patchwork-Id: 16159 Return-Path: X-Original-To: linaro@staging.patches.linaro.org Delivered-To: linaro@staging.patches.linaro.org Received: from mail-qc0-f198.google.com (mail-qc0-f198.google.com [209.85.216.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F2AB723A3E for ; Tue, 16 Apr 2013 11:00:22 +0000 (UTC) Received: by mail-qc0-f198.google.com with SMTP id v20sf483962qcm.9 for ; Tue, 16 Apr 2013 03:59:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=f5iouaFvzpmjtU4GbWcGERAND9WnV0bkErbRiD506wE=; b=GwlyDb2IhQe3p19zpIuyJlEj9TilQJGF9kjZ1uCmPSxXemSMLH4WuEYcGv3ipcqXRk 2/ljp7a5p+LLs2Ho5yP1GHvuN5N0+GmyPMEmAlZcN6YYCeokRwT88oSd6RKKNS8S/4Uz EewljQyfneumo2aAuS5g4IqlOmDpPtUf/Ygs3p8ZiBvyRjz65lozPiIkOzKjQGMU/O99 krFsVA1UkOOIZGBUsDdVxaQ08jo2hdWlYeHPKToDKpEQv61OL2G+QKAA3fHmVf7t4JmD +lJrlhYaNp9vze849FMwgDtMT7lWxAeTFiUjHTweRM9DfTSXBV8w0izK/gw2tzTbzHqO QiTA== X-Received: by 10.224.18.132 with SMTP id w4mr1464478qaa.1.1366109990372; Tue, 16 Apr 2013 03:59:50 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.118.161 with SMTP id kn1ls198225qeb.33.gmail; Tue, 16 Apr 2013 03:59:50 -0700 (PDT) X-Received: by 10.220.39.69 with SMTP id f5mr1101128vce.45.1366109990083; Tue, 16 Apr 2013 03:59:50 -0700 (PDT) Received: from mail-vb0-x232.google.com (mail-vb0-x232.google.com [2607:f8b0:400c:c02::232]) by mx.google.com with ESMTPS id da5si854640vdc.102.2013.04.16.03.59.50 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Apr 2013 03:59:50 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::232 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::232; Received: by mail-vb0-f50.google.com with SMTP id w15so250641vbb.23 for ; Tue, 16 Apr 2013 03:59:49 -0700 (PDT) X-Received: by 10.52.71.4 with SMTP id q4mr968112vdu.8.1366109989805; Tue, 16 Apr 2013 03:59:49 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp18602veb; Tue, 16 Apr 2013 03:59:49 -0700 (PDT) X-Received: by 10.66.149.227 with SMTP id ud3mr3167826pab.33.1366109988507; Tue, 16 Apr 2013 03:59:48 -0700 (PDT) Received: from mail-pd0-f179.google.com (mail-pd0-f179.google.com [209.85.192.179]) by mx.google.com with ESMTPS id tz4si2294667pab.149.2013.04.16.03.59.48 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Apr 2013 03:59:48 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.179 is neither permitted nor denied by best guess record for domain of manjunath.goudar@linaro.org) client-ip=209.85.192.179; Received: by mail-pd0-f179.google.com with SMTP id x11so227944pdj.38 for ; Tue, 16 Apr 2013 03:59:48 -0700 (PDT) X-Received: by 10.68.13.135 with SMTP id h7mr2477904pbc.113.1366109988030; Tue, 16 Apr 2013 03:59:48 -0700 (PDT) Received: from manjunath-Latitude-E6420.LGE.NET ([203.247.149.152]) by mx.google.com with ESMTPS id br2sm1615695pbc.46.2013.04.16.03.59.43 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Apr 2013 03:59:47 -0700 (PDT) From: manjunath.goudar@linaro.org To: manjunath.goudar@linaro.org Cc: arnd@linaro.org, patches@linaro.org, Arnd Bergmann , Greg KH , Alan Stern , linux-usb@vger.kernel.org Subject: [RFC PATCH 2/2] USB: OHCI: make ohci-pci a separate driver Date: Tue, 16 Apr 2013 16:28:43 +0530 Message-Id: <516d2f23.62ae440a.26b5.ffff86f0@mx.google.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1366109923-6498-1-git-send-email-y> References: <1366109923-6498-1-git-send-email-y> X-Gm-Message-State: ALoCoQlDJqiv/D8kQDfaLF1q+AlnlaxUDjvvvVtAZ/i+dPp/IzXJc0LROW4uNSMiWD4bJY0/lQ1f X-Original-Sender: manjunath.goudar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::232 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Manjunath Goudar This patch splits the PCI portion of ohci-hcd out into its own separate driver module, called ohci-pci. Consistently with the current practice, the decision whether to build this module is not user-configurable. If OHCI_PCI are enabled then the module will be built, always. Signed-off-by: Manjunath Goudar Cc: Arnd Bergmann Cc: Greg KH Cc: Alan Stern Cc: linux-usb@vger.kernel.org --- drivers/usb/host/Kconfig | 5 +++ drivers/usb/host/Makefile | 1 + drivers/usb/host/ohci-hcd.c | 31 +-------------- drivers/usb/host/ohci-mem.c | 1 - drivers/usb/host/ohci-pci.c | 93 ++++++++++++++++++------------------------- drivers/usb/host/ohci.h | 6 ++- 6 files changed, 51 insertions(+), 86 deletions(-) diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 7a1a248..8bd53e2 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -333,6 +333,11 @@ config USB_ISP1362_HCD To compile this driver as a module, choose M here: the module will be called isp1362-hcd. +config USB_OHCI_PCI + tristate "OHCI PCI support" + depends on USB_OHCI_HCD + default y + config USB_OHCI_HCD tristate "OHCI HCD support" depends on USB && USB_ARCH_HAS_OHCI diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 58c14c1..39ddcca 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -41,6 +41,7 @@ obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o obj-$(CONFIG_USB_ISP1362_HCD) += isp1362-hcd.o obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o +obj-$(CONFIG_USB_OHCI_PCI) += ohci-pci.o obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o obj-$(CONFIG_USB_FHCI_HCD) += fhci.o obj-$(CONFIG_USB_XHCI_HCD) += xhci-hcd.o diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index fb869fc..3259ff9 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -78,24 +78,13 @@ static const char hcd_name [] = "ohci_hcd"; #include "ohci.h" #include "pci-quirks.h" -static void ohci_dump (struct ohci_hcd *ohci, int verbose); - -#ifdef CONFIG_PCI -static void sb800_prefetch(struct ohci_hcd *ohci, int on); -#else -static inline void sb800_prefetch(struct ohci_hcd *ohci, int on) -{ - return; -} -#endif - +static void ohci_dump(struct ohci_hcd *ohci, int verbose); #include "ohci-hub.c" #include "ohci-dbg.c" #include "ohci-mem.c" #include "ohci-q.c" - /* * On architectures with edge-triggered interrupts we must never return * IRQ_NONE. @@ -585,7 +574,6 @@ int ohci_init(struct ohci_hcd *ohci) return ret; } EXPORT_SYMBOL_GPL(ohci_init); - /*-------------------------------------------------------------------------*/ /* Start an OHCI controller, set the BUS operational @@ -1151,11 +1139,6 @@ MODULE_AUTHOR (DRIVER_AUTHOR); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE ("GPL"); -#ifdef CONFIG_PCI -#include "ohci-pci.c" -#define PCI_DRIVER ohci_pci_driver -#endif - #if defined(CONFIG_ARCH_SA1100) && defined(CONFIG_SA1111) #include "ohci-sa1111.c" #define SA1111_DRIVER ohci_hcd_sa1111_driver @@ -1251,7 +1234,7 @@ MODULE_LICENSE ("GPL"); #define PLATFORM_DRIVER ohci_platform_driver #endif -#if !defined(PCI_DRIVER) && \ +#if !IS_ENABLED(CONFIG_USB_OHCI_PCI) && \ !defined(PLATFORM_DRIVER) && \ !defined(OMAP1_PLATFORM_DRIVER) && \ !defined(OMAP3_PLATFORM_DRIVER) && \ @@ -1326,12 +1309,6 @@ static int __init ohci_hcd_mod_init(void) goto error_sa1111; #endif -#ifdef PCI_DRIVER - retval = pci_register_driver(&PCI_DRIVER); - if (retval < 0) - goto error_pci; -#endif - #ifdef SM501_OHCI_DRIVER retval = platform_driver_register(&SM501_OHCI_DRIVER); if (retval < 0) @@ -1425,10 +1402,6 @@ static int __init ohci_hcd_mod_init(void) platform_driver_unregister(&SM501_OHCI_DRIVER); error_sm501: #endif -#ifdef PCI_DRIVER - pci_unregister_driver(&PCI_DRIVER); - error_pci: -#endif #ifdef SA1111_DRIVER sa1111_driver_unregister(&SA1111_DRIVER); error_sa1111: diff --git a/drivers/usb/host/ohci-mem.c b/drivers/usb/host/ohci-mem.c index 1a4dede..f98727f 100644 --- a/drivers/usb/host/ohci-mem.c +++ b/drivers/usb/host/ohci-mem.c @@ -30,7 +30,6 @@ void ohci_hcd_init (struct ohci_hcd *ohci) INIT_LIST_HEAD (&ohci->pending); } EXPORT_SYMBOL_GPL(ohci_hcd_init); - /*-------------------------------------------------------------------------*/ static int ohci_mem_init (struct ohci_hcd *ohci) diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index 951514e..f9c6c2e 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c @@ -14,12 +14,19 @@ * This file is licenced under the GPL. */ -#ifndef CONFIG_PCI -#error "This file is PCI bus glue. CONFIG_PCI must be defined." -#endif - -#include #include +#include +#include +#include +#include +#include + +#include "ohci.h" +#include "pci-quirks.h" + +#define DRIVER_DESC "OHCI PCI platform driver" + +static const char hcd_name[] = "ohci-pci"; /*-------------------------------------------------------------------------*/ @@ -175,7 +182,7 @@ static int ohci_quirk_amd700(struct usb_hcd *hcd) return 0; } -static void sb800_prefetch(struct ohci_hcd *ohci, int on) +void sb800_prefetch(struct ohci_hcd *ohci, int on) { struct pci_dev *pdev; u16 misc; @@ -187,6 +194,7 @@ static void sb800_prefetch(struct ohci_hcd *ohci, int on) else pci_write_config_word(pdev, 0x50, misc | 0x0300); } +EXPORT_SYMBOL_GPL(sb800_prefetch); /* List of quirks for OHCI */ static const struct pci_device_id ohci_pci_quirks[] = { @@ -296,60 +304,14 @@ static int ohci_pci_start (struct usb_hcd *hcd) return ret; } +static struct hc_driver __read_mostly ohci_pci_hc_driver; -/*-------------------------------------------------------------------------*/ - -static const struct hc_driver ohci_pci_hc_driver = { - .description = hcd_name, - .product_desc = "OHCI Host Controller", - .hcd_priv_size = sizeof(struct ohci_hcd), - - /* - * generic hardware linkage - */ - .irq = ohci_irq, - .flags = HCD_MEMORY | HCD_USB11, - - /* - * basic lifecycle operations - */ +static const struct ohci_driver_overrides overrides = { + .product_desc = "OHCI PCI host controller", .reset = ohci_pci_reset, .start = ohci_pci_start, - .stop = ohci_stop, - .shutdown = ohci_shutdown, - -#ifdef CONFIG_PM - .pci_suspend = ohci_suspend, - .pci_resume = ohci_resume, -#endif - - /* - * managing i/o requests and associated device resources - */ - .urb_enqueue = ohci_urb_enqueue, - .urb_dequeue = ohci_urb_dequeue, - .endpoint_disable = ohci_endpoint_disable, - - /* - * scheduling support - */ - .get_frame_number = ohci_get_frame, - - /* - * root hub support - */ - .hub_status_data = ohci_hub_status_data, - .hub_control = ohci_hub_control, -#ifdef CONFIG_PM - .bus_suspend = ohci_bus_suspend, - .bus_resume = ohci_bus_resume, -#endif - .start_port_reset = ohci_start_port_reset, }; -/*-------------------------------------------------------------------------*/ - - static const struct pci_device_id pci_ids [] = { { /* handle any USB OHCI controller */ PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_OHCI, ~0), @@ -377,3 +339,24 @@ static struct pci_driver ohci_pci_driver = { }, #endif }; + +static int __init ohci_pci_init(void) +{ + if (usb_disabled()) + return -ENODEV; + + pr_info("%s: " DRIVER_DESC "\n", hcd_name); + + ohci_init_driver(&ohci_pci_hc_driver, &overrides); + return pci_register_driver(&ohci_pci_driver); +} +module_init(ohci_pci_init); + +static void __exit ohci_pci_cleanup(void) +{ + pci_unregister_driver(&ohci_pci_driver); +} +module_exit(ohci_pci_cleanup); + +MODULE_DESCRIPTION(DRIVER_DESC); +MODULE_LICENSE("GPL"); diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index 12c750a..7a775849 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h @@ -440,6 +440,7 @@ static inline int quirk_amdprefetch(struct ohci_hcd *ohci) { return ohci->flags & OHCI_QUIRK_AMD_PREFETCH; } +extern void sb800_prefetch(struct ohci_hcd *ohci, int on); #else static inline int quirk_nec(struct ohci_hcd *ohci) { @@ -457,6 +458,10 @@ static inline int quirk_amdprefetch(struct ohci_hcd *ohci) { return 0; } +static void sb800_prefetch(struct ohci_hcd *ohci, int on) +{ + return; +} #endif /* convert between an hcd pointer and the corresponding ohci_hcd */ @@ -734,7 +739,6 @@ extern int ohci_init (struct ohci_hcd *ohci); extern void ohci_stop (struct usb_hcd *hcd); extern void ohci_hcd_init (struct ohci_hcd *ohci); extern int ohci_run (struct ohci_hcd *ohci); - #if defined(CONFIG_PM) || defined(CONFIG_PCI) extern int ohci_restart (struct ohci_hcd *ohci); #else