Re: [PATCH] usb: Kconfig: make USB_ULPI_BUS select USB_COMMON

From: Arnd Bergmann
Date: Tue Sep 13 2016 - 03:04:33 EST

On Tuesday, September 13, 2016 9:48:55 AM CEST Peter Chen wrote:
> On Mon, Sep 12, 2016 at 05:36:23PM +0200, Arnd Bergmann wrote:
> > Moving the CONFIG_USB_ULPI_BUS option to the top-level Kconfig file
> > means that we can enable it without any of the other USB support,
> > leading to a build error because Kbuild never enters the
> > drivers/usb/common/ directory without CONFIG_USB_COMMON:
> >
> > ERROR: "ulpi_unregister_driver" [drivers/phy/phy-tusb1210.ko] undefined!
> > ERROR: "__ulpi_register_driver" [drivers/phy/phy-tusb1210.ko] undefined!
> > ERROR: "ulpi_write" [drivers/phy/phy-tusb1210.ko] undefined!
> >
> Thanks, Arnd. I have submitted the fix.

I see you used 'depends on USB_COMMON' though instead of 'select USB_COMMON'.

This seems inconsistent with how we handle the other places after the patch
I did earlier this year [see below].

It probably works fine for now, but having a mix of 'depends on' and 'select'
can be confusing for users as well as create dependency loops that break
the build.


commit badf6d47f8a93098c6e05fdeb735b44b61877451
Author: Arnd Bergmann <arnd@xxxxxxxx>
Date: Wed Mar 23 17:45:08 2016 +0100

usb: common: rework CONFIG_USB_COMMON logic

The phy-am335x driver selects 'USB_COMMON', but all other drivers
use 'depends on' for that symbol, and it depends on USB || USB_GADGET
itself, which causes a Kconfig warning:

warning: (AM335X_PHY_USB) selects USB_COMMON which has unmet direct dependencies (USB_SUPPORT && (USB || USB_GADGET))

As suggested by Felipe Balbi, this turns the logic around, and makes
'USB_COMMON' selected by everything else that needs it, so we can
remove the dependencies.

Fixes: 59f042f644c5 ("usb: phy: phy-am335x: bypass first VBUS sensing for host-only mode")
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
Acked-by: Felipe Balbi <balbi@xxxxxxxxxx>
Reviewed-by: Peter Chen <peter.chen@xxxxxxx>
Signed-off-by: Felipe Balbi <felipe.balbi@xxxxxxxxxxxxxxx>

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 26566db09de0..e92b97cd6056 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -250,7 +250,8 @@ config PHY_SUN9I_USB
tristate "Allwinner sun9i SoC USB PHY driver"
depends on ARCH_SUNXI && HAS_IOMEM && OF
- depends on USB_COMMON
+ depends on USB_SUPPORT
+ select USB_COMMON
Enable this to support the transceiver that is part of Allwinner
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 8ed451dd651e..8689dcba5201 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -31,8 +31,6 @@ if USB_SUPPORT

- default y
- depends on USB || USB_GADGET

def_bool y
@@ -41,6 +39,7 @@ config USB_ARCH_HAS_HCD
config USB
tristate "Support for Host-side USB"
depends on USB_ARCH_HAS_HCD
+ select USB_COMMON
select NLS # for UTF-8 strings
Universal Serial Bus (USB) is a specification for a serial bus
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index af5d922a8f5d..2057add439f0 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -15,6 +15,7 @@

menuconfig USB_GADGET
tristate "USB Gadget Support"
+ select USB_COMMON
select NLS
USB is a master/slave protocol, organized with one master