Skip to contentSkip to conversation

mfd: core: Preserve OF node when ACPI handle is present

PATCH Superseded Brian Mak 3 participants 5 messages Mar 11 – Mar 20

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Brian Mak

author
#0 lore raw

PATCH v3 1/1 mfd: core: Preserve OF node when ACPI handle is present

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()")

---

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 | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/mfd/mfd-core.c +14 -1
index 6be58eb5a746..e862448b93b3 100644
@@ -88,7 +88,20 @@ 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.
+	 */
+	if (adev)
+		set_primary_fwnode(&pdev->dev, acpi_fwnode_handle(adev));
+	else
+		set_primary_fwnode(&pdev->dev, acpi_fwnode_handle(parent));
 }
 #else
 static inline void mfd_acpi_add_device(const struct mfd_cell *cell,

base-commit: d9d32e5bd5a4e57675f2b70ddf73c3dc5cf44fc2

Signature · 1 line
2.25.1
#1 lore raw
Quoted 5 lines · Brian Mak

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.

Haven't I given a tag already?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author Reviewed-by Andy Shevchenko
#2 lore raw
Quoted 8 lines · Andy Shevchenko
Quoted 5 lines · Brian Mak

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.

Haven't I given a tag already?

Sorry, yes you did, I forgot to copy it over, my bad:

Best,
Brian

maintainer
#3 lore raw
In reply to Brian Mak
Quoted 32 lines · Brian Mak

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()")

---

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 | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/mfd/mfd-core.c +4 -1
index 6be58eb5a746..e862448b93b3 100644
@@ -88,7 +88,20 @@ 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).

drivers/mfd/mfd-core.c static void mfd_acpi_add_device(const struct mfd_cell *cell, · line 104

Quoted 10 lines
drivers/mfd/mfd-core.c +10 -0
+	 *
+	 * 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.
+	 */
+	if (adev)
+		set_primary_fwnode(&pdev->dev, acpi_fwnode_handle(adev));
+	else
+		set_primary_fwnode(&pdev->dev, acpi_fwnode_handle(parent));

Sorry to mess you around again, but how do you feel about:

  set_primary_fwnode(&pdev->dev, acpi_fwnode_handle(adev ?: parent));
Quoted 8 lines
drivers/mfd/mfd-core.c +0 -0
 }
 #else
 static inline void mfd_acpi_add_device(const struct mfd_cell *cell,

base-commit: d9d32e5bd5a4e57675f2b70ddf73c3dc5cf44fc2

Signature · 1 line
2.25.1
Signature · 1 line
Lee Jones [李琼斯]
#4 lore raw
Quoted 1 line · Lee Jones

On Wed, 11 Mar 2026, Brian Mak wrote:

...

Quoted 8 lines

drivers/mfd/mfd-core.c static void mfd_acpi_add_device(const struct mfd_cell *cell, · line 104

Quoted 4 lines
drivers/mfd/mfd-core.c +4 -0
+	if (adev)
+		set_primary_fwnode(&pdev->dev, acpi_fwnode_handle(adev));
+	else
+		set_primary_fwnode(&pdev->dev, acpi_fwnode_handle(parent));

Sorry to mess you around again, but how do you feel about:

  set_primary_fwnode(&pdev->dev, acpi_fwnode_handle(adev ?: parent));

If you think it's better, no objections from me.

Some maintainers prefer avoiding ternary, and specifically Elvis, some not — hard to remember everybody's preferences :-)

Signature · 2 lines
With Best Regards,
Andy Shevchenko