[PATCH v2 14/35] clk: mediatek: Add child-device population to probe/remove helpers
Akari Tsuyukusa
akkun11.open at gmail.com
Tue Oct 13 08:17:13 PDT 2026
MediaTek audio clock drivers call devm_of_platform_populate() after
mtk_clk_simple_probe(). Extend __mtk_clk_simple_probe() to run
of_platform_populate() when the new 'populate_children' flag is set,
reducing boilerplate.
Signed-off-by: Akari Tsuyukusa <akkun11.open at gmail.com>
---
Changes in v2:
- Use non "devm_" helper (based on Chen-Yu Tsai's review)
---
drivers/clk/mediatek/clk-mtk.c | 18 +++++++++++++++++-
drivers/clk/mediatek/clk-mtk.h | 1 +
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c
index e06cd40d995a..1172e76516c0 100644
--- a/drivers/clk/mediatek/clk-mtk.c
+++ b/drivers/clk/mediatek/clk-mtk.c
@@ -12,6 +12,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
+#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/slab.h>
@@ -603,7 +604,16 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
r = mtk_register_reset_controller_with_dev(&pdev->dev,
mcd->rst_desc);
if (r)
- goto unregister_clks;
+ goto unregister_provider;
+ }
+
+ if (mcd->populate_children) {
+ r = of_platform_populate(pdev->dev.of_node, NULL, NULL,
+ &pdev->dev);
+ if (r) {
+ of_platform_depopulate(&pdev->dev);
+ goto unregister_provider;
+ }
}
if (mcd->need_runtime_pm)
@@ -611,6 +621,9 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
return 0;
+unregister_provider:
+ of_clk_del_provider(node);
+ platform_set_drvdata(pdev, NULL);
unregister_clks:
if (mcd->clks)
mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data);
@@ -658,6 +671,9 @@ static void __mtk_clk_simple_remove(struct platform_device *pdev,
struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
const struct mtk_clk_desc *mcd = device_get_match_data(&pdev->dev);
+ if (mcd->populate_children)
+ of_platform_depopulate(&pdev->dev);
+
of_clk_del_provider(node);
if (mcd->clks)
mtk_clk_unregister_gates(mcd->clks, mcd->num_clks, clk_data);
diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h
index b6504b3e77ed..11939e3e0b38 100644
--- a/drivers/clk/mediatek/clk-mtk.h
+++ b/drivers/clk/mediatek/clk-mtk.h
@@ -265,6 +265,7 @@ struct mtk_clk_desc {
unsigned int mfg_clk_idx;
bool need_runtime_pm;
+ bool populate_children;
};
int mtk_clk_pdev_probe(struct platform_device *pdev);
--
2.56.0
More information about the linux-arm-kernel
mailing list