Re: [PATCH v2] mux: convert to use fwnode interface
From: Alvin Šipraga
Date: Fri Sep 25 2026 - 11:54:24 EST
On Wed, Sep 16, 2026 at 07:26:34PM +0200, Fabio Forni wrote:
> As firmware node is a more common abstract, this will convert the whole
> thing to fwnode interface.
>
> Co-developed-by: Xu Yang <xu.yang_2@xxxxxxx>
> Signed-off-by: Xu Yang <xu.yang_2@xxxxxxx>
> Signed-off-by: Fabio Forni <development@xxxxxxxxxx>
> ---
> This patch migrates the multiplexer subsystem from using the of_*
> family of functions and structs, to the more generic fwnode framework.
>
> It is a rebase of a single commit[1] contained in a old patch series[2]
> submitted by Xu Yang. The original commit plus follow-up comments were
> tested on kernel v6.12 on an arm64-based board, but this current rebase
> isn't tested yet.
>
> Link: https://lore.kernel.org/all/20220823195429.1243516-3-xu.yang_2@xxxxxxx [1]
> Link: https://lore.kernel.org/all/20220823195429.1243516-1-xu.yang_2@xxxxxxx [2]
> ---
> Changes in v2:
> - Rename devm_mux_state_get_from_swnode into devm_mux_state_get_from_fwnode
> - Link to v1: https://lore.kernel.org/r/20260915-mux_fwnode-v1-1-ed5a6d8202d4@xxxxxxxxxx
> ---
> drivers/mux/core.c | 96 ++++++++++++++++++-----------------
> drivers/pinctrl/pinctrl-generic-mux.c | 4 +-
> include/linux/mux/consumer.h | 6 ++-
> 3 files changed, 57 insertions(+), 49 deletions(-)
[...]
> static struct mux_control *mux_get(struct device *dev, const char *mux_name,
> unsigned int *state, bool optional,
> - struct device_node *node)
> + struct fwnode_handle *node)
> {
> - struct device_node *np = node ? node : dev->of_node;
> - struct of_phandle_args args;
> + struct fwnode_handle *fwnode = node ? node : dev_fwnode(dev);
> + struct fwnode_reference_args args;
> struct mux_chip *mux_chip;
> unsigned int controller;
> int index = 0;
> @@ -551,11 +552,13 @@ static struct mux_control *mux_get(struct device *dev, const char *mux_name,
>
> if (mux_name) {
> if (state)
> - index = of_property_match_string(np, "mux-state-names",
> - mux_name);
> + index = fwnode_property_match_string(fwnode,
> + "mux-state-names",
> + mux_name);
> else
> - index = of_property_match_string(np, "mux-control-names",
> - mux_name);
> + index = fwnode_property_match_string(fwnode,
> + "mux-control-names",
> + mux_name);
> if (index < 0 && optional) {
> return NULL;
> } else if (index < 0) {
> @@ -566,39 +569,40 @@ static struct mux_control *mux_get(struct device *dev, const char *mux_name,
> }
>
> if (state)
> - ret = of_parse_phandle_with_args(np,
> - "mux-states", "#mux-state-cells",
> - index, &args);
> + ret = fwnode_property_get_reference_args(fwnode, "mux-states",
> + "#mux-state-cells", 0,
> + index, &args);
> else
> - ret = of_parse_phandle_with_args(np,
> - "mux-controls", "#mux-control-cells",
> - index, &args);
> + ret = fwnode_property_get_reference_args(fwnode,
> + "mux-controls", "#mux-control-cells",
> + 0, index, &args);
> +
> if (ret) {
> if (optional && ret == -ENOENT)
> return NULL;
>
> - dev_err(dev, "%pOF: failed to get mux-%s %s(%i)\n",
> - np, state ? "state" : "control",
> - mux_name ?: "", index);
> + dev_err(dev, "%pfw: failed to get mux-%s %s(%i)\n",
> + fwnode, state ? "state" : "control", mux_name ?: "",
> + index);
> return ERR_PTR(ret);
> }
>
> - mux_chip = of_find_mux_chip_by_node(args.np);
> - of_node_put(args.np);
> + mux_chip = mux_chip_find_by_fwnode(args.fwnode);
> + fwnode_handle_put(args.fwnode);
I'm actually not sure why there was an of_node_put() here in the first
place. It seems wrong to me. Any idea what it's for?
I want to give a Reviewed-by here for the rest of the code, but if the
above _put() erroneous, it might be better to add a patch before this
one to remove it (and cc the stable list with that patch).
> if (!mux_chip)
> return ERR_PTR(-EPROBE_DEFER);
Kind regards,
Alvin