Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: OHCI: make ohci-platform a separate driver

This patch splits the ohci-platform code from ohci-hcd out
into its own separate driver module.This work is part of enabling
multi-platform kernels on ARM.

In V2:
-Passed "hcd" argument instead of "ohci" in ohci_setup() because it is
using "struct usb_hcd" argument.
In V3:
-Directly passed "hcd" argument not required to call ohci_to_hcd() function.

Signed-off-by: Manjunath Goudar <manjunath.goudar@linaro.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Manjunath Goudar and committed by
Greg Kroah-Hartman
928fb68e 23735365

+44 -53
+1 -1
drivers/usb/host/Kconfig
··· 481 481 It is needed for low-speed USB 1.0 device support. 482 482 483 483 config USB_OHCI_HCD_PLATFORM 484 - bool "Generic OHCI driver for a platform device" 484 + tristate "Generic OHCI driver for a platform device" 485 485 default n 486 486 ---help--- 487 487 Adds an OHCI host driver for a generic platform device, which
+1
drivers/usb/host/Makefile
··· 40 40 41 41 obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o 42 42 obj-$(CONFIG_USB_OHCI_HCD_PCI) += ohci-pci.o 43 + obj-$(CONFIG_USB_OHCI_HCD_PLATFORM) += ohci-platform.o 43 44 44 45 obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o 45 46 obj-$(CONFIG_USB_FHCI_HCD) += fhci.o
+1 -5
drivers/usb/host/ohci-hcd.c
··· 1262 1262 #define PLATFORM_DRIVER ohci_hcd_tilegx_driver 1263 1263 #endif 1264 1264 1265 - #ifdef CONFIG_USB_OHCI_HCD_PLATFORM 1266 - #include "ohci-platform.c" 1267 - #define PLATFORM_DRIVER ohci_platform_driver 1268 - #endif 1269 - 1270 1265 #if !IS_ENABLED(CONFIG_USB_OHCI_HCD_PCI) && \ 1266 + !IS_ENABLED(CONFIG_USB_OHCI_HCD_PLATFORM) && \ 1271 1267 !defined(PLATFORM_DRIVER) && \ 1272 1268 !defined(OMAP1_PLATFORM_DRIVER) && \ 1273 1269 !defined(OMAP3_PLATFORM_DRIVER) && \
+41 -47
drivers/usb/host/ohci-platform.c
··· 13 13 * 14 14 * Licensed under the GNU/GPL. See COPYING for details. 15 15 */ 16 + 17 + #include <linux/hrtimer.h> 18 + #include <linux/io.h> 19 + #include <linux/kernel.h> 20 + #include <linux/module.h> 16 21 #include <linux/err.h> 17 22 #include <linux/platform_device.h> 18 23 #include <linux/usb/ohci_pdriver.h> 24 + #include <linux/usb.h> 25 + #include <linux/usb/hcd.h> 26 + 27 + #include "ohci.h" 28 + 29 + #define DRIVER_DESC "OHCI generic platform driver" 30 + 31 + static const char hcd_name[] = "ohci-platform"; 19 32 20 33 static int ohci_platform_reset(struct usb_hcd *hcd) 21 34 { 22 35 struct platform_device *pdev = to_platform_device(hcd->self.controller); 23 36 struct usb_ohci_pdata *pdata = pdev->dev.platform_data; 24 37 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 25 - int err; 26 38 27 39 if (pdata->big_endian_desc) 28 40 ohci->flags |= OHCI_QUIRK_BE_DESC; ··· 42 30 ohci->flags |= OHCI_QUIRK_BE_MMIO; 43 31 if (pdata->no_big_frame_no) 44 32 ohci->flags |= OHCI_QUIRK_FRAME_NO; 45 - 46 - ohci_hcd_init(ohci); 47 - 48 33 if (pdata->num_ports) 49 34 ohci->num_ports = pdata->num_ports; 50 35 51 - err = ohci_init(ohci); 52 - 53 - return err; 36 + return ohci_setup(hcd); 54 37 } 55 38 56 - static int ohci_platform_start(struct usb_hcd *hcd) 57 - { 58 - struct ohci_hcd *ohci = hcd_to_ohci(hcd); 59 - int err; 39 + static struct hc_driver __read_mostly ohci_platform_hc_driver; 60 40 61 - err = ohci_run(ohci); 62 - if (err < 0) { 63 - ohci_err(ohci, "can't start\n"); 64 - ohci_stop(hcd); 65 - } 66 - 67 - return err; 68 - } 69 - 70 - static const struct hc_driver ohci_platform_hc_driver = { 71 - .description = hcd_name, 72 - .product_desc = "Generic Platform OHCI Controller", 73 - .hcd_priv_size = sizeof(struct ohci_hcd), 74 - 75 - .irq = ohci_irq, 76 - .flags = HCD_MEMORY | HCD_USB11, 77 - 78 - .reset = ohci_platform_reset, 79 - .start = ohci_platform_start, 80 - .stop = ohci_stop, 81 - .shutdown = ohci_shutdown, 82 - 83 - .urb_enqueue = ohci_urb_enqueue, 84 - .urb_dequeue = ohci_urb_dequeue, 85 - .endpoint_disable = ohci_endpoint_disable, 86 - 87 - .get_frame_number = ohci_get_frame, 88 - 89 - .hub_status_data = ohci_hub_status_data, 90 - .hub_control = ohci_hub_control, 91 - #ifdef CONFIG_PM 92 - .bus_suspend = ohci_bus_suspend, 93 - .bus_resume = ohci_bus_resume, 94 - #endif 95 - 96 - .start_port_reset = ohci_start_port_reset, 41 + static const struct ohci_driver_overrides platform_overrides __initconst = { 42 + .product_desc = "Generic Platform OHCI controller", 43 + .reset = ohci_platform_reset, 97 44 }; 98 45 99 46 static int ohci_platform_probe(struct platform_device *dev) ··· 193 222 .pm = &ohci_platform_pm_ops, 194 223 } 195 224 }; 225 + 226 + static int __init ohci_platform_init(void) 227 + { 228 + if (usb_disabled()) 229 + return -ENODEV; 230 + 231 + pr_info("%s: " DRIVER_DESC "\n", hcd_name); 232 + 233 + ohci_init_driver(&ohci_platform_hc_driver, &platform_overrides); 234 + return platform_driver_register(&ohci_platform_driver); 235 + } 236 + module_init(ohci_platform_init); 237 + 238 + static void __exit ohci_platform_cleanup(void) 239 + { 240 + platform_driver_unregister(&ohci_platform_driver); 241 + } 242 + module_exit(ohci_platform_cleanup); 243 + 244 + MODULE_DESCRIPTION(DRIVER_DESC); 245 + MODULE_AUTHOR("Hauke Mehrtens"); 246 + MODULE_AUTHOR("Alan Stern"); 247 + MODULE_LICENSE("GPL");