[PATCH] memory: jz4780-nemc: publish drvdata before creating children
From: Pengpeng Hou
Date: Mon Jun 15 2026 - 20:57:25 EST
The NEMC child drivers can call exported helpers that fetch the parent
controller state with dev_get_drvdata(dev->parent). jz4780_nemc_probe()
currently creates child platform devices before storing the controller
pointer in the parent drvdata, so a child that probes immediately can
observe a NULL parent drvdata pointer.
Store the controller pointer before creating child devices. Also
depopulate child devices during remove before disabling the controller
clock so child teardown still runs while the parent resources are
available.
Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
drivers/memory/jz4780-nemc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/memory/jz4780-nemc.c b/drivers/memory/jz4780-nemc.c
index 1a8161514d03..1c1d1d019f77 100644
--- a/drivers/memory/jz4780-nemc.c
+++ b/drivers/memory/jz4780-nemc.c
@@ -331,6 +331,8 @@ static int jz4780_nemc_probe(struct platform_device *pdev)
return -EINVAL;
}
+ platform_set_drvdata(pdev, nemc);
+
/*
* Iterate over child devices, check that they do not conflict with
* each other, and register child devices for them. If a child device
@@ -379,7 +381,6 @@ static int jz4780_nemc_probe(struct platform_device *pdev)
}
}
- platform_set_drvdata(pdev, nemc);
dev_info(dev, "JZ4780 NEMC initialised\n");
return 0;
}
@@ -388,6 +389,7 @@ static void jz4780_nemc_remove(struct platform_device *pdev)
{
struct jz4780_nemc *nemc = platform_get_drvdata(pdev);
+ of_platform_depopulate(&pdev->dev);
clk_disable_unprepare(nemc->clk);
}
--
2.50.1 (Apple Git-155)