Re: [PATCH] USB: of: filter disabled device node

From: jerry xzq

Date: Sat Nov 22 2025 - 07:54:49 EST


On Sat, Nov 22, 2025 at 8:32 PM Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Sat, Nov 22, 2025 at 07:49:02PM +0800, jerry xzq wrote:
> > On Sat, Nov 22, 2025 at 7:32 PM Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
> > >
> > > On Sat, Nov 22, 2025 at 07:25:39PM +0800, Zhengqiao Xia wrote:
> > > > We should not point the of_node of a USB device to a disabled devicetree
> > > > node. Otherwise, the interface under this USB device will not be able
> > > > to register.
> > >
> > > Why would a USB device point to a disabled device tree node? Shouldn't
> > > the device tree be fixed instead?
> >
> > According to your suggestion, when a USB device is directly connected
> > to a USB port,
> > we should delete the unused USB hub node instead of disabling it?
>
> Why are you using device tree to describe USB devices at all? What is
> the root problem here that you are trying to solve?

Our device follows a public board that has a USB hub, which is
described in dtsi as a USB hub node.
However, our device only has a USB device, not a USB hub, so I
disabled the USB hub node in our device's DTS.
&xhci3 {
status = "okay";

/* 2.x hub on port 1 */
usb_hub_2_x: hub@1 {
compatible = "usbbda,5411";
reg = <1>;
vdd-supply = <&pp3300_s3>;
peer-hub = <&usb_hub_3_x>;

-----> status = "disabled";

ports {
#address-cells = <1>;
#size-cells = <0>;
port@1 {
reg = <1>;
usb_hub_dsp1_hs: endpoint { };
};
port@2 {
reg = <2>;
usb_hub_dsp2_hs: endpoint { };
};
port@3 {
reg = <3>;
usb_hub_dsp3_hs: endpoint { };
};
port@4 {
reg = <4>;

/* On-board WWAN card */
usb_hub_dsp4_hs: endpoint { };
};
};
};
Then, during use, it was discovered that the LTE device's of_node
pointed to the hub(hub@1).
However, due to the existence of this piece of code, USB interface
cannot be registered.

if (intf->dev.of_node &&
!of_device_is_available(intf->dev.of_node)) {
dev_info(&dev->dev, "skipping disabled interface %d\n",
intf->cur_altsetting->desc.bInterfaceNumber);
continue;
}

When the upgrade program for an LTE device calls the USB character device,
because this LTE interface was not registered, a null pointer
exception was encountered, causing a restart.

please refer to
https://lore.kernel.org/all/20251114141821.416835-1-xiazhengqiao@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/

>
> The use of USB in DT should be _VERY_ limited, if at all. You should
> only do so for very good reasons in very limited situations. If this
> starts to get abused, we'll just have to rip it all out :(
>
> thanks,
>
> greg k-h

thanks.