am33xx: board: Refactor USB initialization into separate function
authorAlexandru Gagniuc <alex.g@adaptrum.com>
Tue, 7 Feb 2017 03:17:33 +0000 (19:17 -0800)
committerTom Rini <trini@konsulko.com>
Wed, 12 Jul 2017 02:49:39 +0000 (22:49 -0400)
The declaration of otg*_plat and otg*_board_data is guarded by
CONFIG_USB_MUSB_*, but their use in arch_misc_init is not. The
ifdef flow goes something like:

if (CONFIG_USB_MUSB_* && other_conditions)
declare usb_data
if (other_conditions)
use usb_data

Thus when CONFIG_USB_MUSB_* is not declared, we try to use the
data structures, but these structures aren't defined.

To fix this, move the USB initialization code into the same #ifdef
which guards the declaration of the data structures. Since the DM_USB
vs legacy cases are completely different, use two versions of
arch_misc_init(), for readability.

Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
arch/arm/mach-omap2/am33xx/board.c

index db757d91fbfea2752744b8ff1f5f712672bd0733..913a44ad64b4f0ece107a4c88ad17e13cc431504 100644 (file)
@@ -213,11 +213,9 @@ static struct musb_hdrc_platform_data otg1_plat = {
        .board_data     = &otg1_board_data,
 };
 #endif
-#endif
 
 int arch_misc_init(void)
 {
-#ifndef CONFIG_DM_USB
 #ifdef CONFIG_AM335X_USB0
        musb_register(&otg0_plat, &otg0_board_data,
                (void *)USB0_OTG_BASE);
@@ -226,7 +224,13 @@ int arch_misc_init(void)
        musb_register(&otg1_plat, &otg1_board_data,
                (void *)USB1_OTG_BASE);
 #endif
-#else
+       return 0;
+}
+
+#else  /* CONFIG_USB_MUSB_* && CONFIG_AM335X_USB* && !CONFIG_DM_USB */
+
+int arch_misc_init(void)
+{
        struct udevice *dev;
        int ret;
 
@@ -241,10 +245,12 @@ int arch_misc_init(void)
                return ret;
        }
 #endif
-#endif
+
        return 0;
 }
 
+#endif /* CONFIG_USB_MUSB_* && CONFIG_AM335X_USB* && !CONFIG_DM_USB */
+
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
 /*
  * In the case of non-SPL based booting we'll want to call these