Re: [PATCH v17 7/7] usb: Specify dependencies on USB_XHCI_PLATFORM with 'depends on'

From: Matthias Kaehlcke
Date: Thu Nov 18 2021 - 12:16:21 EST


On Tue, Nov 16, 2021 at 09:21:44PM -0500, Alan Stern wrote:
> On Tue, Nov 16, 2021 at 12:07:39PM -0800, Matthias Kaehlcke wrote:
> > Some USB controller drivers that depend on the xhci-plat driver
> > specify this dependency using 'select' in Kconfig. This is not
> > recommended for symbols that have other dependencies as it may
> > lead to invalid configurations. Use 'depends on' to specify the
> > dependency instead of 'select'.
> >
> > For dwc3 specify the dependency on USB_XHCI_PLATFORM in
> > USB_DWC3_HOST and USB_DWC3_DUAL_ROLE. Also adjust the
> > dependencies of USB_DWC3_CORE to make sure that at least one
> > of USB_DWC3_HOST, USB_DWC3_GADGET or USB_DWC3_DUAL_ROLE can be
> > selected.
> >
> > Signed-off-by: Matthias Kaehlcke <mka@xxxxxxxxxxxx>
> > Reviewed-by: Roger Quadros <rogerq@xxxxxxxxxx>
> > Reviewed-by: Douglas Anderson <dianders@xxxxxxxxxxxx>
> > ---
> >
> > Changes in v17:
> > - removed explicit dependency on USB from USB_DWC3
> > - added 'Reviewed-by' tags from Roger and Doug
> >
> > Changes in v16:
> > - none
> >
> > Changes in v15:
> > - adjusted dependencies of USB_DWC3_CORE to make sure it can only
> > be enabled when at least one of USB_DWC3_HOST, USB_DWC3_GADGET
> > or USB_DWC3_DUAL_ROLE is selectable
> > - updated commit message
> >
> > Changes in v14:
> > - none
> >
> > Changes in v13:
> > - patch added to the series
>
> > diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
> > index d1d926f8f9c2..e5e612f143a1 100644
> > --- a/drivers/usb/host/Kconfig
> > +++ b/drivers/usb/host/Kconfig
> > @@ -80,7 +80,7 @@ config USB_XHCI_MTK
> >
> > config USB_XHCI_MVEBU
> > tristate "xHCI support for Marvell Armada 375/38x/37xx"
> > - select USB_XHCI_PLATFORM
> > + depends on USB_XHCI_PLATFORM
> > depends on HAS_IOMEM
> > depends on ARCH_MVEBU || COMPILE_TEST
> > help
> > @@ -112,9 +112,9 @@ config USB_EHCI_BRCMSTB
> > config USB_BRCMSTB
> > tristate "Broadcom STB USB support"
> > depends on (ARCH_BRCMSTB && PHY_BRCM_USB) || COMPILE_TEST
> > + depends on !USB_XHCI_HCD || USB_XHCI_PLATFORM
> > select USB_OHCI_HCD_PLATFORM if USB_OHCI_HCD
> > select USB_EHCI_BRCMSTB if USB_EHCI_HCD
> > - select USB_XHCI_PLATFORM if USB_XHCI_HCD
> > help
> > Enables support for XHCI, EHCI and OHCI host controllers
> > found in Broadcom STB SoC's.
>
> It should be pointed out that this now requires people with xHCI systems
> to actively turn on CONFIG_USB_XHCI_PLATFORM before they can enable
> CONFIG_USB_BRCMSTB. Before, that was not necessary. Some users might
> get confused and not realize what is needed. Perhaps something should
> be added to the "help" text.

I agree that the change could cause confusion, I'm not sure though if
adding something to the "help" text is a good mitigation. Users won't see
the text unless they can select the option, which requires
CONFIG_USB_XHCI_PLATFORM to be enabled. Also the dependencies are specified
nearby (and displayed), so it seems similar to a code comment on something
that the code evidently does (e.g. "initialize foobar with 0").

On a different note: I'm considering to break the CONFIG_USB_XHCI_PLATFORM
related patches out of the onboard_usb_hub series, since the driver
doesn't any longer depend on xhci_plat. In that sense I'm also open
to abandon those patches, if they aren't considered an improvement on
their own.