public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: Kumar Gala <galak@kernel.crashing.org>
Cc: linux-usb-devel@lists.sourceforge.net, Greg KH <gregkh@suse.de>,
	LKML mailing list <linux-kernel@vger.kernel.org>
Subject: Re: [linux-usb-devel] compile error when building multiple EHCI host controllers as modules
Date: Mon, 3 Apr 2006 19:48:37 -0700	[thread overview]
Message-ID: <200604031948.38101.david-b@pacbell.net> (raw)
In-Reply-To: <Pine.LNX.4.44.0603241429220.19557-100000@gate.crashing.org>

[-- 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[]) {
 			{

  parent reply	other threads:[~2006-04-04  2:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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       ` David Brownell [this message]
2006-04-04  4:23         ` [linux-usb-devel] " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200604031948.38101.david-b@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=galak@kernel.crashing.org \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox