2021-02-10 00:07:11

by Johan Jonker

[permalink] [raw]
Subject: [PATCH v5 2/8] usb: dwc3: of-simple: bail probe if no dwc3 child node

For some of the dwc3-of-simple compatible SoCs we
don't want to bind this driver to a dwc3 node,
but bind that node to the 'snps,dwc3' driver instead.
The kernel has no logic to decide which driver to bind
to if there are 2 matching drivers, so bail probe if no
dwc3 child node.

Signed-off-by: Johan Jonker <[email protected]>
---
drivers/usb/dwc3/dwc3-of-simple.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
index e62ecd22b..347b4d384 100644
--- a/drivers/usb/dwc3/dwc3-of-simple.c
+++ b/drivers/usb/dwc3/dwc3-of-simple.c
@@ -38,6 +38,10 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)

int ret;

+ /* Bail probe if no dwc3 child node. */
+ if (!of_get_compatible_child(dev->of_node, "snps,dwc3"))
+ return -ENODEV;
+
simple = devm_kzalloc(dev, sizeof(*simple), GFP_KERNEL);
if (!simple)
return -ENOMEM;
--
2.11.0


2021-03-24 16:47:18

by Heiko Stuebner

[permalink] [raw]
Subject: Re: [PATCH v5 2/8] usb: dwc3: of-simple: bail probe if no dwc3 child node

Hi Greg, Felipe,

Am Dienstag, 9. Februar 2021, 20:23:44 CET schrieb Johan Jonker:
> For some of the dwc3-of-simple compatible SoCs we
> don't want to bind this driver to a dwc3 node,
> but bind that node to the 'snps,dwc3' driver instead.
> The kernel has no logic to decide which driver to bind
> to if there are 2 matching drivers, so bail probe if no
> dwc3 child node.
>
> Signed-off-by: Johan Jonker <[email protected]>

It looks like this patch fell through the cracks?

I.e. I can see patches 1+6 adding the devicetree bindings
in 5.12-rc but haven't found this patch there.

And looking at
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/log/drivers/usb/dwc3/dwc3-of-simple.c?h=usb-next
I also didn't find it.

From what I gathered that was somehow mandated from the Devicetree side
as the dwc3-subnode system merely is some Linux-specific thingy
and should not be enforced if not explicitly needed.

I guess Johan can provide pointers to the previous discussion.

So could you look at applying this patch to some usb-tree?


Thanks
Heiko


> ---
> drivers/usb/dwc3/dwc3-of-simple.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
> index e62ecd22b..347b4d384 100644
> --- a/drivers/usb/dwc3/dwc3-of-simple.c
> +++ b/drivers/usb/dwc3/dwc3-of-simple.c
> @@ -38,6 +38,10 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
>
> int ret;
>
> + /* Bail probe if no dwc3 child node. */
> + if (!of_get_compatible_child(dev->of_node, "snps,dwc3"))
> + return -ENODEV;
> +
> simple = devm_kzalloc(dev, sizeof(*simple), GFP_KERNEL);
> if (!simple)
> return -ENOMEM;
>




2021-03-24 17:23:45

by Johan Jonker

[permalink] [raw]
Subject: Re: [PATCH v5 2/8] usb: dwc3: of-simple: bail probe if no dwc3 child node

On 3/24/21 5:41 PM, Heiko Stübner wrote:
> Hi Greg, Felipe,
>
> Am Dienstag, 9. Februar 2021, 20:23:44 CET schrieb Johan Jonker:
>> For some of the dwc3-of-simple compatible SoCs we
>> don't want to bind this driver to a dwc3 node,
>> but bind that node to the 'snps,dwc3' driver instead.
>> The kernel has no logic to decide which driver to bind
>> to if there are 2 matching drivers, so bail probe if no
>> dwc3 child node.
>>
>> Signed-off-by: Johan Jonker <[email protected]>
>
> It looks like this patch fell through the cracks?
>
> I.e. I can see patches 1+6 adding the devicetree bindings
> in 5.12-rc but haven't found this patch there.
>
> And looking at
> https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/log/drivers/usb/dwc3/dwc3-of-simple.c?h=usb-next
> I also didn't find it.
>
> From what I gathered that was somehow mandated from the Devicetree side
> as the dwc3-subnode system merely is some Linux-specific thingy
> and should not be enforced if not explicitly needed.
>

> I guess Johan can provide pointers to the previous discussion.

Comment by Rob in version 3:
Presumably you are getting lucky here (with link order). The kernel
has no logic to decide which driver to bind to if there are 2 matching
drivers. If we did, it would probably be the opposite of what you want
here as we'd pick the most specific match. This driver should probably
bail probe if no dwc3 child node.

https://lore.kernel.org/linux-rockchip/[email protected]/

https://lore.kernel.org/linux-rockchip/CAL_JsqJwNdUfoYM8SZmOgMG9iAyZkJ4-kzjjiDDm_mdmghTEOA@mail.gmail.com/

>
> So could you look at applying this patch to some usb-tree?
>
>
> Thanks
> Heiko
>
>
>> ---
>> drivers/usb/dwc3/dwc3-of-simple.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
>> index e62ecd22b..347b4d384 100644
>> --- a/drivers/usb/dwc3/dwc3-of-simple.c
>> +++ b/drivers/usb/dwc3/dwc3-of-simple.c
>> @@ -38,6 +38,10 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
>>
>> int ret;
>>
>> + /* Bail probe if no dwc3 child node. */
>> + if (!of_get_compatible_child(dev->of_node, "snps,dwc3"))
>> + return -ENODEV;
>> +
>> simple = devm_kzalloc(dev, sizeof(*simple), GFP_KERNEL);
>> if (!simple)
>> return -ENOMEM;
>>
>
>
>
>