Re: ehci-hcd compile error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 10 Jan 2013, Felipe Balbi wrote:

> -ENOROGER :-p
> 
> On Thu, Jan 10, 2013 at 08:23:56PM +0200, Felipe Balbi wrote:
> > Hi
> > 
> > On Thu, Jan 10, 2013 at 12:01:09PM -0500, Alan Stern wrote:
> > > On Thu, 10 Jan 2013, Felipe Balbi wrote:
> > > 
> > > > Hi,
> > > > 
> > > > On Thu, Jan 10, 2013 at 10:36:27AM -0500, Alan Stern wrote:
> > > > > On Thu, 10 Jan 2013, Felipe Balbi wrote:
> > > > > 
> > > > > > Hi Alan,
> > > > > > 
> > > > > > with v3.8-rc3, ehci-hcd fails to compile for ARM if I use 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
> > > > > > 
> > > > > > Looks like the recent ARM multi-arch patches didn't take into account
> > > > > > EHCI-hcd.
> > > > > 
> > > > > Do you know why this problem didn't occur in 3.6-rc2?  I don't see any 
> > > > > changes in -rc3 that would account for it (although I didn't look 
> > > > > terribly thoroughly).
> > > > 
> > > > It's probably there, I just didn't look at it either :-)
> > > 
> > > It seems clear that CONFIG_EHCI_HCD_PLATFORM needs to be mutually 
> > > exclusive with all the old-style drivers, in order to prevent this sort 
> > > of conflict.  I just don't see why it never came up before...
> > 
> > you can't do that as you will break ARM single zImage builds.

As you point out below, they are already broken.

> > > > > >  Now it becomes easy to see why giving ehci its own
> > > > > > platform_device/driver would've been a lot easier ;-)
> > > > > 
> > > > > Not at all.  We merely need to finish the conversion that I started.  
> > > > > It should be pretty easy to convert ehci-mxc over to the new scheme.
> > > > > I don't have time to do it right now, but soon...
> > > > 
> > > > ehci-mxc isn't the only one redefining PLATFORM_DRIVER. All of below are
> > > > potential offenders:
> > > > 
> > > > drivers/usb/host/ehci-hcd.c:#define	PLATFORM_DRIVER		ehci_fsl_driver
> > > > drivers/usb/host/ehci-hcd.c:#define PLATFORM_DRIVER		ehci_mxc_driver
> > > > drivers/usb/host/ehci-hcd.c:#define PLATFORM_DRIVER		ehci_hcd_sh_driver
> > > > drivers/usb/host/ehci-hcd.c:#define        PLATFORM_DRIVER         ehci_hcd_omap_driver
> > > > drivers/usb/host/ehci-hcd.c:#define	PLATFORM_DRIVER		ehci_orion_driver
> > > > drivers/usb/host/ehci-hcd.c:#define	PLATFORM_DRIVER		ehci_hcd_w90x900_driver
> > > > drivers/usb/host/ehci-hcd.c:#define	PLATFORM_DRIVER		ehci_atmel_driver
> > > > drivers/usb/host/ehci-hcd.c:#define PLATFORM_DRIVER		ehci_octeon_driver
> > > > drivers/usb/host/ehci-hcd.c:#define	PLATFORM_DRIVER		vt8500_ehci_driver
> > > > drivers/usb/host/ehci-hcd.c:#define PLATFORM_DRIVER		spear_ehci_hcd_driver
> > > > drivers/usb/host/ehci-hcd.c:#define PLATFORM_DRIVER		ehci_msm_driver
> > > > drivers/usb/host/ehci-hcd.c:#define	PLATFORM_DRIVER		ehci_hcd_tilegx_driver
> > > > drivers/usb/host/ehci-hcd.c:#define	PLATFORM_DRIVER		ehci_hcd_msp_driver
> > > > drivers/usb/host/ehci-hcd.c:#define PLATFORM_DRIVER		tegra_ehci_driver
> > > > drivers/usb/host/ehci-hcd.c:#define PLATFORM_DRIVER		s5p_ehci_driver
> > > > drivers/usb/host/ehci-hcd.c:#define PLATFORM_DRIVER		ehci_grlib_driver
> > > > drivers/usb/host/ehci-hcd.c:#define        PLATFORM_DRIVER         ehci_mv_driver
> > > > drivers/usb/host/ehci-hcd.c:#define	PLATFORM_DRIVER		ehci_hcd_sead3_driver
> > > 
> > > Yes; those all are old-style drivers.  Most of them can be converted to
> > > the new scheme with relatively little effort; a few will require more
> > > work.
> > > 
> > > In fact, the only drivers that _have_ been converted so far are 
> > > ehci-pci, chipidea, and ehci-platform.
> > 
> > Fair enough... Roger Quadros (now in Cc) can probably help converting
> > ehci-omap to the new scheme if you're willing to provide your review :-)

Yes, I saw that and was going to recommend to him that the conversion 
should be done before his changes are applied.  :-)

Roger, I'll send you a patch for ehci-omap.c shortly.  You should base 
your work on top of it (after testing to make sure that it works okay).

> > > It wouldn't hurt to add some restrictions to the Kconfig entry for 
> > > CONFIG_USB_EHCI_HCD_PLATFORM too.
> > 
> > Ok, maybe add a #warn "fix your freaking driver dude!!" to the
> > non-converted ones would make people help ?

Heh.  :-)

Here's my attempt to convert ehci-mxc.  I don't have any simple way 
even to compile it.  Please try it out to make sure that it fixes the 
build problem without introducing any other errors.

Alan Stern



Index: usb-3.7/drivers/usb/host/Kconfig
===================================================================
--- usb-3.7.orig/drivers/usb/host/Kconfig
+++ usb-3.7/drivers/usb/host/Kconfig
@@ -148,7 +148,7 @@ config USB_EHCI_FSL
 	  Variation of ARC USB block used in some Freescale chips.
 
 config USB_EHCI_MXC
-	bool "Support for Freescale i.MX on-chip EHCI USB controller"
+	tristate "Support for Freescale i.MX on-chip EHCI USB controller"
 	depends on USB_EHCI_HCD && ARCH_MXC
 	select USB_EHCI_ROOT_HUB_TT
 	---help---
Index: usb-3.7/drivers/usb/host/Makefile
===================================================================
--- usb-3.7.orig/drivers/usb/host/Makefile
+++ usb-3.7/drivers/usb/host/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_PCI)		+= pci-quirks.o
 obj-$(CONFIG_USB_EHCI_HCD)	+= ehci-hcd.o
 obj-$(CONFIG_USB_EHCI_PCI)	+= ehci-pci.o
 obj-$(CONFIG_USB_EHCI_HCD_PLATFORM)	+= ehci-platform.o
+obj-$(CONFIG_USB_EHCI_MXC)	+= ehci-mxc.o
 
 obj-$(CONFIG_USB_OXU210HP_HCD)	+= oxu210hp-hcd.o
 obj-$(CONFIG_USB_ISP116X_HCD)	+= isp116x-hcd.o
Index: usb-3.7/drivers/usb/host/ehci.h
===================================================================
--- usb-3.7.orig/drivers/usb/host/ehci.h
+++ usb-3.7/drivers/usb/host/ehci.h
@@ -221,6 +221,8 @@ struct ehci_hcd {			/* one per controlle
 #ifdef DEBUG
 	struct dentry		*debug_dir;
 #endif
+
+	unsigned long		priv[0];	/* platform-specific data */
 };
 
 /* convert between an HCD pointer and the corresponding EHCI_HCD */
Index: usb-3.7/drivers/usb/host/ehci-hcd.c
===================================================================
--- usb-3.7.orig/drivers/usb/host/ehci-hcd.c
+++ usb-3.7/drivers/usb/host/ehci-hcd.c
@@ -1250,11 +1250,6 @@ MODULE_LICENSE ("GPL");
 #define	PLATFORM_DRIVER		ehci_fsl_driver
 #endif
 
-#ifdef CONFIG_USB_EHCI_MXC
-#include "ehci-mxc.c"
-#define PLATFORM_DRIVER		ehci_mxc_driver
-#endif
-
 #ifdef CONFIG_USB_EHCI_SH
 #include "ehci-sh.c"
 #define PLATFORM_DRIVER		ehci_hcd_sh_driver
@@ -1353,6 +1348,7 @@ MODULE_LICENSE ("GPL");
 #if !IS_ENABLED(CONFIG_USB_EHCI_PCI) && \
 	!IS_ENABLED(CONFIG_USB_EHCI_HCD_PLATFORM) && \
 	!defined(CONFIG_USB_CHIPIDEA_HOST) && \
+	!defined(CONFIG_USB_EHCI_MXC) && \
 	!defined(PLATFORM_DRIVER) && \
 	!defined(PS3_SYSTEM_BUS_DRIVER) && \
 	!defined(OF_PLATFORM_DRIVER) && \
Index: usb-3.7/drivers/usb/host/ehci-mxc.c
===================================================================
--- usb-3.7.orig/drivers/usb/host/ehci-mxc.c
+++ usb-3.7/drivers/usb/host/ehci-mxc.c
@@ -17,76 +17,39 @@
  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/io.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/usb/otg.h>
 #include <linux/usb/ulpi.h>
 #include <linux/slab.h>
+#include <linux/usb.h>
+#include <linux/usb/hcd.h>
 
 #include <mach/hardware.h>
 #include <linux/platform_data/usb-ehci-mxc.h>
 
 #include <asm/mach-types.h>
 
+#include "ehci.h"
+
+#define DRIVER_DESC "Freescale On-Chip EHCI Host driver";
+
+static const char hcd_name[] = "ehci-mxc";
+
 #define ULPI_VIEWPORT_OFFSET	0x170
 
 struct ehci_mxc_priv {
 	struct clk *usbclk, *ahbclk, *phyclk;
-	struct usb_hcd *hcd;
 };
 
-/* called during probe() after chip reset completes */
-static int ehci_mxc_setup(struct usb_hcd *hcd)
-{
-	hcd->has_tt = 1;
-
-	return ehci_setup(hcd);
-}
-
-static const struct hc_driver ehci_mxc_hc_driver = {
-	.description = hcd_name,
-	.product_desc = "Freescale On-Chip EHCI Host Controller",
-	.hcd_priv_size = sizeof(struct ehci_hcd),
-
-	/*
-	 * generic hardware linkage
-	 */
-	.irq = ehci_irq,
-	.flags = HCD_USB2 | HCD_MEMORY,
-
-	/*
-	 * basic lifecycle operations
-	 */
-	.reset = ehci_mxc_setup,
-	.start = ehci_run,
-	.stop = ehci_stop,
-	.shutdown = ehci_shutdown,
-
-	/*
-	 * managing i/o requests and associated device resources
-	 */
-	.urb_enqueue = ehci_urb_enqueue,
-	.urb_dequeue = ehci_urb_dequeue,
-	.endpoint_disable = ehci_endpoint_disable,
-	.endpoint_reset = ehci_endpoint_reset,
-
-	/*
-	 * scheduling support
-	 */
-	.get_frame_number = ehci_get_frame,
-
-	/*
-	 * root hub support
-	 */
-	.hub_status_data = ehci_hub_status_data,
-	.hub_control = ehci_hub_control,
-	.bus_suspend = ehci_bus_suspend,
-	.bus_resume = ehci_bus_resume,
-	.relinquish_port = ehci_relinquish_port,
-	.port_handed_over = ehci_port_handed_over,
+static struct hc_driver __read_mostly ehci_mxc_hc_driver;
 
-	.clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
+static const struct ehci_driver_overrides ehci_mxc_overrides __initdata = {
+	.extra_priv_size =	sizeof(struct ehci_mxc_priv);
 };
 
 static int ehci_mxc_drv_probe(struct platform_device *pdev)
@@ -113,12 +76,6 @@ static int ehci_mxc_drv_probe(struct pla
 	if (!hcd)
 		return -ENOMEM;
 
-	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv) {
-		ret = -ENOMEM;
-		goto err_alloc;
-	}
-
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
 		dev_err(dev, "Found HC with no register addr. Check setup!\n");
@@ -136,6 +93,10 @@ static int ehci_mxc_drv_probe(struct pla
 		goto err_alloc;
 	}
 
+	hcd->has_tt = 1;
+	ehci = hcd_to_ehci(hcd);
+	priv = (struct ehci_mxc_priv *) ehci->priv;
+
 	/* enable clocks */
 	priv->usbclk = devm_clk_get(&pdev->dev, "ipg");
 	if (IS_ERR(priv->usbclk)) {
@@ -170,8 +131,6 @@ static int ehci_mxc_drv_probe(struct pla
 		mdelay(10);
 	}
 
-	ehci = hcd_to_ehci(hcd);
-
 	/* EHCI registers start at offset 0x100 */
 	ehci->caps = hcd->regs + 0x100;
 	ehci->regs = hcd->regs + 0x100 +
@@ -199,8 +158,7 @@ static int ehci_mxc_drv_probe(struct pla
 		}
 	}
 
-	priv->hcd = hcd;
-	platform_set_drvdata(pdev, priv);
+	platform_set_drvdata(pdev, hcd);
 
 	ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
 	if (ret)
@@ -220,13 +178,16 @@ static int ehci_mxc_drv_probe(struct pla
 							ULPI_OTG_CTRL);
 			if (ret) {
 				dev_err(dev, "unable to set CHRVBUS\n");
-				goto err_add;
+				goto err_chrgvbus;
 			}
 		}
 	}
 
 	return 0;
 
+err_chrgvbus:
+	usb_remove_hcd(hcd);
+
 err_add:
 	if (pdata && pdata->exit)
 		pdata->exit(pdev);
@@ -245,8 +206,11 @@ err_alloc:
 static int __exit ehci_mxc_drv_remove(struct platform_device *pdev)
 {
 	struct mxc_usbh_platform_data *pdata = pdev->dev.platform_data;
-	struct ehci_mxc_priv *priv = platform_get_drvdata(pdev);
-	struct usb_hcd *hcd = priv->hcd;
+	struct usb_hcd *hcd = platform_get_drvdata(pdev);
+	struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+	struct ehci_mxc_priv *priv = (struct ehci_mxc_priv *) ehci->priv;
+
+	usb_remove_hcd(hcd);
 
 	if (pdata && pdata->exit)
 		pdata->exit(pdev);
@@ -254,23 +218,20 @@ static int __exit ehci_mxc_drv_remove(st
 	if (pdata->otg)
 		usb_phy_shutdown(pdata->otg);
 
-	usb_remove_hcd(hcd);
-	usb_put_hcd(hcd);
-	platform_set_drvdata(pdev, NULL);
-
 	clk_disable_unprepare(priv->usbclk);
 	clk_disable_unprepare(priv->ahbclk);
 
 	if (priv->phyclk)
 		clk_disable_unprepare(priv->phyclk);
 
+	usb_put_hcd(hcd);
+	platform_set_drvdata(pdev, NULL);
 	return 0;
 }
 
 static void ehci_mxc_drv_shutdown(struct platform_device *pdev)
 {
-	struct ehci_mxc_priv *priv = platform_get_drvdata(pdev);
-	struct usb_hcd *hcd = priv->hcd;
+	struct usb_hcd *hcd = platform_get_drvdata(pdev);
 
 	if (hcd->driver->shutdown)
 		hcd->driver->shutdown(hcd);
@@ -280,9 +241,31 @@ MODULE_ALIAS("platform:mxc-ehci");
 
 static struct platform_driver ehci_mxc_driver = {
 	.probe = ehci_mxc_drv_probe,
-	.remove = __exit_p(ehci_mxc_drv_remove),
+	.remove = ehci_mxc_drv_remove,
 	.shutdown = ehci_mxc_drv_shutdown,
 	.driver = {
-		   .name = "mxc-ehci",
+		   .name = hcd_name,
 	},
 };
+
+static int __init ehci_mxc_init(void)
+{
+	if (usb_disabled())
+		return -ENODEV;
+
+	pr_info("%s: " DRIVER_DESC "\n", hcd_name);
+
+	ehci_init_driver(&ehci_mxc_hc_driver, &ehci_mxc_overrides);
+	return platform_driver_register(&ehci_mxc_driver);
+}
+module_init(ehci_mxc_init);
+
+static void __exit ehci_mxc_cleanup(void)
+{
+	platform_driver_unregister(&ehci_mxc_driver);
+}
+module_exit(ehci_mxc_cleanup);
+
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_AUTHOR("Sascha Hauer");
+MODULE_LICENSE("GPL");

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux