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

drivers:usb:fsl:Make fsl ehci drv an independent driver module

Make Freescale EHCI driver an independent entity from ehci-hcd.c.
This involves
- using module_init/module_exit functions
- using overrides structure
- some necessary code cleanup

Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ramneek Mehresh and committed by
Greg Kroah-Hartman
ca07e1c1 909eacd7

+76 -104
+1 -1
drivers/usb/host/Kconfig
··· 137 137 devices only. 138 138 139 139 config USB_EHCI_FSL 140 - bool "Support for Freescale PPC on-chip EHCI USB controller" 140 + tristate "Support for Freescale PPC on-chip EHCI USB controller" 141 141 depends on FSL_SOC 142 142 select USB_EHCI_ROOT_HUB_TT 143 143 select USB_FSL_MPH_DR_OF if OF
+1
drivers/usb/host/Makefile
··· 72 72 obj-$(CONFIG_USB_HWA_HCD) += hwa-hc.o 73 73 obj-$(CONFIG_USB_IMX21_HCD) += imx21-hcd.o 74 74 obj-$(CONFIG_USB_FSL_MPH_DR_OF) += fsl-mph-dr-of.o 75 + obj-$(CONFIG_USB_EHCI_FSL) += ehci-fsl.o 75 76 obj-$(CONFIG_USB_HCD_BCMA) += bcma-hcd.o 76 77 obj-$(CONFIG_USB_HCD_SSB) += ssb-hcd.o 77 78 obj-$(CONFIG_USB_FUSBH200_HCD) += fusbh200-hcd.o
+74 -98
drivers/usb/host/ehci-fsl.c
··· 1 1 /* 2 2 * Copyright 2005-2009 MontaVista Software, Inc. 3 - * Copyright 2008,2012 Freescale Semiconductor, Inc. 3 + * Copyright 2008,2012,2015 Freescale Semiconductor, Inc. 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify it 6 6 * under the terms of the GNU General Public License as published by the ··· 24 24 */ 25 25 26 26 #include <linux/kernel.h> 27 + #include <linux/module.h> 27 28 #include <linux/types.h> 28 29 #include <linux/delay.h> 29 30 #include <linux/pm.h> 30 31 #include <linux/err.h> 32 + #include <linux/usb.h> 33 + #include <linux/usb/ehci_def.h> 34 + #include <linux/usb/hcd.h> 35 + #include <linux/usb/otg.h> 31 36 #include <linux/platform_device.h> 32 37 #include <linux/fsl_devices.h> 33 38 39 + #include "ehci.h" 34 40 #include "ehci-fsl.h" 41 + 42 + #define DRIVER_DESC "Freescale EHCI Host controller driver" 43 + #define DRV_NAME "ehci-fsl" 44 + 45 + static struct hc_driver __read_mostly fsl_ehci_hc_driver; 35 46 36 47 /* configure so an HC device and id are always provided */ 37 48 /* always called with process context; sleeping is OK */ 38 49 39 - /** 40 - * usb_hcd_fsl_probe - initialize FSL-based HCDs 41 - * @drvier: Driver to be used for this HCD 50 + /* 51 + * fsl_ehci_drv_probe - initialize FSL-based HCDs 42 52 * @pdev: USB Host Controller being probed 43 53 * Context: !in_interrupt() 44 54 * 45 55 * Allocates basic resources for this USB host controller. 46 56 * 47 57 */ 48 - static int usb_hcd_fsl_probe(const struct hc_driver *driver, 49 - struct platform_device *pdev) 58 + static int fsl_ehci_drv_probe(struct platform_device *pdev) 50 59 { 51 60 struct fsl_usb2_platform_data *pdata; 52 61 struct usb_hcd *hcd; ··· 95 86 } 96 87 irq = res->start; 97 88 98 - hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); 89 + hcd = usb_create_hcd(&fsl_ehci_hc_driver, &pdev->dev, 90 + dev_name(&pdev->dev)); 99 91 if (!hcd) { 100 92 retval = -ENOMEM; 101 93 goto err1; ··· 167 157 if (pdata->exit) 168 158 pdata->exit(pdev); 169 159 return retval; 170 - } 171 - 172 - /* may be called without controller electrically present */ 173 - /* may be called with controller, bus, and devices active */ 174 - 175 - /** 176 - * usb_hcd_fsl_remove - shutdown processing for FSL-based HCDs 177 - * @dev: USB Host Controller being removed 178 - * Context: !in_interrupt() 179 - * 180 - * Reverses the effect of usb_hcd_fsl_probe(). 181 - * 182 - */ 183 - static void usb_hcd_fsl_remove(struct usb_hcd *hcd, 184 - struct platform_device *pdev) 185 - { 186 - struct fsl_usb2_platform_data *pdata = dev_get_platdata(&pdev->dev); 187 - 188 - if (!IS_ERR_OR_NULL(hcd->usb_phy)) { 189 - otg_set_host(hcd->usb_phy->otg, NULL); 190 - usb_put_phy(hcd->usb_phy); 191 - } 192 - 193 - usb_remove_hcd(hcd); 194 - 195 - /* 196 - * do platform specific un-initialization: 197 - * release iomux pins, disable clock, etc. 198 - */ 199 - if (pdata->exit) 200 - pdata->exit(pdev); 201 - usb_put_hcd(hcd); 202 160 } 203 161 204 162 static int ehci_fsl_setup_phy(struct usb_hcd *hcd, ··· 614 636 #define ehci_start_port_reset NULL 615 637 #endif /* CONFIG_USB_OTG */ 616 638 617 - 618 - static const struct hc_driver ehci_fsl_hc_driver = { 619 - .description = hcd_name, 620 - .product_desc = "Freescale On-Chip EHCI Host Controller", 621 - .hcd_priv_size = sizeof(struct ehci_fsl), 622 - 623 - /* 624 - * generic hardware linkage 625 - */ 626 - .irq = ehci_irq, 627 - .flags = HCD_USB2 | HCD_MEMORY | HCD_BH, 628 - 629 - /* 630 - * basic lifecycle operations 631 - */ 639 + static struct ehci_driver_overrides ehci_fsl_overrides __initdata = { 640 + .extra_priv_size = sizeof(struct ehci_fsl), 632 641 .reset = ehci_fsl_setup, 633 - .start = ehci_run, 634 - .stop = ehci_stop, 635 - .shutdown = ehci_shutdown, 636 - 637 - /* 638 - * managing i/o requests and associated device resources 639 - */ 640 - .urb_enqueue = ehci_urb_enqueue, 641 - .urb_dequeue = ehci_urb_dequeue, 642 - .endpoint_disable = ehci_endpoint_disable, 643 - .endpoint_reset = ehci_endpoint_reset, 644 - 645 - /* 646 - * scheduling support 647 - */ 648 - .get_frame_number = ehci_get_frame, 649 - 650 - /* 651 - * root hub support 652 - */ 653 - .hub_status_data = ehci_hub_status_data, 654 - .hub_control = ehci_hub_control, 655 - .bus_suspend = ehci_bus_suspend, 656 - .bus_resume = ehci_bus_resume, 657 - .start_port_reset = ehci_start_port_reset, 658 - .relinquish_port = ehci_relinquish_port, 659 - .port_handed_over = ehci_port_handed_over, 660 - 661 - .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, 662 642 }; 663 643 664 - static int ehci_fsl_drv_probe(struct platform_device *pdev) 665 - { 666 - if (usb_disabled()) 667 - return -ENODEV; 644 + /** 645 + * fsl_ehci_drv_remove - shutdown processing for FSL-based HCDs 646 + * @dev: USB Host Controller being removed 647 + * Context: !in_interrupt() 648 + * 649 + * Reverses the effect of usb_hcd_fsl_probe(). 650 + * 651 + */ 668 652 669 - /* FIXME we only want one one probe() not two */ 670 - return usb_hcd_fsl_probe(&ehci_fsl_hc_driver, pdev); 671 - } 672 - 673 - static int ehci_fsl_drv_remove(struct platform_device *pdev) 653 + static int fsl_ehci_drv_remove(struct platform_device *pdev) 674 654 { 655 + struct fsl_usb2_platform_data *pdata = dev_get_platdata(&pdev->dev); 675 656 struct usb_hcd *hcd = platform_get_drvdata(pdev); 676 657 677 - /* FIXME we only want one one remove() not two */ 678 - usb_hcd_fsl_remove(hcd, pdev); 658 + if (!IS_ERR_OR_NULL(hcd->usb_phy)) { 659 + otg_set_host(hcd->usb_phy->otg, NULL); 660 + usb_put_phy(hcd->usb_phy); 661 + } 662 + 663 + usb_remove_hcd(hcd); 664 + 665 + /* 666 + * do platform specific un-initialization: 667 + * release iomux pins, disable clock, etc. 668 + */ 669 + if (pdata->exit) 670 + pdata->exit(pdev); 671 + usb_put_hcd(hcd); 672 + 679 673 return 0; 680 674 } 681 675 682 - MODULE_ALIAS("platform:fsl-ehci"); 683 - 684 676 static struct platform_driver ehci_fsl_driver = { 685 - .probe = ehci_fsl_drv_probe, 686 - .remove = ehci_fsl_drv_remove, 677 + .probe = fsl_ehci_drv_probe, 678 + .remove = fsl_ehci_drv_remove, 687 679 .shutdown = usb_hcd_platform_shutdown, 688 680 .driver = { 689 681 .name = "fsl-ehci", 690 682 .pm = EHCI_FSL_PM_OPS, 691 683 }, 692 684 }; 685 + 686 + static int __init ehci_fsl_init(void) 687 + { 688 + if (usb_disabled()) 689 + return -ENODEV; 690 + 691 + pr_info(DRV_NAME ": " DRIVER_DESC "\n"); 692 + 693 + ehci_init_driver(&fsl_ehci_hc_driver, &ehci_fsl_overrides); 694 + 695 + fsl_ehci_hc_driver.product_desc = 696 + "Freescale On-Chip EHCI Host Controller"; 697 + fsl_ehci_hc_driver.start_port_reset = ehci_start_port_reset; 698 + 699 + 700 + return platform_driver_register(&ehci_fsl_driver); 701 + } 702 + module_init(ehci_fsl_init); 703 + 704 + static void __exit ehci_fsl_cleanup(void) 705 + { 706 + platform_driver_unregister(&ehci_fsl_driver); 707 + } 708 + module_exit(ehci_fsl_cleanup); 709 + 710 + MODULE_DESCRIPTION(DRIVER_DESC); 711 + MODULE_LICENSE("GPL"); 712 + MODULE_ALIAS("platform:" DRV_NAME);
-5
drivers/usb/host/ehci-hcd.c
··· 1250 1250 MODULE_AUTHOR (DRIVER_AUTHOR); 1251 1251 MODULE_LICENSE ("GPL"); 1252 1252 1253 - #ifdef CONFIG_USB_EHCI_FSL 1254 - #include "ehci-fsl.c" 1255 - #define PLATFORM_DRIVER ehci_fsl_driver 1256 - #endif 1257 - 1258 1253 #ifdef CONFIG_USB_EHCI_SH 1259 1254 #include "ehci-sh.c" 1260 1255 #define PLATFORM_DRIVER ehci_hcd_sh_driver