public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* compile error when building multiple EHCI host controllers as modules
@ 2006-03-23 22:26 Kumar Gala
  2006-03-24  6:33 ` [linux-usb-devel] " David Brownell
  0 siblings, 1 reply; 12+ messages in thread
From: Kumar Gala @ 2006-03-23 22:26 UTC (permalink / raw)
  To: Greg KH, dbrownell; +Cc: linux-usb-devel, LKML mailing list

I was trying to build the USB EHCI host controller support as modules  
for a PowerPC 834x which also has an embedded EHCI (and PCI enabled).

I get the following build error:

In file included from drivers/usb/host/ehci-hcd.c:895:
drivers/usb/host/ehci-fsl.c:365: error: redefinition of '__inittest'
drivers/usb/host/ehci-pci.c:363: error: previous definition of  
'__inittest' was here
drivers/usb/host/ehci-fsl.c:365: error: redefinition of 'init_module'
drivers/usb/host/ehci-pci.c:363: error: previous definition of  
'init_module' was here
drivers/usb/host/ehci-fsl.c:365: error: redefinition of 'init_module'
drivers/usb/host/ehci-pci.c:363: error: previous definition of  
'init_module' was here
drivers/usb/host/ehci-fsl.c:366: error: redefinition of '__exittest'
drivers/usb/host/ehci-pci.c:369: error: previous definition of  
'__exittest' was here
drivers/usb/host/ehci-fsl.c:366: error: redefinition of 'cleanup_module'
drivers/usb/host/ehci-pci.c:369: error: previous definition of  
'cleanup_module' was here
drivers/usb/host/ehci-fsl.c:366: error: redefinition of 'cleanup_module'
drivers/usb/host/ehci-pci.c:369: error: previous definition of  
'cleanup_module' was here

Which makes sense based on how ehci-hcd.c includes "ehci-fsl.c" and  
"ehci-pci.c".  I was wondering if there were an thoughts on how to  
address this so I can build as a module.

- kumar

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [linux-usb-devel] compile error when building multiple EHCI host controllers as modules
  2006-03-23 22:26 compile error when building multiple EHCI host controllers as modules Kumar Gala
@ 2006-03-24  6:33 ` David Brownell
  2006-03-24 16:59   ` Kumar Gala
  0 siblings, 1 reply; 12+ messages in thread
From: David Brownell @ 2006-03-24  6:33 UTC (permalink / raw)
  To: linux-usb-devel; +Cc: Kumar Gala, Greg KH, LKML mailing list

On Thursday 23 March 2006 2:26 pm, Kumar Gala wrote:

> "ehci-pci.c".  I was wondering if there were an thoughts on how to  
> address this so I can build as a module.

Hmm, there was a patch to fix that for OHCI a while back, I'm not
sure what happened to it.  Maybe the cleaned up version just never
got posted as promised.

The problem is that there need to be two different init (and exit)
section routines for the bus glue:  platform_bus and/or pci_bus.

PCs typically just have PCI; battery-oriented SOCs tend to never
have PCI; and we're now starting to see some non-battery SOCs that
include PCI support as well as integrated USB host support.

The *hci-hcd.c file should be converted to have a single module_init()
and module_exit() routine at the end, looking something like

	static int __init Xhci_init(void)
	{
		int status;

		/* various shared stuff, dump version etc */

		/* SOCs usually use only this path */
		status = Xhci_platform_register();
		if (status < 0)
			return status;

		/* PCs, and a few higher powered SOCs, use this */
		status = Xhci_pci_register();
		if (status < 0)
			Xhci_platform_unregister();
		return status;
	}
	module_init(Xhci_init);

Likewise for module_exit.  The #includes for the platform-specific glue
(including PCI) would define those Xhci_platform_*() routine, and it's
a simple bit of #ifdeffery to make sure there's always at least some
NOP default available for those.

- Dave

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [linux-usb-devel] compile error when building multiple EHCI host controllers as modules
  2006-03-24  6:33 ` [linux-usb-devel] " David Brownell
@ 2006-03-24 16:59   ` Kumar Gala
  2006-03-24 20:32     ` Kumar Gala
  0 siblings, 1 reply; 12+ messages in thread
From: Kumar Gala @ 2006-03-24 16:59 UTC (permalink / raw)
  To: David Brownell; +Cc: linux-usb-devel, Greg KH, LKML mailing list


On Mar 24, 2006, at 12:33 AM, David Brownell wrote:

> On Thursday 23 March 2006 2:26 pm, Kumar Gala wrote:
>
>> "ehci-pci.c".  I was wondering if there were an thoughts on how to
>> address this so I can build as a module.
>
> Hmm, there was a patch to fix that for OHCI a while back, I'm not
> sure what happened to it.  Maybe the cleaned up version just never
> got posted as promised.
>
> The problem is that there need to be two different init (and exit)
> section routines for the bus glue:  platform_bus and/or pci_bus.
>
> PCs typically just have PCI; battery-oriented SOCs tend to never
> have PCI; and we're now starting to see some non-battery SOCs that
> include PCI support as well as integrated USB host support.
>
> The *hci-hcd.c file should be converted to have a single module_init()
> and module_exit() routine at the end, looking something like
>
> 	static int __init Xhci_init(void)
> 	{
> 		int status;
>
> 		/* various shared stuff, dump version etc */
>
> 		/* SOCs usually use only this path */
> 		status = Xhci_platform_register();
> 		if (status < 0)
> 			return status;
>
> 		/* PCs, and a few higher powered SOCs, use this */
> 		status = Xhci_pci_register();
> 		if (status < 0)
> 			Xhci_platform_unregister();
> 		return status;
> 	}
> 	module_init(Xhci_init);
>
> Likewise for module_exit.  The #includes for the platform-specific  
> glue
> (including PCI) would define those Xhci_platform_*() routine, and it's
> a simple bit of #ifdeffery to make sure there's always at least some
> NOP default available for those.

The issue I have this is that it makes two (or more) things that were  
independent now dependent.  What about just moving the module_init/ 
exit() functions into files that are built separately.  For the ehci- 
fsl case it was trivial, need to look at ehci-pci case.

- kumar

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [linux-usb-devel] compile error when building multiple EHCI host controllers as modules
  2006-03-24 16:59   ` Kumar Gala
@ 2006-03-24 20:32     ` Kumar Gala
  2006-03-28 16:18       ` Kumar Gala
                         ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Kumar Gala @ 2006-03-24 20:32 UTC (permalink / raw)
  To: David Brownell; +Cc: linux-usb-devel, Greg KH, LKML mailing list

> The issue I have this is that it makes two (or more) things that were  
> independent now dependent.  What about just moving the module_init/ 
> exit() functions into files that are built separately.  For the ehci- 
> fsl case it was trivial, need to look at ehci-pci case.

Ok, my idea required exporting things I didn't really want to export, so 
what about something like this or where you thinking of some more 
sophisticated?

If this is good, I'll do the same for ohci.

diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c
index 63eadee..036a1c0 100644
--- a/drivers/usb/host/ehci-au1xxx.c
+++ b/drivers/usb/host/ehci-au1xxx.c
@@ -280,18 +280,3 @@ static struct device_driver ehci_hcd_au1
 	/*.suspend      = ehci_hcd_au1xxx_drv_suspend, */
 	/*.resume       = ehci_hcd_au1xxx_drv_resume, */
 };
-
-static int __init ehci_hcd_au1xxx_init(void)
-{
-	pr_debug(DRIVER_INFO " (Au1xxx)\n");
-
-	return driver_register(&ehci_hcd_au1xxx_driver);
-}
-
-static void __exit ehci_hcd_au1xxx_cleanup(void)
-{
-	driver_unregister(&ehci_hcd_au1xxx_driver);
-}
-
-module_init(ehci_hcd_au1xxx_init);
-module_exit(ehci_hcd_au1xxx_cleanup);
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index f985f12..30410c2 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -339,28 +339,3 @@ static struct platform_driver ehci_fsl_m
 		   .name = "fsl-usb2-mph",
 		   },
 };
-
-static int __init ehci_fsl_init(void)
-{
-	int retval;
-
-	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
-		 hcd_name,
-		 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
-		 sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
-
-	retval = platform_driver_register(&ehci_fsl_dr_driver);
-	if (retval)
-		return retval;
-
-	return platform_driver_register(&ehci_fsl_mph_driver);
-}
-
-static void __exit ehci_fsl_cleanup(void)
-{
-	platform_driver_unregister(&ehci_fsl_mph_driver);
-	platform_driver_unregister(&ehci_fsl_dr_driver);
-}
-
-module_init(ehci_fsl_init);
-module_exit(ehci_fsl_cleanup);
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 79f2d8b..549ce59 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -905,3 +905,57 @@ MODULE_LICENSE ("GPL");
 #ifndef	EHCI_BUS_GLUED
 #error "missing bus glue for ehci-hcd"
 #endif
+
+static int __init ehci_hcd_init(void)
+{
+	int retval = 0;
+
+	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
+		 hcd_name,
+		 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
+		 sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
+
+#ifdef CONFIG_PPC_83xx
+	retval = platform_driver_register(&ehci_fsl_dr_driver);
+	if (retval < 0)
+		return retval;
+
+	retval = platform_driver_register(&ehci_fsl_dr_driver);
+	if (retval < 0)
+		return retval;
+#endif
+
+#ifdef CONFIG_SOC_AU1X00
+	pr_debug(DRIVER_INFO " (Au1xxx)\n");
+
+	retval = driver_register(&ehci_hcd_au1xxx_driver);
+	if (retval < 0)
+		return retval;
+#endif
+
+#ifdef CONFIG_PCI
+	retval = pci_register_driver(&ehci_pci_driver);
+	if (retval < 0)
+		return retval;
+#endif
+
+	return retval;
+}
+
+static void __exit ehci_hcd_cleanup(void)
+{
+#ifdef CONFIG_PPC_83xx
+	platform_driver_unregister(&ehci_fsl_mph_driver);
+	platform_driver_unregister(&ehci_fsl_dr_driver);
+#endif
+#ifdef CONFIG_SOC_AU1X00
+	driver_unregister(&ehci_hcd_au1xxx_driver);
+#endif
+#ifdef CONFIG_PCI
+	pci_unregister_driver(&ehci_pci_driver);
+#endif
+}
+
+module_init(ehci_hcd_init);
+module_exit(ehci_hcd_cleanup);
+
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 1e03f1a..e0641bc 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -370,23 +370,3 @@ static struct pci_driver ehci_pci_driver
 	.resume =	usb_hcd_pci_resume,
 #endif
 };
-
-static int __init ehci_hcd_pci_init(void)
-{
-	if (usb_disabled())
-		return -ENODEV;
-
-	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
-		hcd_name,
-		sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
-		sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
-
-	return pci_register_driver(&ehci_pci_driver);
-}
-module_init(ehci_hcd_pci_init);
-
-static void __exit ehci_hcd_pci_cleanup(void)
-{
-	pci_unregister_driver(&ehci_pci_driver);
-}
-module_exit(ehci_hcd_pci_cleanup);


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [linux-usb-devel] compile error when building multiple EHCI host controllers as modules
  2006-03-24 20:32     ` Kumar Gala
@ 2006-03-28 16:18       ` Kumar Gala
  2006-03-28 17:51       ` Matthieu CASTET
  2006-04-04  2:48       ` [linux-usb-devel] " David Brownell
  2 siblings, 0 replies; 12+ messages in thread
From: Kumar Gala @ 2006-03-28 16:18 UTC (permalink / raw)
  To: David Brownell; +Cc: linux-usb-devel, Greg KH, LKML mailing list


On Mar 24, 2006, at 2:32 PM, Kumar Gala wrote:

>> The issue I have this is that it makes two (or more) things that were
>> independent now dependent.  What about just moving the module_init/
>> exit() functions into files that are built separately.  For the ehci-
>> fsl case it was trivial, need to look at ehci-pci case.
>
> Ok, my idea required exporting things I didn't really want to  
> export, so
> what about something like this or where you thinking of some more
> sophisticated?
>
> If this is good, I'll do the same for ohci.

David, any comments?

- k

> diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci- 
> au1xxx.c
> index 63eadee..036a1c0 100644
> --- a/drivers/usb/host/ehci-au1xxx.c
> +++ b/drivers/usb/host/ehci-au1xxx.c
> @@ -280,18 +280,3 @@ static struct device_driver ehci_hcd_au1
>  	/*.suspend      = ehci_hcd_au1xxx_drv_suspend, */
>  	/*.resume       = ehci_hcd_au1xxx_drv_resume, */
>  };
> -
> -static int __init ehci_hcd_au1xxx_init(void)
> -{
> -	pr_debug(DRIVER_INFO " (Au1xxx)\n");
> -
> -	return driver_register(&ehci_hcd_au1xxx_driver);
> -}
> -
> -static void __exit ehci_hcd_au1xxx_cleanup(void)
> -{
> -	driver_unregister(&ehci_hcd_au1xxx_driver);
> -}
> -
> -module_init(ehci_hcd_au1xxx_init);
> -module_exit(ehci_hcd_au1xxx_cleanup);
> diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
> index f985f12..30410c2 100644
> --- a/drivers/usb/host/ehci-fsl.c
> +++ b/drivers/usb/host/ehci-fsl.c
> @@ -339,28 +339,3 @@ static struct platform_driver ehci_fsl_m
>  		   .name = "fsl-usb2-mph",
>  		   },
>  };
> -
> -static int __init ehci_fsl_init(void)
> -{
> -	int retval;
> -
> -	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
> -		 hcd_name,
> -		 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
> -		 sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
> -
> -	retval = platform_driver_register(&ehci_fsl_dr_driver);
> -	if (retval)
> -		return retval;
> -
> -	return platform_driver_register(&ehci_fsl_mph_driver);
> -}
> -
> -static void __exit ehci_fsl_cleanup(void)
> -{
> -	platform_driver_unregister(&ehci_fsl_mph_driver);
> -	platform_driver_unregister(&ehci_fsl_dr_driver);
> -}
> -
> -module_init(ehci_fsl_init);
> -module_exit(ehci_fsl_cleanup);
> diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> index 79f2d8b..549ce59 100644
> --- a/drivers/usb/host/ehci-hcd.c
> +++ b/drivers/usb/host/ehci-hcd.c
> @@ -905,3 +905,57 @@ MODULE_LICENSE ("GPL");
>  #ifndef	EHCI_BUS_GLUED
>  #error "missing bus glue for ehci-hcd"
>  #endif
> +
> +static int __init ehci_hcd_init(void)
> +{
> +	int retval = 0;
> +
> +	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
> +		 hcd_name,
> +		 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
> +		 sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
> +
> +#ifdef CONFIG_PPC_83xx
> +	retval = platform_driver_register(&ehci_fsl_dr_driver);
> +	if (retval < 0)
> +		return retval;
> +
> +	retval = platform_driver_register(&ehci_fsl_dr_driver);
> +	if (retval < 0)
> +		return retval;
> +#endif
> +
> +#ifdef CONFIG_SOC_AU1X00
> +	pr_debug(DRIVER_INFO " (Au1xxx)\n");
> +
> +	retval = driver_register(&ehci_hcd_au1xxx_driver);
> +	if (retval < 0)
> +		return retval;
> +#endif
> +
> +#ifdef CONFIG_PCI
> +	retval = pci_register_driver(&ehci_pci_driver);
> +	if (retval < 0)
> +		return retval;
> +#endif
> +
> +	return retval;
> +}
> +
> +static void __exit ehci_hcd_cleanup(void)
> +{
> +#ifdef CONFIG_PPC_83xx
> +	platform_driver_unregister(&ehci_fsl_mph_driver);
> +	platform_driver_unregister(&ehci_fsl_dr_driver);
> +#endif
> +#ifdef CONFIG_SOC_AU1X00
> +	driver_unregister(&ehci_hcd_au1xxx_driver);
> +#endif
> +#ifdef CONFIG_PCI
> +	pci_unregister_driver(&ehci_pci_driver);
> +#endif
> +}
> +
> +module_init(ehci_hcd_init);
> +module_exit(ehci_hcd_cleanup);
> +
> diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
> index 1e03f1a..e0641bc 100644
> --- a/drivers/usb/host/ehci-pci.c
> +++ b/drivers/usb/host/ehci-pci.c
> @@ -370,23 +370,3 @@ static struct pci_driver ehci_pci_driver
>  	.resume =	usb_hcd_pci_resume,
>  #endif
>  };
> -
> -static int __init ehci_hcd_pci_init(void)
> -{
> -	if (usb_disabled())
> -		return -ENODEV;
> -
> -	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
> -		hcd_name,
> -		sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
> -		sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
> -
> -	return pci_register_driver(&ehci_pci_driver);
> -}
> -module_init(ehci_hcd_pci_init);
> -
> -static void __exit ehci_hcd_pci_cleanup(void)
> -{
> -	pci_unregister_driver(&ehci_pci_driver);
> -}
> -module_exit(ehci_hcd_pci_cleanup);
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux- 
> kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: compile error when building multiple EHCI host controllers as modules
  2006-03-24 20:32     ` Kumar Gala
  2006-03-28 16:18       ` Kumar Gala
@ 2006-03-28 17:51       ` Matthieu CASTET
  2006-04-04  2:48       ` [linux-usb-devel] " David Brownell
  2 siblings, 0 replies; 12+ messages in thread
From: Matthieu CASTET @ 2006-03-28 17:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-usb-devel

Hi,

Le Fri, 24 Mar 2006 14:32:57 -0600, Kumar Gala a écrit :


> +
> +static int __init ehci_hcd_init(void)
> +{
> +	int retval = 0;
> +
> +	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
> +		 hcd_name,
> +		 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
> +		 sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
> +
> +#ifdef CONFIG_PPC_83xx
> +	retval = platform_driver_register(&ehci_fsl_dr_driver);
> +	if (retval < 0)
> +		return retval;
This is wrong as the first driver could failed but the following one could
be correct : imagine generic kernel were multiple config options are
enabled.
On some board we could have only one controller, on other both.

> +	retval = platform_driver_register(&ehci_fsl_dr_driver);
> +	if (retval < 0)
> +		return retval;
> +#endif
We should unregister all the previous drivers if we fail.

Matthieu


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [linux-usb-devel] compile error when building multiple EHCI host controllers as modules
  2006-03-24 20:32     ` Kumar Gala
  2006-03-28 16:18       ` Kumar Gala
  2006-03-28 17:51       ` Matthieu CASTET
@ 2006-04-04  2:48       ` David Brownell
  2006-04-04  4:23         ` Kumar Gala
  2 siblings, 1 reply; 12+ messages in thread
From: David Brownell @ 2006-04-04  2:48 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linux-usb-devel, Greg KH, LKML mailing list

[-- Attachment #1: Type: text/plain, Size: 824 bytes --]

On Friday 24 March 2006 12:32 pm, Kumar Gala wrote:
> > The issue I have this is that it makes two (or more) things that were  
> > independent now dependent.  What about just moving the module_init/ 
> > exit() functions into files that are built separately.  For the ehci- 
> > fsl case it was trivial, need to look at ehci-pci case.
> 
> Ok, my idea required exporting things I didn't really want to export, so 
> what about something like this or where you thinking of some more 
> sophisticated?
> 
> If this is good, I'll do the same for ohci.

How about this one instead?  It requires fewer per-SOC hacks in generic
code when adding a new SOC.  And it also removes a platform device naming
goof for your mpc83xx support ... that's a case where you should just let
the platform device IDs distinguish things.

- Dave


[-- Attachment #2: ehci-kumar.patch --]
[-- Type: text/x-diff, Size: 6190 bytes --]

Let EHCI build and link supporing both PCI and platform bus glue.

 - there's now a single pair of module init/exit routines, which
   do little beyond registering/unregistering one or two drivers:
     * a single platform driver
     * a single pci driver

 - for coldplug, the non-PCI drivers also define a MODULE_ALIAS;
   boot scripts can just "modprobe $(cat .../modalias)"

 - renamed mpc83xx platform devices to follow normal Linux rules

au1xxx will have a compile problem, it still needs to convert to
using platform_driver.

Index: g26/drivers/usb/host/ehci-au1xxx.c
===================================================================
--- g26.orig/drivers/usb/host/ehci-au1xxx.c	2006-03-31 22:36:07.000000000 -0800
+++ g26/drivers/usb/host/ehci-au1xxx.c	2006-04-03 19:40:44.000000000 -0700
@@ -272,6 +272,8 @@ static int ehci_hcd_au1xxx_drv_resume(st
 	return 0;
 }
 */
+MODULE_ALIAS("au1xxx-ehci");
+/* FIXME use "struct platform_driver" */
 static struct device_driver ehci_hcd_au1xxx_driver = {
 	.name = "au1xxx-ehci",
 	.bus = &platform_bus_type,
@@ -280,18 +282,3 @@ static struct device_driver ehci_hcd_au1
 	/*.suspend      = ehci_hcd_au1xxx_drv_suspend, */
 	/*.resume       = ehci_hcd_au1xxx_drv_resume, */
 };
-
-static int __init ehci_hcd_au1xxx_init(void)
-{
-	pr_debug(DRIVER_INFO " (Au1xxx)\n");
-
-	return driver_register(&ehci_hcd_au1xxx_driver);
-}
-
-static void __exit ehci_hcd_au1xxx_cleanup(void)
-{
-	driver_unregister(&ehci_hcd_au1xxx_driver);
-}
-
-module_init(ehci_hcd_au1xxx_init);
-module_exit(ehci_hcd_au1xxx_cleanup);
Index: g26/drivers/usb/host/ehci-fsl.c
===================================================================
--- g26.orig/drivers/usb/host/ehci-fsl.c	2006-03-31 22:36:07.000000000 -0800
+++ g26/drivers/usb/host/ehci-fsl.c	2006-04-03 19:38:26.000000000 -0700
@@ -324,43 +324,12 @@ static int ehci_fsl_drv_remove(struct pl
 	return 0;
 }
 
-static struct platform_driver ehci_fsl_dr_driver = {
-	.probe = ehci_fsl_drv_probe,
-	.remove = ehci_fsl_drv_remove,
-	.driver = {
-		   .name = "fsl-usb2-dr",
-		   },
-};
+MODULE_ALIAS("fsl-ehci");
 
-static struct platform_driver ehci_fsl_mph_driver = {
+static struct platform_driver ehci_fsl_driver = {
 	.probe = ehci_fsl_drv_probe,
 	.remove = ehci_fsl_drv_remove,
 	.driver = {
-		   .name = "fsl-usb2-mph",
+		   .name = "fsl-ehci",
 		   },
 };
-
-static int __init ehci_fsl_init(void)
-{
-	int retval;
-
-	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
-		 hcd_name,
-		 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
-		 sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
-
-	retval = platform_driver_register(&ehci_fsl_dr_driver);
-	if (retval)
-		return retval;
-
-	return platform_driver_register(&ehci_fsl_mph_driver);
-}
-
-static void __exit ehci_fsl_cleanup(void)
-{
-	platform_driver_unregister(&ehci_fsl_mph_driver);
-	platform_driver_unregister(&ehci_fsl_dr_driver);
-}
-
-module_init(ehci_fsl_init);
-module_exit(ehci_fsl_cleanup);
Index: g26/drivers/usb/host/ehci-hcd.c
===================================================================
--- g26.orig/drivers/usb/host/ehci-hcd.c	2006-03-31 22:36:07.000000000 -0800
+++ g26/drivers/usb/host/ehci-hcd.c	2006-04-03 19:46:07.000000000 -0700
@@ -889,19 +889,59 @@ MODULE_LICENSE ("GPL");
 
 #ifdef CONFIG_PCI
 #include "ehci-pci.c"
-#define	EHCI_BUS_GLUED
+#define	PCI_DRIVER		ehci_pci_driver
 #endif
 
 #ifdef CONFIG_PPC_83xx
 #include "ehci-fsl.c"
-#define	EHCI_BUS_GLUED
+#define	PLATFORM_DRIVER		ehci_fsl_dr_driver
 #endif
 
 #ifdef CONFIG_SOC_AU1X00
 #include "ehci-au1xxx.c"
-#define	EHCI_BUS_GLUED
+#define	PLATFORM_DRIVER		ehci_hcd_au1xxx_driver
 #endif
 
-#ifndef	EHCI_BUS_GLUED
+#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER)
 #error "missing bus glue for ehci-hcd"
 #endif
+
+static int __init ehci_hcd_init(void)
+{
+	int retval = 0;
+
+	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
+		 hcd_name,
+		 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
+		 sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
+
+#ifdef PLATFORM_DRIVER
+	retval = platform_driver_register(&PLATFORM_DRIVER);
+	if (retval < 0)
+		return retval;
+#endif
+
+#ifdef PCI_DRIVER
+	retval = pci_register_driver(&PCI_DRIVER);
+	if (retval < 0) {
+#ifdef PLATFORM_DRIVER
+		platform_driver_unregister(&PLATFORM_DRIVER);
+#endif
+	}
+#endif
+
+	return retval;
+}
+module_init(ehci_hcd_init);
+
+static void __exit ehci_hcd_cleanup(void)
+{
+#ifdef PLATFORM_DRIVER
+	driver_unregister(&PLATFORM_DRIVER);
+#endif
+#ifdef PCI_DRIVER
+	pci_unregister_driver(&PCI_DRIVER);
+#endif
+}
+module_exit(ehci_hcd_cleanup);
+
Index: g26/drivers/usb/host/ehci-pci.c
===================================================================
--- g26.orig/drivers/usb/host/ehci-pci.c	2006-03-31 22:36:07.000000000 -0800
+++ g26/drivers/usb/host/ehci-pci.c	2006-04-03 19:15:33.000000000 -0700
@@ -370,23 +370,3 @@ static struct pci_driver ehci_pci_driver
 	.resume =	usb_hcd_pci_resume,
 #endif
 };
-
-static int __init ehci_hcd_pci_init(void)
-{
-	if (usb_disabled())
-		return -ENODEV;
-
-	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
-		hcd_name,
-		sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
-		sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
-
-	return pci_register_driver(&ehci_pci_driver);
-}
-module_init(ehci_hcd_pci_init);
-
-static void __exit ehci_hcd_pci_cleanup(void)
-{
-	pci_unregister_driver(&ehci_pci_driver);
-}
-module_exit(ehci_hcd_pci_cleanup);
Index: g26/arch/ppc/syslib/mpc83xx_devices.c
===================================================================
--- g26.orig/arch/ppc/syslib/mpc83xx_devices.c	2006-03-31 22:35:39.000000000 -0800
+++ g26/arch/ppc/syslib/mpc83xx_devices.c	2006-04-03 19:39:10.000000000 -0700
@@ -186,7 +186,7 @@ struct platform_device ppc_sys_platform_
 		},
 	},
 	[MPC83xx_USB2_DR] = {
-		.name = "fsl-usb2-dr",
+		.name = "fsl-ehci",
 		.id	= 1,
 		.num_resources	 = 2,
 		.resource = (struct resource[]) {
@@ -203,8 +203,8 @@ struct platform_device ppc_sys_platform_
 		},
 	},
 	[MPC83xx_USB2_MPH] = {
-		.name = "fsl-usb2-mph",
-		.id	= 1,
+		.name = "fsl-ehci",
+		.id	= 2,
 		.num_resources	 = 2,
 		.resource = (struct resource[]) {
 			{

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [linux-usb-devel] compile error when building multiple EHCI host controllers as modules
  2006-04-04  2:48       ` [linux-usb-devel] " David Brownell
@ 2006-04-04  4:23         ` Kumar Gala
  2006-04-05 17:32           ` Kumar Gala
  0 siblings, 1 reply; 12+ messages in thread
From: Kumar Gala @ 2006-04-04  4:23 UTC (permalink / raw)
  To: David Brownell; +Cc: linux-usb-devel, Greg KH, LKML mailing list


On Apr 3, 2006, at 9:48 PM, David Brownell wrote:

> On Friday 24 March 2006 12:32 pm, Kumar Gala wrote:
>>> The issue I have this is that it makes two (or more) things that  
>>> were
>>> independent now dependent.  What about just moving the module_init/
>>> exit() functions into files that are built separately.  For the  
>>> ehci-
>>> fsl case it was trivial, need to look at ehci-pci case.
>>
>> Ok, my idea required exporting things I didn't really want to  
>> export, so
>> what about something like this or where you thinking of some more
>> sophisticated?
>>
>> If this is good, I'll do the same for ohci.
>
> How about this one instead?  It requires fewer per-SOC hacks in  
> generic
> code when adding a new SOC.  And it also removes a platform device  
> naming
> goof for your mpc83xx support ... that's a case where you should  
> just let
> the platform device IDs distinguish things.

Let me test this patch out.  I'm ok with the changes for handling  
both PCI and platform driver.  However, I need to take a look at the  
renaming of the fsl driver.  The "dr" device supports device and OTG  
modes.  I'm concerned about how we distinguish that in the future.

(also, we need to fixup arch/powerpc/sysdev/fsl_soc.c)

- k



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [linux-usb-devel] compile error when building multiple EHCI host controllers as modules
  2006-04-04  4:23         ` Kumar Gala
@ 2006-04-05 17:32           ` Kumar Gala
  2006-04-10 19:11             ` David Brownell
  0 siblings, 1 reply; 12+ messages in thread
From: Kumar Gala @ 2006-04-05 17:32 UTC (permalink / raw)
  To: David Brownell; +Cc: linux-usb-devel, Greg KH, LKML mailing list

> Let me test this patch out.  I'm ok with the changes for handling  
> both PCI and platform driver.  However, I need to take a look at the  
> renaming of the fsl driver.  The "dr" device supports device and OTG  
> modes.  I'm concerned about how we distinguish that in the future.
> 
> (also, we need to fixup arch/powerpc/sysdev/fsl_soc.c)

Here's a cleaned up version that builds and fixes up some warnings for me.
I need to cleanup the code in arch/powerpc/sysdev/fsl_soc.c a bit, but it 
works for now.

diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c
index 63eadee..036a1c0 100644
--- a/drivers/usb/host/ehci-au1xxx.c
+++ b/drivers/usb/host/ehci-au1xxx.c
@@ -280,18 +280,3 @@ static struct device_driver ehci_hcd_au1
 	/*.suspend      = ehci_hcd_au1xxx_drv_suspend, */
 	/*.resume       = ehci_hcd_au1xxx_drv_resume, */
 };
-
-static int __init ehci_hcd_au1xxx_init(void)
-{
-	pr_debug(DRIVER_INFO " (Au1xxx)\n");
-
-	return driver_register(&ehci_hcd_au1xxx_driver);
-}
-
-static void __exit ehci_hcd_au1xxx_cleanup(void)
-{
-	driver_unregister(&ehci_hcd_au1xxx_driver);
-}
-
-module_init(ehci_hcd_au1xxx_init);
-module_exit(ehci_hcd_au1xxx_cleanup);
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index f985f12..30410c2 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -339,28 +339,3 @@ static struct platform_driver ehci_fsl_m
 		   .name = "fsl-usb2-mph",
 		   },
 };
-
-static int __init ehci_fsl_init(void)
-{
-	int retval;
-
-	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
-		 hcd_name,
-		 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
-		 sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
-
-	retval = platform_driver_register(&ehci_fsl_dr_driver);
-	if (retval)
-		return retval;
-
-	return platform_driver_register(&ehci_fsl_mph_driver);
-}
-
-static void __exit ehci_fsl_cleanup(void)
-{
-	platform_driver_unregister(&ehci_fsl_mph_driver);
-	platform_driver_unregister(&ehci_fsl_dr_driver);
-}
-
-module_init(ehci_fsl_init);
-module_exit(ehci_fsl_cleanup);
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 79f2d8b..549ce59 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -905,3 +905,57 @@ MODULE_LICENSE ("GPL");
 #ifndef	EHCI_BUS_GLUED
 #error "missing bus glue for ehci-hcd"
 #endif
+
+static int __init ehci_hcd_init(void)
+{
+	int retval = 0;
+
+	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
+		 hcd_name,
+		 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
+		 sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
+
+#ifdef CONFIG_PPC_83xx
+	retval = platform_driver_register(&ehci_fsl_dr_driver);
+	if (retval < 0)
+		return retval;
+
+	retval = platform_driver_register(&ehci_fsl_dr_driver);
+	if (retval < 0)
+		return retval;
+#endif
+
+#ifdef CONFIG_SOC_AU1X00
+	pr_debug(DRIVER_INFO " (Au1xxx)\n");
+
+	retval = driver_register(&ehci_hcd_au1xxx_driver);
+	if (retval < 0)
+		return retval;
+#endif
+
+#ifdef CONFIG_PCI
+	retval = pci_register_driver(&ehci_pci_driver);
+	if (retval < 0)
+		return retval;
+#endif
+
+	return retval;
+}
+
+static void __exit ehci_hcd_cleanup(void)
+{
+#ifdef CONFIG_PPC_83xx
+	platform_driver_unregister(&ehci_fsl_mph_driver);
+	platform_driver_unregister(&ehci_fsl_dr_driver);
+#endif
+#ifdef CONFIG_SOC_AU1X00
+	driver_unregister(&ehci_hcd_au1xxx_driver);
+#endif
+#ifdef CONFIG_PCI
+	pci_unregister_driver(&ehci_pci_driver);
+#endif
+}
+
+module_init(ehci_hcd_init);
+module_exit(ehci_hcd_cleanup);
+
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 1e03f1a..e0641bc 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -370,23 +370,3 @@ static struct pci_driver ehci_pci_driver
 	.resume =	usb_hcd_pci_resume,
 #endif
 };
-
-static int __init ehci_hcd_pci_init(void)
-{
-	if (usb_disabled())
-		return -ENODEV;
-
-	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
-		hcd_name,
-		sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
-		sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
-
-	return pci_register_driver(&ehci_pci_driver);
-}
-module_init(ehci_hcd_pci_init);
-
-static void __exit ehci_hcd_pci_cleanup(void)
-{
-	pci_unregister_driver(&ehci_pci_driver);
-}
-module_exit(ehci_hcd_pci_cleanup);


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [linux-usb-devel] compile error when building multiple EHCI host controllers as modules
  2006-04-05 17:32           ` Kumar Gala
@ 2006-04-10 19:11             ` David Brownell
  2006-04-10 19:16               ` Kumar Gala
  0 siblings, 1 reply; 12+ messages in thread
From: David Brownell @ 2006-04-10 19:11 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linux-usb-devel, Greg KH, LKML mailing list


> +
> +#ifdef CONFIG_PPC_83xx
> +	retval = platform_driver_register(&ehci_fsl_dr_driver);
> +	if (retval < 0)
> +		return retval;
> +
> +	retval = platform_driver_register(&ehci_fsl_dr_driver);
> +	if (retval < 0)
> +		return retval;
> +#endif
> +
> +#ifdef CONFIG_SOC_AU1X00
> +	pr_debug(DRIVER_INFO " (Au1xxx)\n");
> +
> +	retval = driver_register(&ehci_hcd_au1xxx_driver);
> +	if (retval < 0)
> +		return retval;
> +#endif

Can we just get away from all of that extra #ifdeffery?  

This is essentially the same patch you sent the first time.
With the same bugs ... like, not cleaning up the first driver
after errors registering the second one.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [linux-usb-devel] compile error when building multiple EHCI host controllers as modules
  2006-04-10 19:11             ` David Brownell
@ 2006-04-10 19:16               ` Kumar Gala
  2006-04-11 15:07                 ` [PATCH] usb: allow multiple types of EHCI controllers to be built " Kumar Gala
  0 siblings, 1 reply; 12+ messages in thread
From: Kumar Gala @ 2006-04-10 19:16 UTC (permalink / raw)
  To: David Brownell; +Cc: linux-usb-devel, Greg KH, LKML mailing list


On Apr 10, 2006, at 2:11 PM, David Brownell wrote:

>
>> +
>> +#ifdef CONFIG_PPC_83xx
>> +	retval = platform_driver_register(&ehci_fsl_dr_driver);
>> +	if (retval < 0)
>> +		return retval;
>> +
>> +	retval = platform_driver_register(&ehci_fsl_dr_driver);
>> +	if (retval < 0)
>> +		return retval;
>> +#endif
>> +
>> +#ifdef CONFIG_SOC_AU1X00
>> +	pr_debug(DRIVER_INFO " (Au1xxx)\n");
>> +
>> +	retval = driver_register(&ehci_hcd_au1xxx_driver);
>> +	if (retval < 0)
>> +		return retval;
>> +#endif
>
> Can we just get away from all of that extra #ifdeffery?
>
> This is essentially the same patch you sent the first time.
> With the same bugs ... like, not cleaning up the first driver
> after errors registering the second one.

Let me find a brown paper bag. The patch was suppose to be based on  
what you sent me fixed up to build and run for arch/powerpc...   
Clearly that's not the case. Let me work on a new version.

- k

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] usb: allow multiple types of EHCI controllers to be built as modules
  2006-04-10 19:16               ` Kumar Gala
@ 2006-04-11 15:07                 ` Kumar Gala
  0 siblings, 0 replies; 12+ messages in thread
From: Kumar Gala @ 2006-04-11 15:07 UTC (permalink / raw)
  To: David Brownell; +Cc: linux-usb-devel, Greg KH, LKML mailing list

In some systems we may have both a platform EHCI controller and PCI EHCI
controller.  Previously we couldn't build the EHCI support as a module due
to conflicting module_init() calls in the code.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

---
commit 7a5e244608d23e60f31e6c63bd69af3534ef38eb
tree 6957efcb7d12e5f56fbc318bf503dd7307a3d075
parent a145410dccdb44f81d3b56763ef9b6f721f4e47c
author Kumar Gala <galak@kernel.crashing.org> Tue, 11 Apr 2006 10:05:36 -0500
committer Kumar Gala <galak@kernel.crashing.org> Tue, 11 Apr 2006 10:05:36 -0500

 arch/powerpc/sysdev/fsl_soc.c     |   66 +++++++++++++++----------------------
 arch/ppc/syslib/mpc83xx_devices.c |    6 ++-
 drivers/usb/host/ehci-au1xxx.c    |   17 +---------
 drivers/usb/host/ehci-fsl.c       |   37 ++-------------------
 drivers/usb/host/ehci-hcd.c       |   48 +++++++++++++++++++++++++--
 drivers/usb/host/ehci-pci.c       |   20 -----------
 6 files changed, 78 insertions(+), 116 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index ceb5846..71a3275 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -372,7 +372,7 @@ static int __init fsl_usb_of_init(void)
 {
 	struct device_node *np;
 	unsigned int i;
-	struct platform_device *usb_dev;
+	struct platform_device *usb_dev_mph = NULL, *usb_dev_dr = NULL;
 	int ret;
 
 	for (np = NULL, i = 0;
@@ -393,15 +393,15 @@ static int __init fsl_usb_of_init(void)
 		r[1].end = np->intrs[0].line;
 		r[1].flags = IORESOURCE_IRQ;
 
-		usb_dev =
-		    platform_device_register_simple("fsl-usb2-mph", i, r, 2);
-		if (IS_ERR(usb_dev)) {
-			ret = PTR_ERR(usb_dev);
+		usb_dev_mph =
+		    platform_device_register_simple("fsl-ehci", i, r, 2);
+		if (IS_ERR(usb_dev_mph)) {
+			ret = PTR_ERR(usb_dev_mph);
 			goto err;
 		}
 
-		usb_dev->dev.coherent_dma_mask = 0xffffffffUL;
-		usb_dev->dev.dma_mask = &usb_dev->dev.coherent_dma_mask;
+		usb_dev_mph->dev.coherent_dma_mask = 0xffffffffUL;
+		usb_dev_mph->dev.dma_mask = &usb_dev_mph->dev.coherent_dma_mask;
 
 		usb_data.operating_mode = FSL_USB2_MPH_HOST;
 
@@ -417,31 +417,14 @@ static int __init fsl_usb_of_init(void)
 		usb_data.phy_mode = determine_usb_phy(prop);
 
 		ret =
-		    platform_device_add_data(usb_dev, &usb_data,
+		    platform_device_add_data(usb_dev_mph, &usb_data,
 					     sizeof(struct
 						    fsl_usb2_platform_data));
 		if (ret)
-			goto unreg;
+			goto unreg_mph;
 	}
 
-	return 0;
-
-unreg:
-	platform_device_unregister(usb_dev);
-err:
-	return ret;
-}
-
-arch_initcall(fsl_usb_of_init);
-
-static int __init fsl_usb_dr_of_init(void)
-{
-	struct device_node *np;
-	unsigned int i;
-	struct platform_device *usb_dev;
-	int ret;
-
-	for (np = NULL, i = 0;
+	for (np = NULL;
 	     (np = of_find_compatible_node(np, "usb", "fsl-usb2-dr")) != NULL;
 	     i++) {
 		struct resource r[2];
@@ -453,21 +436,21 @@ static int __init fsl_usb_dr_of_init(voi
 
 		ret = of_address_to_resource(np, 0, &r[0]);
 		if (ret)
-			goto err;
+			goto unreg_mph;
 
 		r[1].start = np->intrs[0].line;
 		r[1].end = np->intrs[0].line;
 		r[1].flags = IORESOURCE_IRQ;
 
-		usb_dev =
-		    platform_device_register_simple("fsl-usb2-dr", i, r, 2);
-		if (IS_ERR(usb_dev)) {
-			ret = PTR_ERR(usb_dev);
+		usb_dev_dr =
+		    platform_device_register_simple("fsl-ehci", i, r, 2);
+		if (IS_ERR(usb_dev_dr)) {
+			ret = PTR_ERR(usb_dev_dr);
 			goto err;
 		}
 
-		usb_dev->dev.coherent_dma_mask = 0xffffffffUL;
-		usb_dev->dev.dma_mask = &usb_dev->dev.coherent_dma_mask;
+		usb_dev_dr->dev.coherent_dma_mask = 0xffffffffUL;
+		usb_dev_dr->dev.dma_mask = &usb_dev_dr->dev.coherent_dma_mask;
 
 		usb_data.operating_mode = FSL_USB2_DR_HOST;
 
@@ -475,19 +458,22 @@ static int __init fsl_usb_dr_of_init(voi
 		usb_data.phy_mode = determine_usb_phy(prop);
 
 		ret =
-		    platform_device_add_data(usb_dev, &usb_data,
+		    platform_device_add_data(usb_dev_dr, &usb_data,
 					     sizeof(struct
 						    fsl_usb2_platform_data));
 		if (ret)
-			goto unreg;
+			goto unreg_dr;
 	}
-
 	return 0;
 
-unreg:
-	platform_device_unregister(usb_dev);
+unreg_dr:
+	if (usb_dev_dr)
+		platform_device_unregister(usb_dev_dr);
+unreg_mph:
+	if (usb_dev_mph)
+		platform_device_unregister(usb_dev_mph);
 err:
 	return ret;
 }
 
-arch_initcall(fsl_usb_dr_of_init);
+arch_initcall(fsl_usb_of_init);
diff --git a/arch/ppc/syslib/mpc83xx_devices.c b/arch/ppc/syslib/mpc83xx_devices.c
index 1af2c00..5c4932c 100644
--- a/arch/ppc/syslib/mpc83xx_devices.c
+++ b/arch/ppc/syslib/mpc83xx_devices.c
@@ -186,7 +186,7 @@ struct platform_device ppc_sys_platform_
 		},
 	},
 	[MPC83xx_USB2_DR] = {
-		.name = "fsl-usb2-dr",
+		.name = "fsl-ehci",
 		.id	= 1,
 		.num_resources	 = 2,
 		.resource = (struct resource[]) {
@@ -203,8 +203,8 @@ struct platform_device ppc_sys_platform_
 		},
 	},
 	[MPC83xx_USB2_MPH] = {
-		.name = "fsl-usb2-mph",
-		.id	= 1,
+		.name = "fsl-ehci",
+		.id	= 2,
 		.num_resources	 = 2,
 		.resource = (struct resource[]) {
 			{
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c
index 63eadee..0e444ab 100644
--- a/drivers/usb/host/ehci-au1xxx.c
+++ b/drivers/usb/host/ehci-au1xxx.c
@@ -272,6 +272,8 @@ static int ehci_hcd_au1xxx_drv_resume(st
 	return 0;
 }
 */
+MODULE_ALIAS("au1xxx-ehci");
+/* FIXME use "struct platform_driver" */
 static struct device_driver ehci_hcd_au1xxx_driver = {
 	.name = "au1xxx-ehci",
 	.bus = &platform_bus_type,
@@ -280,18 +282,3 @@ static struct device_driver ehci_hcd_au1
 	/*.suspend      = ehci_hcd_au1xxx_drv_suspend, */
 	/*.resume       = ehci_hcd_au1xxx_drv_resume, */
 };
-
-static int __init ehci_hcd_au1xxx_init(void)
-{
-	pr_debug(DRIVER_INFO " (Au1xxx)\n");
-
-	return driver_register(&ehci_hcd_au1xxx_driver);
-}
-
-static void __exit ehci_hcd_au1xxx_cleanup(void)
-{
-	driver_unregister(&ehci_hcd_au1xxx_driver);
-}
-
-module_init(ehci_hcd_au1xxx_init);
-module_exit(ehci_hcd_au1xxx_cleanup);
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index f985f12..a49a689 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -324,43 +324,12 @@ static int ehci_fsl_drv_remove(struct pl
 	return 0;
 }
 
-static struct platform_driver ehci_fsl_dr_driver = {
-	.probe = ehci_fsl_drv_probe,
-	.remove = ehci_fsl_drv_remove,
-	.driver = {
-		   .name = "fsl-usb2-dr",
-		   },
-};
+MODULE_ALIAS("fsl-ehci");
 
-static struct platform_driver ehci_fsl_mph_driver = {
+static struct platform_driver ehci_fsl_driver = {
 	.probe = ehci_fsl_drv_probe,
 	.remove = ehci_fsl_drv_remove,
 	.driver = {
-		   .name = "fsl-usb2-mph",
+		   .name = "fsl-ehci",
 		   },
 };
-
-static int __init ehci_fsl_init(void)
-{
-	int retval;
-
-	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
-		 hcd_name,
-		 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
-		 sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
-
-	retval = platform_driver_register(&ehci_fsl_dr_driver);
-	if (retval)
-		return retval;
-
-	return platform_driver_register(&ehci_fsl_mph_driver);
-}
-
-static void __exit ehci_fsl_cleanup(void)
-{
-	platform_driver_unregister(&ehci_fsl_mph_driver);
-	platform_driver_unregister(&ehci_fsl_dr_driver);
-}
-
-module_init(ehci_fsl_init);
-module_exit(ehci_fsl_cleanup);
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 79f2d8b..7d7c97c 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -889,19 +889,59 @@ MODULE_LICENSE ("GPL");
 
 #ifdef CONFIG_PCI
 #include "ehci-pci.c"
-#define	EHCI_BUS_GLUED
+#define	PCI_DRIVER		ehci_pci_driver
 #endif
 
 #ifdef CONFIG_PPC_83xx
 #include "ehci-fsl.c"
-#define	EHCI_BUS_GLUED
+#define	PLATFORM_DRIVER		ehci_fsl_driver
 #endif
 
 #ifdef CONFIG_SOC_AU1X00
 #include "ehci-au1xxx.c"
-#define	EHCI_BUS_GLUED
+#define	PLATFORM_DRIVER		ehci_hcd_au1xxx_driver
 #endif
 
-#ifndef	EHCI_BUS_GLUED
+#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER)
 #error "missing bus glue for ehci-hcd"
 #endif
+
+static int __init ehci_hcd_init(void)
+{
+	int retval = 0;
+
+	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
+		 hcd_name,
+		 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
+		 sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
+
+#ifdef PLATFORM_DRIVER
+	retval = platform_driver_register(&PLATFORM_DRIVER);
+	if (retval < 0)
+		return retval;
+#endif
+
+#ifdef PCI_DRIVER
+	retval = pci_register_driver(&PCI_DRIVER);
+	if (retval < 0) {
+#ifdef PLATFORM_DRIVER
+		platform_driver_unregister(&PLATFORM_DRIVER);
+#endif
+	}
+#endif
+
+	return retval;
+}
+module_init(ehci_hcd_init);
+
+static void __exit ehci_hcd_cleanup(void)
+{
+#ifdef PLATFORM_DRIVER
+	platform_driver_unregister(&PLATFORM_DRIVER);
+#endif
+#ifdef PCI_DRIVER
+	pci_unregister_driver(&PCI_DRIVER);
+#endif
+}
+module_exit(ehci_hcd_cleanup);
+
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 1e03f1a..e0641bc 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -370,23 +370,3 @@ static struct pci_driver ehci_pci_driver
 	.resume =	usb_hcd_pci_resume,
 #endif
 };
-
-static int __init ehci_hcd_pci_init(void)
-{
-	if (usb_disabled())
-		return -ENODEV;
-
-	pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
-		hcd_name,
-		sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
-		sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
-
-	return pci_register_driver(&ehci_pci_driver);
-}
-module_init(ehci_hcd_pci_init);
-
-static void __exit ehci_hcd_pci_cleanup(void)
-{
-	pci_unregister_driver(&ehci_pci_driver);
-}
-module_exit(ehci_hcd_pci_cleanup);


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-04-11 15:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-23 22:26 compile error when building multiple EHCI host controllers as modules Kumar Gala
2006-03-24  6:33 ` [linux-usb-devel] " David Brownell
2006-03-24 16:59   ` Kumar Gala
2006-03-24 20:32     ` Kumar Gala
2006-03-28 16:18       ` Kumar Gala
2006-03-28 17:51       ` Matthieu CASTET
2006-04-04  2:48       ` [linux-usb-devel] " David Brownell
2006-04-04  4:23         ` Kumar Gala
2006-04-05 17:32           ` Kumar Gala
2006-04-10 19:11             ` David Brownell
2006-04-10 19:16               ` Kumar Gala
2006-04-11 15:07                 ` [PATCH] usb: allow multiple types of EHCI controllers to be built " Kumar Gala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox