Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: mediatek: mt8195: Implement remove functions

Until now the mediatek clk driver library did not have any way to
unregister clks, and so none of the drivers implemented remove
functions.

Now that the library does have APIs to unregister clks, use them
to implement remove functions for the mt8195 clk drivers.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: Miles Chen <miles.chen@mediatek.com>
Link: https://lore.kernel.org/r/20220208124034.414635-31-wenst@chromium.org
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Chen-Yu Tsai and committed by
Stephen Boyd
cf8a482a f3e690b0

+83
+16
drivers/clk/mediatek/clk-mt8195-apmixedsys.c
··· 132 132 if (r) 133 133 goto unregister_gates; 134 134 135 + platform_set_drvdata(pdev, clk_data); 136 + 135 137 return r; 136 138 137 139 unregister_gates: ··· 145 143 return r; 146 144 } 147 145 146 + static int clk_mt8195_apmixed_remove(struct platform_device *pdev) 147 + { 148 + struct device_node *node = pdev->dev.of_node; 149 + struct clk_onecell_data *clk_data = platform_get_drvdata(pdev); 150 + 151 + of_clk_del_provider(node); 152 + mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); 153 + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 154 + mtk_free_clk_data(clk_data); 155 + 156 + return 0; 157 + } 158 + 148 159 static struct platform_driver clk_mt8195_apmixed_drv = { 149 160 .probe = clk_mt8195_apmixed_probe, 161 + .remove = clk_mt8195_apmixed_remove, 150 162 .driver = { 151 163 .name = "clk-mt8195-apmixed", 152 164 .of_match_table = of_match_clk_mt8195_apmixed,
+15
drivers/clk/mediatek/clk-mt8195-apusys_pll.c
··· 74 74 if (r) 75 75 goto unregister_plls; 76 76 77 + platform_set_drvdata(pdev, clk_data); 78 + 77 79 return r; 78 80 79 81 unregister_plls: ··· 85 83 return r; 86 84 } 87 85 86 + static int clk_mt8195_apusys_pll_remove(struct platform_device *pdev) 87 + { 88 + struct clk_onecell_data *clk_data = platform_get_drvdata(pdev); 89 + struct device_node *node = pdev->dev.of_node; 90 + 91 + of_clk_del_provider(node); 92 + mtk_clk_unregister_plls(apusys_plls, ARRAY_SIZE(apusys_plls), clk_data); 93 + mtk_free_clk_data(clk_data); 94 + 95 + return 0; 96 + } 97 + 88 98 static const struct of_device_id of_match_clk_mt8195_apusys_pll[] = { 89 99 { .compatible = "mediatek,mt8195-apusys_pll", }, 90 100 {} ··· 104 90 105 91 static struct platform_driver clk_mt8195_apusys_pll_drv = { 106 92 .probe = clk_mt8195_apusys_pll_probe, 93 + .remove = clk_mt8195_apusys_pll_remove, 107 94 .driver = { 108 95 .name = "clk-mt8195-apusys_pll", 109 96 .of_match_table = of_match_clk_mt8195_apusys_pll,
+20
drivers/clk/mediatek/clk-mt8195-topckgen.c
··· 1271 1271 if (r) 1272 1272 goto unregister_gates; 1273 1273 1274 + platform_set_drvdata(pdev, top_clk_data); 1275 + 1274 1276 return r; 1275 1277 1276 1278 unregister_gates: ··· 1292 1290 return r; 1293 1291 } 1294 1292 1293 + static int clk_mt8195_topck_remove(struct platform_device *pdev) 1294 + { 1295 + struct clk_onecell_data *top_clk_data = platform_get_drvdata(pdev); 1296 + struct device_node *node = pdev->dev.of_node; 1297 + 1298 + of_clk_del_provider(node); 1299 + mtk_clk_unregister_gates(top_clks, ARRAY_SIZE(top_clks), top_clk_data); 1300 + mtk_clk_unregister_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs), top_clk_data); 1301 + mtk_clk_unregister_composites(top_muxes, ARRAY_SIZE(top_muxes), top_clk_data); 1302 + mtk_clk_unregister_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), top_clk_data); 1303 + mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); 1304 + mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), top_clk_data); 1305 + mtk_free_clk_data(top_clk_data); 1306 + 1307 + return 0; 1308 + } 1309 + 1295 1310 static struct platform_driver clk_mt8195_topck_drv = { 1296 1311 .probe = clk_mt8195_topck_probe, 1312 + .remove = clk_mt8195_topck_remove, 1297 1313 .driver = { 1298 1314 .name = "clk-mt8195-topck", 1299 1315 .of_match_table = of_match_clk_mt8195_topck,
+16
drivers/clk/mediatek/clk-mt8195-vdo0.c
··· 107 107 if (r) 108 108 goto unregister_gates; 109 109 110 + platform_set_drvdata(pdev, clk_data); 111 + 110 112 return r; 111 113 112 114 unregister_gates: ··· 118 116 return r; 119 117 } 120 118 119 + static int clk_mt8195_vdo0_remove(struct platform_device *pdev) 120 + { 121 + struct device *dev = &pdev->dev; 122 + struct device_node *node = dev->parent->of_node; 123 + struct clk_onecell_data *clk_data = platform_get_drvdata(pdev); 124 + 125 + of_clk_del_provider(node); 126 + mtk_clk_unregister_gates(vdo0_clks, ARRAY_SIZE(vdo0_clks), clk_data); 127 + mtk_free_clk_data(clk_data); 128 + 129 + return 0; 130 + } 131 + 121 132 static struct platform_driver clk_mt8195_vdo0_drv = { 122 133 .probe = clk_mt8195_vdo0_probe, 134 + .remove = clk_mt8195_vdo0_remove, 123 135 .driver = { 124 136 .name = "clk-mt8195-vdo0", 125 137 },
+16
drivers/clk/mediatek/clk-mt8195-vdo1.c
··· 124 124 if (r) 125 125 goto unregister_gates; 126 126 127 + platform_set_drvdata(pdev, clk_data); 128 + 127 129 return r; 128 130 129 131 unregister_gates: ··· 135 133 return r; 136 134 } 137 135 136 + static int clk_mt8195_vdo1_remove(struct platform_device *pdev) 137 + { 138 + struct device *dev = &pdev->dev; 139 + struct device_node *node = dev->parent->of_node; 140 + struct clk_onecell_data *clk_data = platform_get_drvdata(pdev); 141 + 142 + of_clk_del_provider(node); 143 + mtk_clk_unregister_gates(vdo1_clks, ARRAY_SIZE(vdo1_clks), clk_data); 144 + mtk_free_clk_data(clk_data); 145 + 146 + return 0; 147 + } 148 + 138 149 static struct platform_driver clk_mt8195_vdo1_drv = { 139 150 .probe = clk_mt8195_vdo1_probe, 151 + .remove = clk_mt8195_vdo1_remove, 140 152 .driver = { 141 153 .name = "clk-mt8195-vdo1", 142 154 },