[PATCH v4] mfd: core: Preserve OF node when ACPI handle is present

Brian Mak posted 1 patch 1 week ago
drivers/mfd/mfd-core.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
[PATCH v4] mfd: core: Preserve OF node when ACPI handle is present
Posted by Brian Mak 1 week ago
Switch device_set_node to set_primary_fwnode, so that the ACPI fwnode
does not overwrite the of_node with NULL.

This allows MFD children with both OF nodes and ACPI handles to have OF
nodes again.

Fixes: 51e3b257099d ("mfd: core: Make use of device_set_node()")
Cc: stable@vger.kernel.org
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Brian Mak <makb@juniper.net>
---

v4: Switched to use ?: operator.

v3: Changed FIXME to NOTE, as this will not be addressed in the near
future.

v2: Use open-coded logic for clarity and add FIXME.

 drivers/mfd/mfd-core.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 6be58eb5a746..7aa32b90cf1e 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -88,7 +88,17 @@ static void mfd_acpi_add_device(const struct mfd_cell *cell,
 		}
 	}
 
-	device_set_node(&pdev->dev, acpi_fwnode_handle(adev ?: parent));
+	/*
+	 * NOTE: The fwnode design doesn't allow proper stacking/sharing. This
+	 * should eventually turn into a device fwnode API call that will allow
+	 * prepending to a list of fwnodes (with ACPI taking precedence).
+	 *
+	 * set_primary_fwnode() is used here, instead of device_set_node(), as
+	 * device_set_node() will overwrite the existing fwnode, which may be an
+	 * OF node that was populated earlier. To support a use case where ACPI
+	 * and OF is used in conjunction, we call set_primary_fwnode() instead.
+	 */
+	set_primary_fwnode(&pdev->dev, acpi_fwnode_handle(adev ?: parent));
 }
 #else
 static inline void mfd_acpi_add_device(const struct mfd_cell *cell,

base-commit: d2a43e7f89da55d6f0f96aaadaa243f35557291e
-- 
2.25.1
Re: (subset) [PATCH v4] mfd: core: Preserve OF node when ACPI handle is present
Posted by Lee Jones 2 days, 9 hours ago
On Wed, 25 Mar 2026 15:30:24 -0700, Brian Mak wrote:
> Switch device_set_node to set_primary_fwnode, so that the ACPI fwnode
> does not overwrite the of_node with NULL.
> 
> This allows MFD children with both OF nodes and ACPI handles to have OF
> nodes again.
> 
> 
> [...]

Applied, thanks!

[1/1] mfd: core: Preserve OF node when ACPI handle is present
      commit: caa5a5d44d8ae4fd13b744857d66c9313b712d1f

--
Lee Jones [李琼斯]