Re: [PATCH v5 06/16] usb: hub: Associate port@ fwnode with USB port device
From: Chen-Yu Tsai
Date: Thu Jul 16 2026 - 00:32:02 EST
On Wed, Jul 15, 2026 at 5:20 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> On Wed, Jul 15, 2026 at 04:53:36PM +0800, Chen-Yu Tsai wrote:
> > When a USB hub port is connected to a connector in a firmware node
> > graph, the port itself has a node in the graph.
> >
> > Associate the port's firmware node with the USB port's device,
> > usb_port::dev. This is used in later changes for the M.2 slot power
> > sequencing provider to match against the requesting port.
> >
> > To avoid potential conflicts with ACPI firmware nodes and then causing
> > power management issues, only assign the firmware node if the hub's
> > firmware node is not an ACPI firmware node.
>
> ...
>
> > int usb_hub_create_port_device(struct usb_hub *hub, int port1)
>
> What about adding
>
> struct fwnode_handle *fwnode = dev_fwnode(&hdev->dev);
>
> to the top of the function, and...
>
> > port_dev->dev.driver = &usb_port_driver;
> > dev_set_name(&port_dev->dev, "%s-port%d", dev_name(&hub->hdev->dev),
> > port1);
> > + /*
> > + * ACPI FW nodes are associated later when device_register() happens.
> > + * Skip assigning one here to avoid potential conflicts.
> > + */
> > + if (!is_acpi_node(dev_fwnode(&hdev->dev)))
> > + device_set_node(&port_dev->dev,
> > + fwnode_graph_get_port_by_id(dev_fwnode(&hdev->dev), port1,
> > + FWNODE_GRAPH_DEVICE_DISABLED));
>
> ...shorten this a bit to
Makes sense.
> if (!is_acpi_node(fwnode)) {
> struct fwnode_handle *ep;
>
> ep = fwnode_graph_get_port_by_id(fwnode, port1, FWNODE_GRAPH_DEVICE_DISABLED);
>
> // Is NULL or error pointer is fine here to be set as fwnode in port device?
> // Perhaps add a comment?
fwnode_graph_get_port_by_id returns NULL, but not error pointers.
And passing NULL to device_set_node() basically erases the current
associated node (which is NULL anyway, since we just created the
device) so it's a no-op. I'll add a comment.
ChenYu
> device_set_node(&port_dev->dev, ep);
> }
>
> --
> With Best Regards,
> Andy Shevchenko
>
>