when any driver using usb_bus_start_enum() is
enabled in a build with CONFIG_USB=m, we will
have a build error because of usb_bus_start_enum()
will be compiled into a module (usbcore) and
the driver (phy-fsm-usb.c or phy-isp1301-omap.c)
will be statically linked to the kernel.

The easiest fix in this situation is to move the
definition of usb_bus_start_enum() to usb-common.c
(since it can be used by both host or gadget roles),
and make that a boolean config option, instead of
tristate.

This is another example where usage of 'select'
creates problems.

Cc: <sta...@vger.kernel.org>
Stephen Rothwell <s...@canb.auug.org.au>
Signed-off-by: Felipe Balbi <ba...@ti.com>
---

I was originally against hiding CONFIG_USB_OTG (and
CONFIG_USB_PHY for that matter) for this specific reason.

When people rely on select to enable things they want,
there's a rather high probability of some dependencies
getting messed up and linux-next having build problems.

Greg, let me know if this patch is acceptable for you -rc
cycle, note that it fixes a build error with allmodconfig,
possibly in any arch.

 drivers/usb/Kconfig      |  2 +-
 drivers/usb/core/hcd.c   | 41 -----------------------------------------
 drivers/usb/usb-common.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+), 42 deletions(-)

diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 2642b8a..42d9970b 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -40,7 +40,7 @@ menuconfig USB_SUPPORT
 if USB_SUPPORT
 
 config USB_COMMON
-       tristate
+       bool
        default y
        depends on USB || USB_GADGET
 
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 6bffb8c..bed909f 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2277,47 +2277,6 @@ EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub);
 
 /*-------------------------------------------------------------------------*/
 
-#ifdef CONFIG_USB_OTG
-
-/**
- * usb_bus_start_enum - start immediate enumeration (for OTG)
- * @bus: the bus (must use hcd framework)
- * @port_num: 1-based number of port; usually bus->otg_port
- * Context: in_interrupt()
- *
- * Starts enumeration, with an immediate reset followed later by
- * khubd identifying and possibly configuring the device.
- * This is needed by OTG controller drivers, where it helps meet
- * HNP protocol timing requirements for starting a port reset.
- *
- * Return: 0 if successful.
- */
-int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num)
-{
-       struct usb_hcd          *hcd;
-       int                     status = -EOPNOTSUPP;
-
-       /* NOTE: since HNP can't start by grabbing the bus's address0_sem,
-        * boards with root hubs hooked up to internal devices (instead of
-        * just the OTG port) may need more attention to resetting...
-        */
-       hcd = container_of (bus, struct usb_hcd, self);
-       if (port_num && hcd->driver->start_port_reset)
-               status = hcd->driver->start_port_reset(hcd, port_num);
-
-       /* run khubd shortly after (first) root port reset finishes;
-        * it may issue others, until at least 50 msecs have passed.
-        */
-       if (status == 0)
-               mod_timer(&hcd->rh_timer, jiffies + msecs_to_jiffies(10));
-       return status;
-}
-EXPORT_SYMBOL_GPL(usb_bus_start_enum);
-
-#endif
-
-/*-------------------------------------------------------------------------*/
-
 /**
  * usb_hcd_irq - hook IRQs to HCD framework (bus glue)
  * @irq: the IRQ being raised
diff --git a/drivers/usb/usb-common.c b/drivers/usb/usb-common.c
index d771870..f6f6f57 100644
--- a/drivers/usb/usb-common.c
+++ b/drivers/usb/usb-common.c
@@ -14,6 +14,8 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/usb.h>
+#include <linux/usb/hcd.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/of.h>
 #include <linux/usb/otg.h>
@@ -141,4 +143,46 @@ EXPORT_SYMBOL_GPL(of_usb_get_maximum_speed);
 
 #endif
 
+#ifdef CONFIG_USB_OTG
+
+/**
+ * usb_bus_start_enum - start immediate enumeration (for OTG)
+ * @bus: the bus (must use hcd framework)
+ * @port_num: 1-based number of port; usually bus->otg_port
+ * Context: in_interrupt()
+ *
+ * Starts enumeration, with an immediate reset followed later by
+ * khubd identifying and possibly configuring the device.
+ * This is needed by OTG controller drivers, where it helps meet
+ * HNP protocol timing requirements for starting a port reset.
+ *
+ * Return: 0 if successful.
+ */
+int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num)
+{
+       struct usb_hcd          *hcd;
+       int                     status = -EOPNOTSUPP;
+
+       /* NOTE: since HNP can't start by grabbing the bus's address0_sem,
+        * boards with root hubs hooked up to internal devices (instead of
+        * just the OTG port) may need more attention to resetting...
+        */
+       hcd = container_of (bus, struct usb_hcd, self);
+       if (port_num && hcd->driver->start_port_reset)
+               status = hcd->driver->start_port_reset(hcd, port_num);
+
+       /* run khubd shortly after (first) root port reset finishes;
+        * it may issue others, until at least 50 msecs have passed.
+        */
+       if (status == 0)
+               mod_timer(&hcd->rh_timer, jiffies + msecs_to_jiffies(10));
+       return status;
+}
+EXPORT_SYMBOL_GPL(usb_bus_start_enum);
+
+#endif
+
+/*-------------------------------------------------------------------------*/
+
+
 MODULE_LICENSE("GPL");
-- 
1.8.4.GIT

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

Reply via email to