sparc: Populate 'device' for platform device devicetree nodes
PATCH 1/1 sparc: Populate 'device' for platform device devicetree nodes
Since commit 61e82530d80f ("of/platform: Point to struct device from device node"), the 'device' pointer in devicetree nodes for platform devices must be set for of_find_device_by_node to succeed. This is not the case unless the platform device was created using of_platform_device_create(), which is not always the case. This causes all sparc images to crash with "Unable to handle NULL pointer reference" in functions such as iommu_init(), which don't expect of_find_device_by_node() to return NULL.
---
This patch depends on the patch causing the problem (which can not be easily reverted). It should probably go through the same tree as that patch, or the patches should be merged.
arch/sparc/kernel/of_device_32.c | 1 + arch/sparc/kernel/of_device_64.c | 1 + 2 files changed, 2 insertions(+)
arch/sparc/kernel/of_device_32.c +1 -0
@@ -350,6 +350,7 @@ static struct platform_device * __init scan_one_device(struct device_node *dp, sd->op = op; op->dev.of_node = dp; + dp->device = &op->dev; intr =of_get_property (dp,"intr" , &len);if (intr) {
arch/sparc/kernel/of_device_64.c +1 -0
@@ -647,6 +647,7 @@ static struct platform_device * __init scan_one_device(struct device_node *dp, sd->op = op; op->dev.of_node = dp; + dp->device = &op->dev; irq =of_get_property (dp,"interrupts" , &len);if (irq) {
Signature · 1 line
2.1.4
From: Guenter Roeck <[email protected]>
Date: Sun, 25 Oct 2015 17:26:38 -0700
Quoted 8 lines
Since commit
61e82530d80f("of/platform: Point to struct device from device node"), the 'device' pointer in devicetree nodes for platform devices must be set forof_find_device_by_nodeto succeed. This is not the case unless the platform device was created usingof_platform_device_create(), which is not always the case. This causes all sparc images to crash with "Unable to handle NULL pointer reference" in functions such asiommu_init(), which don't expectof_find_device_by_node()to return NULL.
Quoted 6 lines
Cc Tomeu Vizoso <[email protected]>Signed-off-by Guenter Roeck <[email protected]>---
This patch depends on the patch causing the problem (which can not be easily reverted). It should probably go through the same tree as that patch, or the patches should be merged.
Indeed, please merge this into the tree that added the change in question: