]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mfd: core: Preserve OF node when ACPI handle is present
authorBrian Mak <makb@juniper.net>
Wed, 25 Mar 2026 22:30:24 +0000 (15:30 -0700)
committerLee Jones <lee@kernel.org>
Tue, 31 Mar 2026 12:38:25 +0000 (13:38 +0100)
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.

Cc: stable@vger.kernel.org
Fixes: 51e3b257099d ("mfd: core: Make use of device_set_node()")
Signed-off-by: Brian Mak <makb@juniper.net>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20260325223024.35992-1-makb@juniper.net
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/mfd-core.c

index 6be58eb5a746d80ae2773201afbbfbed3e8b43cb..7aa32b90cf1eb7fa0a05bf3dc506e60a262c9850 100644 (file)
@@ -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,