History

USB: EHCI: fix build error in ehci-mxc

This patch (as1643b) fixes a build error in ehci-hcd when compiling for ARM with allmodconfig: drivers/usb/host/ehci-hcd.c:1285:0: warning: "PLATFORM_DRIVER" redefined [enabled by default] drivers/usb/host/ehci-hcd.c:1255:0: note: this is the location of the previous definition drivers/usb/host/ehci-mxc.c:280:31: warning: 'ehci_mxc_driver' defined but not used [-Wunused-variable] drivers/usb/host/ehci-hcd.c:1285:0: warning: "PLATFORM_DRIVER" redefined [enabled by default] drivers/usb/host/ehci-hcd.c:1255:0: note: this is the location of the previous definition The fix is to convert ehci-mxc over to the new "ehci-hcd is a library" scheme so that it can coexist peacefully with the ehci-platform driver. As part of the conversion the ehci_mxc_priv data structure, which was allocated dynamically, is now placed where it belongs: in the private area at the end of struct ehci_hcd.

Alan Stern committed 13 years ago

Commit dba63b21 parent 9debc174 files · +53 −76Browse files

Unified · Split

4 files
  1. drivers/usb/host/Kconfig +1 −1
  2. drivers/usb/host/Makefile +1 −0
  3. drivers/usb/host/ehci-hcd.c +1 −5
  4. drivers/usb/host/ehci-mxc.c +50 −70
drivers/usb/host/Kconfig+1−1
@@ -148,7 +148,7 @@ config USB_EHCI_FSL · 147 unmodified lines
148 Variation of ARC USB block used in some Freescale chips.148 Variation of ARC USB block used in some Freescale chips.
149 149
150config USB_EHCI_MXC150config USB_EHCI_MXC
151 bool "Support for Freescale i.MX on-chip EHCI USB controller"151 tristate "Support for Freescale i.MX on-chip EHCI USB controller"
152 depends on USB_EHCI_HCD && ARCH_MXC152 depends on USB_EHCI_HCD && ARCH_MXC
153 select USB_EHCI_ROOT_HUB_TT153 select USB_EHCI_ROOT_HUB_TT
154 ---help---154 ---help---
drivers/usb/host/Makefile+1−0
@@ -26,6 +26,7 @@ obj-$(CONFIG_PCI) += pci-quirks.o · 25 unmodified lines
26obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o26obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o
27obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o27obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o
28obj-$(CONFIG_USB_EHCI_HCD_PLATFORM) += ehci-platform.o28obj-$(CONFIG_USB_EHCI_HCD_PLATFORM) += ehci-platform.o
29obj-$(CONFIG_USB_EHCI_MXC) += ehci-mxc.o
29 30
30obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o31obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o
31obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o32obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o
drivers/usb/host/ehci-hcd.c+1−5
@@ -1246,11 +1246,6 @@ MODULE_LICENSE ("GPL"); · 1245 unmodified lines
1246#define PLATFORM_DRIVER ehci_fsl_driver1246#define PLATFORM_DRIVER ehci_fsl_driver
1247#endif1247#endif
1248 1248
1249#ifdef CONFIG_USB_EHCI_MXC
1250#include "ehci-mxc.c"
1251#define PLATFORM_DRIVER ehci_mxc_driver
1252#endif
1253
1254#ifdef CONFIG_USB_EHCI_SH1249#ifdef CONFIG_USB_EHCI_SH
1255#include "ehci-sh.c"1250#include "ehci-sh.c"
1256#define PLATFORM_DRIVER ehci_hcd_sh_driver1251#define PLATFORM_DRIVER ehci_hcd_sh_driver
@@ -1349,6 +1344,7 @@ MODULE_LICENSE ("GPL"); · 92 unmodified lines
1349#if !IS_ENABLED(CONFIG_USB_EHCI_PCI) && \1344#if !IS_ENABLED(CONFIG_USB_EHCI_PCI) && \
1350 !IS_ENABLED(CONFIG_USB_EHCI_HCD_PLATFORM) && \1345 !IS_ENABLED(CONFIG_USB_EHCI_HCD_PLATFORM) && \
1351 !IS_ENABLED(CONFIG_USB_CHIPIDEA_HOST) && \1346 !IS_ENABLED(CONFIG_USB_CHIPIDEA_HOST) && \
1347 !IS_ENABLED(CONFIG_USB_EHCI_MXC) && \
1352 !defined(PLATFORM_DRIVER) && \1348 !defined(PLATFORM_DRIVER) && \
1353 !defined(PS3_SYSTEM_BUS_DRIVER) && \1349 !defined(PS3_SYSTEM_BUS_DRIVER) && \
1354 !defined(OF_PLATFORM_DRIVER) && \1350 !defined(OF_PLATFORM_DRIVER) && \
drivers/usb/host/ehci-mxc.c+50−70
@@ -17,75 +17,38 @@ · 16 unmodified lines
17 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.17 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */18 */
19 19
20#include <linux/kernel.h>
21#include <linux/module.h>
22#include <linux/io.h>
20#include <linux/platform_device.h>23#include <linux/platform_device.h>
21#include <linux/clk.h>24#include <linux/clk.h>
22#include <linux/delay.h>25#include <linux/delay.h>
23#include <linux/usb/otg.h>26#include <linux/usb/otg.h>
24#include <linux/usb/ulpi.h>27#include <linux/usb/ulpi.h>
25#include <linux/slab.h>28#include <linux/slab.h>
29#include <linux/usb.h>
30#include <linux/usb/hcd.h>
26 31
27#include <linux/platform_data/usb-ehci-mxc.h>32#include <linux/platform_data/usb-ehci-mxc.h>
28 33
29#include <asm/mach-types.h>34#include <asm/mach-types.h>
30 35
36#include "ehci.h"
37
38#define DRIVER_DESC "Freescale On-Chip EHCI Host driver"
39
40static const char hcd_name[] = "ehci-mxc";
41
31#define ULPI_VIEWPORT_OFFSET 0x17042#define ULPI_VIEWPORT_OFFSET 0x170
32 43
33struct ehci_mxc_priv {44struct ehci_mxc_priv {
34 struct clk *usbclk, *ahbclk, *phyclk;45 struct clk *usbclk, *ahbclk, *phyclk;
35 struct usb_hcd *hcd;
36};46};
37 47
38/* called during probe() after chip reset completes */48static struct hc_driver __read_mostly ehci_mxc_hc_driver;
39static int ehci_mxc_setup(struct usb_hcd *hcd)
40{
41 hcd->has_tt = 1;
42
43 return ehci_setup(hcd);
44}
45 49
46static const struct hc_driver ehci_mxc_hc_driver = {50static const struct ehci_driver_overrides ehci_mxc_overrides __initdata = {
47 .description = hcd_name,51 .extra_priv_size = sizeof(struct ehci_mxc_priv),
48 .product_desc = "Freescale On-Chip EHCI Host Controller",
49 .hcd_priv_size = sizeof(struct ehci_hcd),
50
51 /*
52 * generic hardware linkage
53 */
54 .irq = ehci_irq,
55 .flags = HCD_USB2 | HCD_MEMORY,
56
57 /*
58 * basic lifecycle operations
59 */
60 .reset = ehci_mxc_setup,
61 .start = ehci_run,
62 .stop = ehci_stop,
63 .shutdown = ehci_shutdown,
64
65 /*
66 * managing i/o requests and associated device resources
67 */
68 .urb_enqueue = ehci_urb_enqueue,
69 .urb_dequeue = ehci_urb_dequeue,
70 .endpoint_disable = ehci_endpoint_disable,
71 .endpoint_reset = ehci_endpoint_reset,
72
73 /*
74 * scheduling support
75 */
76 .get_frame_number = ehci_get_frame,
77
78 /*
79 * root hub support
80 */
81 .hub_status_data = ehci_hub_status_data,
82 .hub_control = ehci_hub_control,
83 .bus_suspend = ehci_bus_suspend,
84 .bus_resume = ehci_bus_resume,
85 .relinquish_port = ehci_relinquish_port,
86 .port_handed_over = ehci_port_handed_over,
87
88 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
89};52};
90 53
91static int ehci_mxc_drv_probe(struct platform_device *pdev)54static int ehci_mxc_drv_probe(struct platform_device *pdev)
@@ -112,12 +75,6 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) · 20 unmodified lines
112 if (!hcd)75 if (!hcd)
113 return -ENOMEM;76 return -ENOMEM;
114 77
115 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
116 if (!priv) {
117 ret = -ENOMEM;
118 goto err_alloc;
119 }
120
121 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);78 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
122 if (!res) {79 if (!res) {
123 dev_err(dev, "Found HC with no register addr. Check setup!\n");80 dev_err(dev, "Found HC with no register addr. Check setup!\n");
@@ -135,6 +92,10 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) · 11 unmodified lines
135 goto err_alloc;92 goto err_alloc;
136 }93 }
137 94
95 hcd->has_tt = 1;
96 ehci = hcd_to_ehci(hcd);
97 priv = (struct ehci_mxc_priv *) ehci->priv;
98
138 /* enable clocks */99 /* enable clocks */
139 priv->usbclk = devm_clk_get(&pdev->dev, "ipg");100 priv->usbclk = devm_clk_get(&pdev->dev, "ipg");
140 if (IS_ERR(priv->usbclk)) {101 if (IS_ERR(priv->usbclk)) {
@@ -169,8 +130,6 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) · 28 unmodified lines
169 mdelay(10);130 mdelay(10);
170 }131 }
171 132
172 ehci = hcd_to_ehci(hcd);
173
174 /* EHCI registers start at offset 0x100 */133 /* EHCI registers start at offset 0x100 */
175 ehci->caps = hcd->regs + 0x100;134 ehci->caps = hcd->regs + 0x100;
176 ehci->regs = hcd->regs + 0x100 +135 ehci->regs = hcd->regs + 0x100 +
@@ -198,8 +157,7 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) · 21 unmodified lines
198 }157 }
199 }158 }
200 159
201 priv->hcd = hcd;160 platform_set_drvdata(pdev, hcd);
202 platform_set_drvdata(pdev, priv);
203 161
204 ret = usb_add_hcd(hcd, irq, IRQF_SHARED);162 ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
205 if (ret)163 if (ret)
@@ -244,8 +202,11 @@ err_alloc: · 38 unmodified lines
244static int __exit ehci_mxc_drv_remove(struct platform_device *pdev)202static int __exit ehci_mxc_drv_remove(struct platform_device *pdev)
245{203{
246 struct mxc_usbh_platform_data *pdata = pdev->dev.platform_data;204 struct mxc_usbh_platform_data *pdata = pdev->dev.platform_data;
247 struct ehci_mxc_priv *priv = platform_get_drvdata(pdev);205 struct usb_hcd *hcd = platform_get_drvdata(pdev);
248 struct usb_hcd *hcd = priv->hcd;206 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
207 struct ehci_mxc_priv *priv = (struct ehci_mxc_priv *) ehci->priv;
208
209 usb_remove_hcd(hcd);
249 210
250 if (pdata && pdata->exit)211 if (pdata && pdata->exit)
251 pdata->exit(pdev);212 pdata->exit(pdev);
@@ -253,23 +214,20 @@ static int __exit ehci_mxc_drv_remove(struct platform_device *pdev) · 1 unmodified line
253 if (pdata->otg)214 if (pdata->otg)
254 usb_phy_shutdown(pdata->otg);215 usb_phy_shutdown(pdata->otg);
255 216
256 usb_remove_hcd(hcd);
257 usb_put_hcd(hcd);
258 platform_set_drvdata(pdev, NULL);
259
260 clk_disable_unprepare(priv->usbclk);217 clk_disable_unprepare(priv->usbclk);
261 clk_disable_unprepare(priv->ahbclk);218 clk_disable_unprepare(priv->ahbclk);
262 219
263 if (priv->phyclk)220 if (priv->phyclk)
264 clk_disable_unprepare(priv->phyclk);221 clk_disable_unprepare(priv->phyclk);
265 222
223 usb_put_hcd(hcd);
224 platform_set_drvdata(pdev, NULL);
266 return 0;225 return 0;
267}226}
268 227
269static void ehci_mxc_drv_shutdown(struct platform_device *pdev)228static void ehci_mxc_drv_shutdown(struct platform_device *pdev)
270{229{
271 struct ehci_mxc_priv *priv = platform_get_drvdata(pdev);230 struct usb_hcd *hcd = platform_get_drvdata(pdev);
272 struct usb_hcd *hcd = priv->hcd;
273 231
274 if (hcd->driver->shutdown)232 if (hcd->driver->shutdown)
275 hcd->driver->shutdown(hcd);233 hcd->driver->shutdown(hcd);
@@ -279,9 +237,31 @@ MODULE_ALIAS("platform:mxc-ehci"); · 3 unmodified lines
279 237
280static struct platform_driver ehci_mxc_driver = {238static struct platform_driver ehci_mxc_driver = {
281 .probe = ehci_mxc_drv_probe,239 .probe = ehci_mxc_drv_probe,
282 .remove = __exit_p(ehci_mxc_drv_remove),240 .remove = ehci_mxc_drv_remove,
283 .shutdown = ehci_mxc_drv_shutdown,241 .shutdown = ehci_mxc_drv_shutdown,
284 .driver = {242 .driver = {
285 .name = "mxc-ehci",243 .name = "mxc-ehci",
286 },244 },
287};245};
246
247static int __init ehci_mxc_init(void)
248{
249 if (usb_disabled())
250 return -ENODEV;
251
252 pr_info("%s: " DRIVER_DESC "\n", hcd_name);
253
254 ehci_init_driver(&ehci_mxc_hc_driver, &ehci_mxc_overrides);
255 return platform_driver_register(&ehci_mxc_driver);
256}
257module_init(ehci_mxc_init);
258
259static void __exit ehci_mxc_cleanup(void)
260{
261 platform_driver_unregister(&ehci_mxc_driver);
262}
263module_exit(ehci_mxc_cleanup);
264
265MODULE_DESCRIPTION(DRIVER_DESC);
266MODULE_AUTHOR("Sascha Hauer");
267MODULE_LICENSE("GPL");