Thread (30 messages) flat view 30 messages, 7 authors, 9h ago

Re: [PATCH v8 01/16] device property: Add fwnode_graph_get_port_by_id()

From: sashiko-bot@kernel.org
Date: 2026-09-04 08:54:19

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The newly added `fwnode_graph_get_port_by_id()` API takes a non-const `struct fwnode_handle *fwnode` parameter, which is inconsistent with similar API functions.
--

commit 5894c0b778c62e34e52132ac30ee27b4741eb588
Author: Chen-Yu Tsai [off-list ref]

device property: Add fwnode_graph_get_port_by_id()

This commit adds the fwnode_graph_get_port_by_id() helper to obtain a
reference to a specific port firmware node by ID. This helper is intended for
cases such as USB power sequencing integration where a USB hub port is tied to
its corresponding port firmware node.
quoted hunk ↗ jump to hunk
diff --git a/drivers/base/property.c b/drivers/base/property.c
index b136c339ddae7..68108805482de 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -1353,6 +1353,37 @@ int fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
 }
 EXPORT_SYMBOL(fwnode_graph_parse_endpoint);
 
+/**
+ * fwnode_graph_get_port_by_id - get the port matching a given id
+ * @fwnode: parent fwnode_handle containing the graph
+ * @id: id of the port
+ * @flags: fwnode lookup flags
+ *
+ * The caller is responsible for calling fwnode_handle_put() on the returned
+ * fwnode pointer.
+ *
+ * Does not return ports that belong to disabled devices or endpoints that
+ * are unconnected, unless FWNODE_GRAPH_DEVICE_DISABLED is passed in @flags.
+ *
+ * Does not return ports that have no endpoints.
+ *
+ * Return: A 'port' firmware node pointer with refcount incremented.
+ */
+struct fwnode_handle *fwnode_graph_get_port_by_id(struct fwnode_handle *fwnode,
+						  u32 id,
+						  unsigned long flags)
[Severity: Low]
Does this function signature intentionally drop the const qualifier for the
fwnode parameter? 

This is inconsistent with similar API functions like
fwnode_graph_get_endpoint_by_id() which take a const struct fwnode_handle *.
Callers holding a const struct fwnode_handle * cannot use this helper without
an explicit cast that discards the const qualifier, which reduces API
ergonomics.
+{
+	struct fwnode_handle *ep;
+
+	ep = fwnode_graph_get_endpoint_by_id(fwnode, id, 0,
+					     flags | FWNODE_GRAPH_ENDPOINT_NEXT);
+	if (!ep)
+		return NULL;
+
+	return fwnode_get_next_parent(ep);
+}
+EXPORT_SYMBOL_GPL(fwnode_graph_get_port_by_id);
+
 const void *device_get_match_data(const struct device *dev)
 {
 	return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev);
quoted hunk ↗ jump to hunk
diff --git a/include/linux/property.h b/include/linux/property.h
index 907c790a3f013..3dbbd01a52d09 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
[ ... ]
quoted hunk ↗ jump to hunk
@@ -507,6 +507,8 @@ int fwnode_get_phy_mode(const struct fwnode_handle *fwnode);
 
 void __iomem *fwnode_iomap(struct fwnode_handle *fwnode, int index);
 
+struct fwnode_handle *fwnode_graph_get_port_by_id(struct fwnode_handle *fwnode, u32 id,
+						  unsigned long flags);
[Severity: Low]
Should this declaration also use const struct fwnode_handle * for the fwnode
parameter to match the suggested change above and maintain consistency with
other fwnode_graph_* functions?
 struct fwnode_handle *fwnode_graph_get_next_endpoint(
 	const struct fwnode_handle *fwnode, struct fwnode_handle *prev);
 struct fwnode_handle *
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260904084158.1341550-1-wenst@chromium.org?part=1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help