Re: [PATCH v6 09/10] usb: dwc3: qcom: Detect DWC3 DT-nodes with "usb"-prefixed names
From: Serge Semin
Date: Wed Feb 10 2021 - 13:49:14 EST
On Wed, Feb 10, 2021 at 12:17:27PM -0600, Rob Herring wrote:
> On Wed, Feb 10, 2021 at 11:29 AM Serge Semin
> <Sergey.Semin@xxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > In accordance with the USB HCD/DRD schema all the USB controllers are
> > supposed to have DT-nodes named with prefix "^usb(@.*)?". Since the
> > existing DT-nodes will be renamed in a subsequent patch let's first make
> > sure the DWC3 Qualcomm driver supports them and second falls back to the
> > deprecated naming so not to fail on the legacy DTS-files passed to the
> > newer kernels.
> >
> > Signed-off-by: Serge Semin <Sergey.Semin@xxxxxxxxxxxxxxxxxxxx>
> > Reviewed-by: Bjorn Andersson <bjorn.andersson@xxxxxxxxxx>
> > ---
> > drivers/usb/dwc3/dwc3-qcom.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> > index c703d552bbcf..49ad8d507d37 100644
> > --- a/drivers/usb/dwc3/dwc3-qcom.c
> > +++ b/drivers/usb/dwc3/dwc3-qcom.c
> > @@ -630,7 +630,8 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
> > struct device *dev = &pdev->dev;
> > int ret;
> >
> > - dwc3_np = of_get_child_by_name(np, "dwc3");
> > + dwc3_np = of_get_child_by_name(np, "usb") ?:
> > + of_get_child_by_name(np, "dwc3");
>
> Is there some reason using compatible instead wouldn't work here?
I don't know for sure. The fix has been requested in the framework of
this discussion:
https://lore.kernel.org/linux-usb/20201020115959.2658-30-Sergey.Semin@xxxxxxxxxxxxxxxxxxxx/#t
by the driver maintainer Bjorn. To get a firm answer it's better to
have him asked. As I see it having of_get_compatible_child() utilized
here would also work. At least for the available in kernel dt-files.
See the affected dts-es in:
https://lore.kernel.org/linux-usb/20210210172850.20849-11-Sergey.Semin@xxxxxxxxxxxxxxxxxxxx/
A problem may happen if some older versions of DTS-es had another
compatible string in the dwc3 sub-node...
-Sergey
>
> Rob