[PATCH v2 02/16] device property: Add fwnode_graph_get_next_port_endpoint()
Andy Shevchenko
andriy.shevchenko at linux.intel.com
Wed Jun 10 07:08:48 PDT 2026
On Wed, Jun 10, 2026 at 04:40:36PM +0800, Chen-Yu Tsai wrote:
> Due to design constraints of the power sequencing API, the consumer
> must first be sure that the other side is actually a provider, or it
> will continually get -EPROBE_DEFER when requesting the power
> sequencing descriptor.
>
> In the upcoming USB power sequencing integration, the USB hub driver
> first needs to check whether a graph connection exists, and whether
> the other side of the connection is a supported connector type. The
> USB port is tied to a "port" firmware node, and this new helper will
> be used to get the endpoint under the known "port" firmware node.
...
> +/**
> + * fwnode_graph_get_next_port_endpoint - Get next endpoint firmware node in port
> + * @port: Pointer to the target port firmware node
> + * @prev: Previous endpoint node or %NULL to get the first
> + *
> + * The caller is responsible for calling fwnode_handle_put() on the returned
> + * fwnode pointer. Note that this function also puts a reference to @prev
> + * unconditionally.
> + *
> + * Return: an endpoint firmware node pointer or %NULL if no more endpoints
> + * are available.
Yeah, you see, even here is inconsistency with previously added kernel-doc.
> + */
> +struct fwnode_handle *fwnode_graph_get_next_port_endpoint(const struct fwnode_handle *port,
> + struct fwnode_handle *prev)
> +{
> + struct fwnode_handle *ep;
Unused?
> + while (1) {
This is usually harder to read and follow. It's like "pay much attention on
the code", but here no rocket science, no code to really pay attention to.
> + prev = fwnode_get_next_child_node(port, prev);
> + if (!prev)
> + break;
> +
> + if (WARN(!fwnode_name_eq(prev, "endpoint"),
> + "non endpoint node is used (%pfw)", prev))
> + continue;
> +
> + break;
> + }
> +
> + return prev;
> +}
So, this can be rewritten as
ep = prev;
do {
ep = fwnode_get_next_child_node(port, ep);
if (fwnode_name_eq(ep, "endpoint"))
break;
WARN_ON(ep, ...);
} while (ep);
return ep;
But also big question why? to WARN*(). There is no use in the entire
property.c.
--
With Best Regards,
Andy Shevchenko
More information about the linux-arm-kernel
mailing list