[PATCH 14/32] clk: mediatek: mt2712-apmixedsys: Switch to common probe/remove helpers
Akari Tsuyukusa
akkun11.open at gmail.com
Mon Aug 3 07:16:41 PDT 2026
The MT2712 apmixedsys driver can use the MediaTek clock framework
common initialization sequence. Reduce boilerplate code by creating
struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers.
Signed-off-by: Akari Tsuyukusa <akkun11.open at gmail.com>
---
drivers/clk/mediatek/clk-mt2712-apmixedsys.c | 50 +++-----------------
1 file changed, 7 insertions(+), 43 deletions(-)
diff --git a/drivers/clk/mediatek/clk-mt2712-apmixedsys.c b/drivers/clk/mediatek/clk-mt2712-apmixedsys.c
index 087cf574bcdc..1e06f87e71d0 100644
--- a/drivers/clk/mediatek/clk-mt2712-apmixedsys.c
+++ b/drivers/clk/mediatek/clk-mt2712-apmixedsys.c
@@ -109,56 +109,20 @@ static const struct mtk_pll_data plls[] = {
0, 31, 0x0300, 4, 0, 0, 0, 0x0304, 0),
};
-static int clk_mt2712_apmixed_probe(struct platform_device *pdev)
-{
- struct clk_hw_onecell_data *clk_data;
- int r;
- struct device_node *node = pdev->dev.of_node;
-
- clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
- if (!clk_data)
- return -ENOMEM;
-
- r = mtk_clk_register_plls(&pdev->dev, plls, ARRAY_SIZE(plls), clk_data);
- if (r)
- goto free_clk_data;
-
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
- if (r) {
- dev_err(&pdev->dev, "Cannot register clock provider: %d\n", r);
- goto unregister_plls;
- }
-
- platform_set_drvdata(pdev, clk_data);
-
- return 0;
-
-unregister_plls:
- mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
-free_clk_data:
- mtk_free_clk_data(clk_data);
- return r;
-}
-
-static void clk_mt2712_apmixed_remove(struct platform_device *pdev)
-{
- struct device_node *node = pdev->dev.of_node;
- struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
-
- of_clk_del_provider(node);
- mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
- mtk_free_clk_data(clk_data);
-}
+static const struct mtk_clk_desc apmixed_desc = {
+ .plls = plls,
+ .num_plls = ARRAY_SIZE(plls),
+};
static const struct of_device_id of_match_clk_mt2712_apmixed[] = {
- { .compatible = "mediatek,mt2712-apmixedsys" },
+ { .compatible = "mediatek,mt2712-apmixedsys", .data = &apmixed_desc },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, of_match_clk_mt2712_apmixed);
static struct platform_driver clk_mt2712_apmixed_drv = {
- .probe = clk_mt2712_apmixed_probe,
- .remove = clk_mt2712_apmixed_remove,
+ .probe = mtk_clk_simple_probe,
+ .remove = mtk_clk_simple_remove,
.driver = {
.name = "clk-mt2712-apmixed",
.of_match_table = of_match_clk_mt2712_apmixed,
--
2.55.0
More information about the linux-arm-kernel
mailing list