Re: [PATCH v8 2/2] i2c: mux: Propagate firmware nodes to channel adapters
From: Andy Shevchenko
Date: Tue Sep 01 2026 - 05:20:31 EST
On Mon, Aug 31, 2026 at 10:22:07AM -0700, Ahmad Byagowi wrote:
> Device Tree channel nodes are associated with the adapters created by
> i2c-mux, but equivalent firmware-node descriptions are not.
>
> Use generic firmware-node operations for the existing channel lookup
> and associate the returned node with the adapter. Do not restrict the
> lookup by firmware-node type, so Device Tree, software nodes, and ACPI
> descriptions all follow the same property traversal. The existing
> acpi_preset_companion() call remains in place for the standard ACPI
> channel association.
>
> Keep a separate reference to the node returned by the generic lookup
> because acpi_preset_companion() may replace the device's primary
> firmware node. Release the saved reference after adapter deletion.
...
> if (muxc->arbitrator)
> - mux_node = of_get_child_by_name(dev_node, "i2c-arb");
> + mux_node = fwnode_get_named_child_node(dev_node, "i2c-arb");
> else if (muxc->gate)
> - mux_node = of_get_child_by_name(dev_node, "i2c-gate");
> + mux_node = fwnode_get_named_child_node(dev_node, "i2c-gate");
> else
> - mux_node = of_get_child_by_name(dev_node, "i2c-mux");
> + mux_node = fwnode_get_named_child_node(dev_node, "i2c-mux");
>
> if (mux_node) {
> - /* A "reg" property indicates an old-style DT entry */
> - if (!of_property_read_u32(mux_node, "reg", ®)) {
> - of_node_put(mux_node);
> + /* A "reg" property indicates an old-style firmware entry. */
> + if (!fwnode_property_read_u32(mux_node, "reg", ®)) {
> + fwnode_handle_put(mux_node);
Consider using __free(fwnode_handle) at some point. Perhaps as a patch
on top of this.
It also may help with the rest of the existing code elsewhere in the file.
> mux_node = NULL;
> }
> }
>
> if (!mux_node)
> - mux_node = of_node_get(dev_node);
> + mux_node = fwnode_handle_get(dev_node);
> else if (muxc->arbitrator || muxc->gate)
> return mux_node;
>
> - for_each_child_of_node(mux_node, child) {
> - ret = of_property_read_u32(child, "reg", ®);
> + fwnode_for_each_child_node(mux_node, child) {
> + ret = fwnode_property_read_u32(child, "reg", ®);
> if (ret)
> continue;
> if (chan_id == reg)
> break;
> }
>
> - of_node_put(mux_node);
> + fwnode_handle_put(mux_node);
> return child;
> }
--
With Best Regards,
Andy Shevchenko