[1/1] USB: OHCI: Fix definition overriding while registering Exynos OHCI driver

Message ID 1357533715-22911-1-git-send-email-sachin.kamat@linaro.org
State Rejected
Headers show

Commit Message

Sachin Kamat Jan. 7, 2013, 4:41 a.m.
Exynos OHCI driver does not get registered if generic OHCI driver
is also selected as the macro PLATFORM_DRIVER gets re-defined to
'ohci_platform_driver' instead of 'exynos_ohci_driver'. Hence define
it separately.

Also, silences the following compilation warnings:
drivers/usb/host/ohci-hcd.c:1191:0: warning:
"PLATFORM_DRIVER" redefined [enabled by default]
drivers/usb/host/ohci-hcd.c:1110:0: note:
this is the location of the previous definition
drivers/usb/host/ohci-exynos.c:276:31: warning:
‘exynos_ohci_driver’ defined but not used [-Wunused-variable]

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/usb/host/ohci-hcd.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

Comments

Alan Stern Jan. 7, 2013, 3:26 p.m. | #1
On Mon, 7 Jan 2013, Sachin Kamat wrote:

> Exynos OHCI driver does not get registered if generic OHCI driver
> is also selected as the macro PLATFORM_DRIVER gets re-defined to
> 'ohci_platform_driver' instead of 'exynos_ohci_driver'. Hence define
> it separately.
> 
> Also, silences the following compilation warnings:
> drivers/usb/host/ohci-hcd.c:1191:0: warning:
> "PLATFORM_DRIVER" redefined [enabled by default]
> drivers/usb/host/ohci-hcd.c:1110:0: note:
> this is the location of the previous definition
> drivers/usb/host/ohci-exynos.c:276:31: warning:
> ‘exynos_ohci_driver’ defined but not used [-Wunused-variable]

Why are you selecting both the Exynos and generic OHCI drivers at the 
same time?

Alan Stern
Sachin Kamat Jan. 7, 2013, 3:38 p.m. | #2
On Monday, 7 January 2013, Alan Stern <stern@rowland.harvard.edu> wrote:
> On Mon, 7 Jan 2013, Sachin Kamat wrote:
>
>> Exynos OHCI driver does not get registered if generic OHCI driver
>> is also selected as the macro PLATFORM_DRIVER gets re-defined to
>> 'ohci_platform_driver' instead of 'exynos_ohci_driver'. Hence define
>> it separately.
>>
>> Also, silences the following compilation warnings:
>> drivers/usb/host/ohci-hcd.c:1191:0: warning:
>> "PLATFORM_DRIVER" redefined [enabled by default]
>> drivers/usb/host/ohci-hcd.c:1110:0: note:
>> this is the location of the previous definition
>> drivers/usb/host/ohci-exynos.c:276:31: warning:
>> ‘exynos_ohci_driver’ defined but not used [-Wunused-variable]
>
> Why are you selecting both the Exynos and generic OHCI drivers at the
> same time?
>
I was experimenting selecting generic since that option is still available
after selecting Exynos. In case of other drivers like Omap, it worked
whereas in case of exynos it got overridden. Hence the patch to make it
behave like other drivers.

> Alan Stern
>
>
Alan Stern Jan. 7, 2013, 4:25 p.m. | #3
On Mon, 7 Jan 2013, Sachin Kamat wrote:

> On Monday, 7 January 2013, Alan Stern <stern@rowland.harvard.edu> wrote:
> > On Mon, 7 Jan 2013, Sachin Kamat wrote:
> >
> >> Exynos OHCI driver does not get registered if generic OHCI driver
> >> is also selected as the macro PLATFORM_DRIVER gets re-defined to
> >> 'ohci_platform_driver' instead of 'exynos_ohci_driver'. Hence define
> >> it separately.
> >>
> >> Also, silences the following compilation warnings:
> >> drivers/usb/host/ohci-hcd.c:1191:0: warning:
> >> "PLATFORM_DRIVER" redefined [enabled by default]
> >> drivers/usb/host/ohci-hcd.c:1110:0: note:
> >> this is the location of the previous definition
> >> drivers/usb/host/ohci-exynos.c:276:31: warning:
> >> ‘exynos_ohci_driver’ defined but not used [-Wunused-variable]
> >
> > Why are you selecting both the Exynos and generic OHCI drivers at the
> > same time?
> >
> I was experimenting selecting generic since that option is still available
> after selecting Exynos. In case of other drivers like Omap, it worked
> whereas in case of exynos it got overridden. Hence the patch to make it
> behave like other drivers.

I don't know what the OMAP driver does this differently.  The only real
reason would be if a board had two distinct kinds of OHCI controllers.  
If the Exynos board doesn't, the simplest approach is to change the
Kconfig file so as to make USB_OHCI_EXYNOS mutually exclusive with
USB_OHCI_HCD_PLATFORM.

However, I would much prefer to see a more general solution, like the
one that was recently merged for EHCI.  Convert ohci-hcd into a
platform-independent library module, and make ohci-exynos, ohci-omap,
and so on into separate driver modules that use the library's
facilities.

I believe Manjunath Goudar <manjunath.goudar@linaro.org> may already be 
working on this, under Deepak Saxena.

Alan Stern

Patch

diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 180a2b0..22b6ccd 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -1107,7 +1107,7 @@  MODULE_LICENSE ("GPL");
 
 #ifdef CONFIG_USB_OHCI_EXYNOS
 #include "ohci-exynos.c"
-#define PLATFORM_DRIVER		exynos_ohci_driver
+#define EXYNOS_PLATFORM_DRIVER		exynos_ohci_driver
 #endif
 
 #ifdef CONFIG_USB_OHCI_HCD_OMAP1
@@ -1193,6 +1193,7 @@  MODULE_LICENSE ("GPL");
 
 #if	!defined(PCI_DRIVER) &&		\
 	!defined(PLATFORM_DRIVER) &&	\
+	!defined(EXYNOS_PLATFORM_DRIVER) &&	\
 	!defined(OMAP1_PLATFORM_DRIVER) &&	\
 	!defined(OMAP3_PLATFORM_DRIVER) &&	\
 	!defined(OF_PLATFORM_DRIVER) &&	\
@@ -1235,6 +1236,12 @@  static int __init ohci_hcd_mod_init(void)
 		goto error_platform;
 #endif
 
+#ifdef EXYNOS_PLATFORM_DRIVER
+	retval = platform_driver_register(&EXYNOS_PLATFORM_DRIVER);
+	if (retval < 0)
+		goto error_exynos_platform;
+#endif
+
 #ifdef OMAP1_PLATFORM_DRIVER
 	retval = platform_driver_register(&OMAP1_PLATFORM_DRIVER);
 	if (retval < 0)
@@ -1304,6 +1311,10 @@  static int __init ohci_hcd_mod_init(void)
 	platform_driver_unregister(&PLATFORM_DRIVER);
  error_platform:
 #endif
+#ifdef EXYNOS_PLATFORM_DRIVER
+	platform_driver_unregister(&EXYNOS_PLATFORM_DRIVER);
+ error_exynos_platform:
+#endif
 #ifdef OMAP1_PLATFORM_DRIVER
 	platform_driver_unregister(&OMAP1_PLATFORM_DRIVER);
  error_omap1_platform: