From nobody Fri Sep 25 04:44:55 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31CA54D37CD; Wed, 16 Sep 2026 17:26:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789579598; cv=none; b=ahRm79e2kkZB5kTxXx0QabQv32ngh33WUe/Oe6EesRA9PMsuk5ECEFRK78fh2ur2sR1MzhHCJrLkPC1axuE1/WZU+A4yW7kdunkbhtejCQilpwMd4FFsiOGAQAEf34ej0iN0KebwWKRB4n7rzUWPDThtQDbTLbHnqtMIpUYy/LU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789579598; c=relaxed/simple; bh=jt2k1mqMUdsYDppKroF+YI7Hrr/djy+41Ohu661cpSs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=hWeM1EuY/zyD0nOM2Ss9XWQQWsqVRJfPM8BCEvJ+oRRRnc8JX0Gxzf9FUhMGK0DnP/UKGYcW8UTQJGAg/5Nnyb5ZoKKPdvvULpijw8ZzFKOgbLOZMX+f/6nI+wQG14KxTMzaObowkLsRQeyUXI0+/mVRhs3QnWdFPg92DjvbXu8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=olfKpBkn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="olfKpBkn" Received: by smtp.kernel.org (Postfix) with ESMTPS id B1F4BC2BCC7; Wed, 16 Sep 2026 17:26:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1789579597; bh=jt2k1mqMUdsYDppKroF+YI7Hrr/djy+41Ohu661cpSs=; h=From:Date:Subject:To:Cc:Reply-To:From; b=olfKpBknSOX9+oDs6TtOv8NZ8hIIwj0EF2PmrXT/naLw4fV8lsJwRto+HYbruEVtf ir8wbQZsx3Lzk0OFcMhEG3+L0nRWi6bdPf9eGiMwzFmDxAGof74bTAnZvZGLOKrWBR qLSHJDBfq35+9NwxrjGmJDvhGajBNdtel1JGcImB2URMbot4fGqZRbx7fml7v2Ho4f a8QrIE2N3rnndWd2F5SCkrPrrRluVWfvWfXdWnsJbaZuZvuBSjcc86K1ZO3ksPYfC6 xUzo736q5T3+BrtWfTi1LXswdqNg9B9QRj/c1EiITfGy2PX9aIXPzUOTcra0RyGBli O3ogRi64ZjPHw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85B91C982CC; Wed, 16 Sep 2026 17:26:37 +0000 (UTC) From: Fabio Forni via B4 Relay Date: Wed, 16 Sep 2026 19:26:34 +0200 Subject: [PATCH v2] mux: convert to use fwnode interface Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260916-mux_fwnode-v2-1-58f1d85b9dde@redaril.me> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/22MQQ7CIBBFr9LMWkyhQsSV9zCNIZ3BTmKpAcWah ruLXbt8/+e9FRJFpgSnZoVImRPPoYLaNTCMLtxIMFYG1SrTWqnF9Fqu/h1mJOGk0bYbOus9QhU ekTwvW+zSVx45Pef42dpZ/ta/mSyFFITaGTzWHw/nSOgi3/cTQV9K+QLFJ7nUpQAAAA== X-Change-ID: 20260915-mux_fwnode-a16593c39ffd To: Peter Rosin , Linus Walleij Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, xu.yang_2@nxp.com, Fabio Forni X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=12830; i=development@redaril.me; h=from:subject:message-id; bh=GL/ALRt0wncLq4wJ04HBV6uKvlKSN4oYTvvfkhGNjOk=; b=owGbwMvMwCXWeKho1tqFWemMp9WSGLJWXfQpWGN2YU7hreBe5m8sMYYvV4oGWGeqyPRlHlu97 Udi5q09HaUsDGJcDLJiiiz/nYw2dZuZGN3ql6iFmcPKBDKEgYtTACbydxUjw1PpfZVtzhKbd61d K1F5cNXm6w/2nwpc2crMPrXsnpD5OmuGf1oevVklq04lygvnaSV+0LI/FLGAvYP33RzLLxzzNBa XswMA X-Developer-Key: i=development@redaril.me; a=openpgp; fpr=FF4232B28B363432DA8F187D81C2729AADA16A67 X-Endpoint-Received: by B4 Relay for development@redaril.me/default with auth_id=1033 X-Original-From: Fabio Forni Reply-To: development@redaril.me From: Fabio Forni As firmware node is a more common abstract, this will convert the whole thing to fwnode interface. Co-developed-by: Xu Yang Signed-off-by: Xu Yang Signed-off-by: Fabio Forni --- This patch migrates the multiplexer subsystem from using the of_* =20 family of functions and structs, to the more generic fwnode framework. =20 =20 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. =20 =20 Link: https://lore.kernel.org/all/20220823195429.1243516-3-xu.yang_2@nxp.co= m [1] Link: https://lore.kernel.org/all/20220823195429.1243516-1-xu.yang_2@nxp.co= m [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-ed5a6d8202= d4@redaril.me --- 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(-) diff --git a/drivers/mux/core.c b/drivers/mux/core.c index 5083e3d19606..56096a9139bd 100644 --- a/drivers/mux/core.c +++ b/drivers/mux/core.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include =20 /* @@ -118,6 +118,7 @@ struct mux_chip *mux_chip_alloc(struct device *dev, mux_chip->dev.type =3D &mux_type; mux_chip->dev.parent =3D dev; mux_chip->dev.of_node =3D dev->of_node; + mux_chip->dev.fwnode =3D dev->fwnode; dev_set_drvdata(&mux_chip->dev, mux_chip); =20 mux_chip->id =3D ida_alloc(&mux_ida, GFP_KERNEL); @@ -517,11 +518,11 @@ int mux_state_deselect(struct mux_state *mstate) EXPORT_SYMBOL_GPL(mux_state_deselect); =20 /* Note this function returns a reference to the mux_chip dev. */ -static struct mux_chip *of_find_mux_chip_by_node(struct device_node *np) +static struct mux_chip *mux_chip_find_by_fwnode(struct fwnode_handle *fwno= de) { struct device *dev; =20 - dev =3D class_find_device_by_of_node(&mux_class, np); + dev =3D class_find_device_by_fwnode(&mux_class, fwnode); =20 return dev ? to_mux_chip(dev) : NULL; } @@ -533,17 +534,17 @@ static struct mux_chip *of_find_mux_chip_by_node(stru= ct device_node *np) * @state: Pointer to where the requested state is returned, or NULL when * the required multiplexer states are handled by other means. * @optional: Whether to return NULL and silence errors when mux doesn't e= xist. - * @node: the device nodes, use dev->of_node if it is NULL. + * @node: the device nodes, use dev's fwnode if it is NULL. * * Return: Pointer to the mux-control on success, an ERR_PTR with a negati= ve * errno on error, or NULL if optional is true and mux doesn't exist. */ static struct mux_control *mux_get(struct device *dev, const char *mux_nam= e, unsigned int *state, bool optional, - struct device_node *node) + struct fwnode_handle *node) { - struct device_node *np =3D node ? node : dev->of_node; - struct of_phandle_args args; + struct fwnode_handle *fwnode =3D node ? node : dev_fwnode(dev); + struct fwnode_reference_args args; struct mux_chip *mux_chip; unsigned int controller; int index =3D 0; @@ -551,11 +552,13 @@ static struct mux_control *mux_get(struct device *dev= , const char *mux_name, =20 if (mux_name) { if (state) - index =3D of_property_match_string(np, "mux-state-names", - mux_name); + index =3D fwnode_property_match_string(fwnode, + "mux-state-names", + mux_name); else - index =3D of_property_match_string(np, "mux-control-names", - mux_name); + index =3D 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, } =20 if (state) - ret =3D of_parse_phandle_with_args(np, - "mux-states", "#mux-state-cells", - index, &args); + ret =3D fwnode_property_get_reference_args(fwnode, "mux-states", + "#mux-state-cells", 0, + index, &args); else - ret =3D of_parse_phandle_with_args(np, - "mux-controls", "#mux-control-cells", - index, &args); + ret =3D fwnode_property_get_reference_args(fwnode, + "mux-controls", "#mux-control-cells", + 0, index, &args); + if (ret) { if (optional && ret =3D=3D -ENOENT) return NULL; =20 - 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); } =20 - mux_chip =3D of_find_mux_chip_by_node(args.np); - of_node_put(args.np); + mux_chip =3D mux_chip_find_by_fwnode(args.fwnode); + fwnode_handle_put(args.fwnode); if (!mux_chip) return ERR_PTR(-EPROBE_DEFER); =20 controller =3D 0; if (state) { - if (args.args_count > 2 || args.args_count =3D=3D 0 || - (args.args_count < 2 && mux_chip->controllers > 1)) { - dev_err(dev, "%pOF: wrong #mux-state-cells for %pOF\n", - np, args.np); + if (args.nargs > 2 || args.nargs =3D=3D 0 || + (args.nargs < 2 && mux_chip->controllers > 1)) { + dev_err(dev, "%pfw: wrong #mux-state-cells for %pfw\n", + fwnode, args.fwnode); put_device(&mux_chip->dev); return ERR_PTR(-EINVAL); } =20 - if (args.args_count =3D=3D 2) { + if (args.nargs =3D=3D 2) { controller =3D args.args[0]; *state =3D args.args[1]; } else { @@ -606,21 +610,21 @@ static struct mux_control *mux_get(struct device *dev= , const char *mux_name, } =20 } else { - if (args.args_count > 1 || - (!args.args_count && mux_chip->controllers > 1)) { - dev_err(dev, "%pOF: wrong #mux-control-cells for %pOF\n", - np, args.np); + if (args.nargs > 1 || + (!args.nargs && mux_chip->controllers > 1)) { + dev_err(dev, "%pfw: wrong #mux-control-cells for %pfw\n", + fwnode, args.fwnode); put_device(&mux_chip->dev); return ERR_PTR(-EINVAL); } =20 - if (args.args_count) + if (args.nargs) controller =3D args.args[0]; } =20 if (controller >=3D mux_chip->controllers) { - dev_err(dev, "%pOF: bad mux controller %u specified in %pOF\n", - np, controller, args.np); + dev_err(dev, "%pfw: bad mux controller %u specified in %pfw\n", + fwnode, controller, args.fwnode); put_device(&mux_chip->dev); return ERR_PTR(-EINVAL); } @@ -714,14 +718,14 @@ EXPORT_SYMBOL_GPL(devm_mux_control_get); * @dev: The device that needs a mux-state. * @mux_name: The name identifying the mux-state. * @optional: Whether to return NULL and silence errors when mux doesn't e= xist. - * @np: the device nodes, use dev->of_node if it is NULL. + * @node: the device nodes, use dev's fwnode if it is NULL. * * Return: Pointer to the mux-state on success, an ERR_PTR with a negative * errno on error, or NULL if optional is true and mux doesn't exist. */ static struct mux_state * mux_state_get(struct device *dev, const char *mux_name, bool optional, - struct device_node *np) + struct fwnode_handle *node) { struct mux_state *mstate; =20 @@ -729,7 +733,7 @@ mux_state_get(struct device *dev, const char *mux_name,= bool optional, if (!mstate) return ERR_PTR(-ENOMEM); =20 - mstate->mux =3D mux_get(dev, mux_name, &mstate->state, optional, np); + mstate->mux =3D mux_get(dev, mux_name, &mstate->state, optional, node); if (IS_ERR(mstate->mux)) { int err =3D PTR_ERR(mstate->mux); =20 @@ -771,7 +775,7 @@ static void devm_mux_state_release(struct device *dev, = void *res) * @dev: The device that needs a mux-state. * @mux_name: The name identifying the mux-state. * @optional: Whether to return NULL and silence errors when mux doesn't e= xist. - * @np: The device nodes, use dev->of_node if it is NULL. + * @node: The device nodes, use dev's fwnode if it is NULL. * @init: Optional function pointer for mux-state object initialisation. * @exit: Optional function pointer for mux-state object cleanup on releas= e. * @@ -779,7 +783,7 @@ static void devm_mux_state_release(struct device *dev, = void *res) * errno on error, or NULL if optional is true and mux doesn't exist. */ static struct mux_state *__devm_mux_state_get(struct device *dev, const ch= ar *mux_name, - bool optional, struct device_node *np, + bool optional, struct fwnode_handle *node, int (*init)(struct mux_state *mstate), int (*exit)(struct mux_state *mstate)) { @@ -787,7 +791,7 @@ static struct mux_state *__devm_mux_state_get(struct de= vice *dev, const char *mu struct mux_state *mstate; int ret; =20 - mstate =3D mux_state_get(dev, mux_name, optional, np); + mstate =3D mux_state_get(dev, mux_name, optional, node); if (IS_ERR(mstate)) return ERR_CAST(mstate); else if (optional && !mstate) @@ -821,23 +825,23 @@ static struct mux_state *__devm_mux_state_get(struct = device *dev, const char *mu } =20 /** - * devm_mux_state_get_from_np() - Get the mux-state for a device, with res= ource + * devm_mux_state_get_from_fwnode() - Get the mux-state for a device, with= resource * management. * @dev: The device that needs a mux-control. * @mux_name: The name identifying the mux-control. - * @np: the device nodes, use dev->of_node if it is NULL. + * @node: the device nodes, use dev's fwnode if it is NULL. * * Return: Pointer to the mux-state, or an ERR_PTR with a negative errno. * * The mux-state will automatically be freed on release. */ struct mux_state * -devm_mux_state_get_from_np(struct device *dev, const char *mux_name, - struct device_node *np) +devm_mux_state_get_from_fwnode(struct device *dev, const char *mux_name, + struct fwnode_handle *node) { - return __devm_mux_state_get(dev, mux_name, false, np, NULL, NULL); + return __devm_mux_state_get(dev, mux_name, false, node, NULL, NULL); } -EXPORT_SYMBOL_GPL(devm_mux_state_get_from_np); +EXPORT_SYMBOL_GPL(devm_mux_state_get_from_fwnode); =20 /** * devm_mux_state_get_optional() - Get the optional mux-state for a device, diff --git a/drivers/pinctrl/pinctrl-generic-mux.c b/drivers/pinctrl/pinctr= l-generic-mux.c index 202b72351efb..6d5b6100c5ca 100644 --- a/drivers/pinctrl/pinctrl-generic-mux.c +++ b/drivers/pinctrl/pinctrl-generic-mux.c @@ -50,7 +50,9 @@ mux_pinmux_dt_node_to_map(struct pinctrl_dev *pctldev, if (!group_names) return -ENOMEM; =20 - function->mux_state =3D devm_mux_state_get_from_np(pctldev->dev, NULL, np= _config); + function->mux_state =3D devm_mux_state_get_from_fwnode(pctldev->dev, + NULL, + of_fwnode_handle(np_config)); if (IS_ERR(function->mux_state)) return PTR_ERR(function->mux_state); =20 diff --git a/include/linux/mux/consumer.h b/include/linux/mux/consumer.h index 449e38e6e2c5..7d121217ca96 100644 --- a/include/linux/mux/consumer.h +++ b/include/linux/mux/consumer.h @@ -11,6 +11,7 @@ #define _LINUX_MUX_CONSUMER_H =20 #include +#include =20 struct device; struct mux_control; @@ -62,7 +63,8 @@ void mux_control_put(struct mux_control *mux); struct mux_control *devm_mux_control_get(struct device *dev, const char *m= ux_name); =20 struct mux_state * -devm_mux_state_get_from_np(struct device *dev, const char *mux_name, struc= t device_node *np); +devm_mux_state_get_from_fwnode(struct device *dev, const char *mux_name, + struct fwnode_handle *node); =20 struct mux_state *devm_mux_state_get_optional(struct device *dev, const ch= ar *mux_name); struct mux_state *devm_mux_state_get_selected(struct device *dev, const ch= ar *mux_name); @@ -165,6 +167,6 @@ static inline struct mux_state *devm_mux_state_get_opti= onal_selected(struct devi #endif /* CONFIG_MULTIPLEXER */ =20 #define devm_mux_state_get(dev, mux_name) \ - devm_mux_state_get_from_np(dev, mux_name, NULL) + devm_mux_state_get_from_fwnode(dev, mux_name, NULL) =20 #endif /* _LINUX_MUX_CONSUMER_H */ --- base-commit: f6e7b42bf05b2427fb8a7a1d1c387a86638bb413 change-id: 20260915-mux_fwnode-a16593c39ffd Best regards, --=20 Fabio Forni