@@ -178,11 +178,9 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
if (IS_ERR(pdev))
dev_err(&adev->dev, "platform device creation failed: %ld\n",
PTR_ERR(pdev));
- else {
- set_dev_node(&pdev->dev, acpi_get_node(adev->handle));
+ else
dev_dbg(&adev->dev, "created platform device %s\n",
dev_name(&pdev->dev));
- }
kfree(resources);
@@ -841,6 +841,7 @@ struct platform_device *platform_device_register_full(
goto err;
}
+ set_dev_node(&pdev->dev, ACPI_NODE_GET(ACPI_COMPANION(&pdev->dev)));
ret = platform_device_add(pdev);
if (ret) {
err:
@@ -477,6 +477,10 @@ static inline int acpi_get_node(acpi_handle handle)
return 0;
}
#endif
+
+#define ACPI_NODE_GET(adev) ((adev) && (adev)->handle ? \
+ acpi_get_node((adev)->handle) : NUMA_NO_NODE)
+
extern int pnpacpi_disabled;
#define PXM_INVAL (-1)
@@ -770,6 +774,7 @@ const char *acpi_get_subsystem_id(acpi_handle handle);
#define ACPI_COMPANION_SET(dev, adev) do { } while (0)
#define ACPI_HANDLE(dev) (NULL)
#define ACPI_HANDLE_FWNODE(fwnode) (NULL)
+#define ACPI_NODE_GET(adev) NUMA_NO_NODE
#include <acpi/acpi_numa.h>
platform_add_device() creates the numa_node attribute of sysfs according to whether dev_to_node(dev) is equal to NUMA_NO_NODE. So set the numa node of device before creating numa_node attribute of sysfs. Fixes: 4a60406d3592 ("driver core: platform: expose numa_node to users in sysfs") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202309122309.mbxAnAIe-lkp@intel.com/ Signed-off-by: Jinhui Guo <guojinhui.liam@bytedance.com> --- drivers/acpi/acpi_platform.c | 4 +--- drivers/base/platform.c | 1 + include/linux/acpi.h | 5 +++++ 3 files changed, 7 insertions(+), 3 deletions(-)