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

clk: mediatek: Convert all remaining drivers to platform_driver's .remove_new()

The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert all mediatek clk drivers from always returning zero in
the remove callback to the void returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230430190233.878921-4-u.kleine-koenig@pengutronix.de
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Uwe Kleine-König and committed by
Stephen Boyd
a65615df b3bc7275

+32 -64
+2 -4
drivers/clk/mediatek/clk-mt2712-apmixedsys.c
··· 138 138 return r; 139 139 } 140 140 141 - static int clk_mt2712_apmixed_remove(struct platform_device *pdev) 141 + static void clk_mt2712_apmixed_remove(struct platform_device *pdev) 142 142 { 143 143 struct device_node *node = pdev->dev.of_node; 144 144 struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); ··· 146 146 of_clk_del_provider(node); 147 147 mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 148 148 mtk_free_clk_data(clk_data); 149 - 150 - return 0; 151 149 } 152 150 153 151 static const struct of_device_id of_match_clk_mt2712_apmixed[] = { ··· 156 158 157 159 static struct platform_driver clk_mt2712_apmixed_drv = { 158 160 .probe = clk_mt2712_apmixed_probe, 159 - .remove = clk_mt2712_apmixed_remove, 161 + .remove_new = clk_mt2712_apmixed_remove, 160 162 .driver = { 161 163 .name = "clk-mt2712-apmixed", 162 164 .of_match_table = of_match_clk_mt2712_apmixed,
+2 -4
drivers/clk/mediatek/clk-mt6795-apmixedsys.c
··· 187 187 return ret; 188 188 } 189 189 190 - static int clk_mt6795_apmixed_remove(struct platform_device *pdev) 190 + static void clk_mt6795_apmixed_remove(struct platform_device *pdev) 191 191 { 192 192 struct device_node *node = pdev->dev.of_node; 193 193 struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); ··· 197 197 mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, 198 198 ARRAY_SIZE(pllfhs), clk_data); 199 199 mtk_free_clk_data(clk_data); 200 - 201 - return 0; 202 200 } 203 201 204 202 static struct platform_driver clk_mt6795_apmixed_drv = { 205 203 .probe = clk_mt6795_apmixed_probe, 206 - .remove = clk_mt6795_apmixed_remove, 204 + .remove_new = clk_mt6795_apmixed_remove, 207 205 .driver = { 208 206 .name = "clk-mt6795-apmixed", 209 207 .of_match_table = of_match_clk_mt6795_apmixed,
+2 -4
drivers/clk/mediatek/clk-mt6795-infracfg.c
··· 127 127 return ret; 128 128 } 129 129 130 - static int clk_mt6795_infracfg_remove(struct platform_device *pdev) 130 + static void clk_mt6795_infracfg_remove(struct platform_device *pdev) 131 131 { 132 132 struct device_node *node = pdev->dev.of_node; 133 133 struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); ··· 136 136 mtk_clk_unregister_cpumuxes(cpu_muxes, ARRAY_SIZE(cpu_muxes), clk_data); 137 137 mtk_clk_unregister_gates(infra_gates, ARRAY_SIZE(infra_gates), clk_data); 138 138 mtk_free_clk_data(clk_data); 139 - 140 - return 0; 141 139 } 142 140 143 141 static struct platform_driver clk_mt6795_infracfg_drv = { ··· 144 146 .of_match_table = of_match_clk_mt6795_infracfg, 145 147 }, 146 148 .probe = clk_mt6795_infracfg_probe, 147 - .remove = clk_mt6795_infracfg_remove, 149 + .remove_new = clk_mt6795_infracfg_remove, 148 150 }; 149 151 module_platform_driver(clk_mt6795_infracfg_drv); 150 152
+2 -4
drivers/clk/mediatek/clk-mt6795-pericfg.c
··· 136 136 return ret; 137 137 } 138 138 139 - static int clk_mt6795_pericfg_remove(struct platform_device *pdev) 139 + static void clk_mt6795_pericfg_remove(struct platform_device *pdev) 140 140 { 141 141 struct device_node *node = pdev->dev.of_node; 142 142 struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); ··· 145 145 mtk_clk_unregister_composites(peri_clks, ARRAY_SIZE(peri_clks), clk_data); 146 146 mtk_clk_unregister_gates(peri_gates, ARRAY_SIZE(peri_gates), clk_data); 147 147 mtk_free_clk_data(clk_data); 148 - 149 - return 0; 150 148 } 151 149 152 150 static struct platform_driver clk_mt6795_pericfg_drv = { ··· 153 155 .of_match_table = of_match_clk_mt6795_pericfg, 154 156 }, 155 157 .probe = clk_mt6795_pericfg_probe, 156 - .remove = clk_mt6795_pericfg_remove, 158 + .remove_new = clk_mt6795_pericfg_remove, 157 159 }; 158 160 module_platform_driver(clk_mt6795_pericfg_drv); 159 161
+2 -4
drivers/clk/mediatek/clk-mt7622-apmixedsys.c
··· 119 119 return ret; 120 120 } 121 121 122 - static int clk_mt7622_apmixed_remove(struct platform_device *pdev) 122 + static void clk_mt7622_apmixed_remove(struct platform_device *pdev) 123 123 { 124 124 struct device_node *node = pdev->dev.of_node; 125 125 struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); ··· 128 128 mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); 129 129 mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 130 130 mtk_free_clk_data(clk_data); 131 - 132 - return 0; 133 131 } 134 132 135 133 static const struct of_device_id of_match_clk_mt7622_apmixed[] = { ··· 138 140 139 141 static struct platform_driver clk_mt7622_apmixed_drv = { 140 142 .probe = clk_mt7622_apmixed_probe, 141 - .remove = clk_mt7622_apmixed_remove, 143 + .remove_new = clk_mt7622_apmixed_remove, 142 144 .driver = { 143 145 .name = "clk-mt7622-apmixed", 144 146 .of_match_table = of_match_clk_mt7622_apmixed,
+2 -4
drivers/clk/mediatek/clk-mt7622-infracfg.c
··· 101 101 return ret; 102 102 } 103 103 104 - static int clk_mt7622_infracfg_remove(struct platform_device *pdev) 104 + static void clk_mt7622_infracfg_remove(struct platform_device *pdev) 105 105 { 106 106 struct device_node *node = pdev->dev.of_node; 107 107 struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); ··· 110 110 mtk_clk_unregister_cpumuxes(cpu_muxes, ARRAY_SIZE(cpu_muxes), clk_data); 111 111 mtk_clk_unregister_gates(infra_clks, ARRAY_SIZE(infra_clks), clk_data); 112 112 mtk_free_clk_data(clk_data); 113 - 114 - return 0; 115 113 } 116 114 117 115 static struct platform_driver clk_mt7622_infracfg_drv = { ··· 118 120 .of_match_table = of_match_clk_mt7622_infracfg, 119 121 }, 120 122 .probe = clk_mt7622_infracfg_probe, 121 - .remove = clk_mt7622_infracfg_remove, 123 + .remove_new = clk_mt7622_infracfg_remove, 122 124 }; 123 125 module_platform_driver(clk_mt7622_infracfg_drv); 124 126
+2 -4
drivers/clk/mediatek/clk-mt8135-apmixedsys.c
··· 73 73 return ret; 74 74 } 75 75 76 - static int clk_mt8135_apmixed_remove(struct platform_device *pdev) 76 + static void clk_mt8135_apmixed_remove(struct platform_device *pdev) 77 77 { 78 78 struct device_node *node = pdev->dev.of_node; 79 79 struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); ··· 81 81 of_clk_del_provider(node); 82 82 mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 83 83 mtk_free_clk_data(clk_data); 84 - 85 - return 0; 86 84 } 87 85 88 86 static const struct of_device_id of_match_clk_mt8135_apmixed[] = { ··· 91 93 92 94 static struct platform_driver clk_mt8135_apmixed_drv = { 93 95 .probe = clk_mt8135_apmixed_probe, 94 - .remove = clk_mt8135_apmixed_remove, 96 + .remove_new = clk_mt8135_apmixed_remove, 95 97 .driver = { 96 98 .name = "clk-mt8135-apmixed", 97 99 .of_match_table = of_match_clk_mt8135_apmixed,
+2 -4
drivers/clk/mediatek/clk-mt8173-apmixedsys.c
··· 189 189 return r; 190 190 } 191 191 192 - static int clk_mt8173_apmixed_remove(struct platform_device *pdev) 192 + static void clk_mt8173_apmixed_remove(struct platform_device *pdev) 193 193 { 194 194 struct device_node *node = pdev->dev.of_node; 195 195 struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); ··· 199 199 mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, 200 200 ARRAY_SIZE(pllfhs), clk_data); 201 201 mtk_free_clk_data(clk_data); 202 - 203 - return 0; 204 202 } 205 203 206 204 static struct platform_driver clk_mt8173_apmixed_drv = { 207 205 .probe = clk_mt8173_apmixed_probe, 208 - .remove = clk_mt8173_apmixed_remove, 206 + .remove_new = clk_mt8173_apmixed_remove, 209 207 .driver = { 210 208 .name = "clk-mt8173-apmixed", 211 209 .of_match_table = of_match_clk_mt8173_apmixed,
+2 -4
drivers/clk/mediatek/clk-mt8173-infracfg.c
··· 129 129 return r; 130 130 } 131 131 132 - static int clk_mt8173_infracfg_remove(struct platform_device *pdev) 132 + static void clk_mt8173_infracfg_remove(struct platform_device *pdev) 133 133 { 134 134 struct device_node *node = pdev->dev.of_node; 135 135 struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); ··· 138 138 mtk_clk_unregister_cpumuxes(cpu_muxes, ARRAY_SIZE(cpu_muxes), clk_data); 139 139 mtk_clk_unregister_gates(infra_gates, ARRAY_SIZE(infra_gates), clk_data); 140 140 mtk_free_clk_data(clk_data); 141 - 142 - return 0; 143 141 } 144 142 145 143 static struct platform_driver clk_mt8173_infracfg_drv = { ··· 146 148 .of_match_table = of_match_clk_mt8173_infracfg, 147 149 }, 148 150 .probe = clk_mt8173_infracfg_probe, 149 - .remove = clk_mt8173_infracfg_remove, 151 + .remove_new = clk_mt8173_infracfg_remove, 150 152 }; 151 153 module_platform_driver(clk_mt8173_infracfg_drv); 152 154
+2 -4
drivers/clk/mediatek/clk-mt8186-apmixedsys.c
··· 172 172 return r; 173 173 } 174 174 175 - static int clk_mt8186_apmixed_remove(struct platform_device *pdev) 175 + static void clk_mt8186_apmixed_remove(struct platform_device *pdev) 176 176 { 177 177 struct device_node *node = pdev->dev.of_node; 178 178 struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); ··· 181 181 mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, 182 182 ARRAY_SIZE(pllfhs), clk_data); 183 183 mtk_free_clk_data(clk_data); 184 - 185 - return 0; 186 184 } 187 185 188 186 static struct platform_driver clk_mt8186_apmixed_drv = { 189 187 .probe = clk_mt8186_apmixed_probe, 190 - .remove = clk_mt8186_apmixed_remove, 188 + .remove_new = clk_mt8186_apmixed_remove, 191 189 .driver = { 192 190 .name = "clk-mt8186-apmixed", 193 191 .of_match_table = of_match_clk_mt8186_apmixed,
+2 -4
drivers/clk/mediatek/clk-mt8188-apmixedsys.c
··· 132 132 return r; 133 133 } 134 134 135 - static int clk_mt8188_apmixed_remove(struct platform_device *pdev) 135 + static void clk_mt8188_apmixed_remove(struct platform_device *pdev) 136 136 { 137 137 struct device_node *node = pdev->dev.of_node; 138 138 struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); ··· 141 141 mtk_clk_unregister_gates(apmixed_clks, ARRAY_SIZE(apmixed_clks), clk_data); 142 142 mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); 143 143 mtk_free_clk_data(clk_data); 144 - 145 - return 0; 146 144 } 147 145 148 146 static struct platform_driver clk_mt8188_apmixed_drv = { 149 147 .probe = clk_mt8188_apmixed_probe, 150 - .remove = clk_mt8188_apmixed_remove, 148 + .remove_new = clk_mt8188_apmixed_remove, 151 149 .driver = { 152 150 .name = "clk-mt8188-apmixed", 153 151 .of_match_table = of_match_clk_mt8188_apmixed,
+2 -4
drivers/clk/mediatek/clk-mt8188-topckgen.c
··· 1322 1322 return r; 1323 1323 } 1324 1324 1325 - static int clk_mt8188_topck_remove(struct platform_device *pdev) 1325 + static void clk_mt8188_topck_remove(struct platform_device *pdev) 1326 1326 { 1327 1327 struct clk_hw_onecell_data *top_clk_data = platform_get_drvdata(pdev); 1328 1328 struct device_node *node = pdev->dev.of_node; ··· 1334 1334 mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); 1335 1335 mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), top_clk_data); 1336 1336 mtk_free_clk_data(top_clk_data); 1337 - 1338 - return 0; 1339 1337 } 1340 1338 1341 1339 static struct platform_driver clk_mt8188_topck_drv = { 1342 1340 .probe = clk_mt8188_topck_probe, 1343 - .remove = clk_mt8188_topck_remove, 1341 + .remove_new = clk_mt8188_topck_remove, 1344 1342 .driver = { 1345 1343 .name = "clk-mt8188-topck", 1346 1344 .of_match_table = of_match_clk_mt8188_topck,
+2 -4
drivers/clk/mediatek/clk-mt8192-apmixedsys.c
··· 188 188 return r; 189 189 } 190 190 191 - static int clk_mt8192_apmixed_remove(struct platform_device *pdev) 191 + static void clk_mt8192_apmixed_remove(struct platform_device *pdev) 192 192 { 193 193 struct device_node *node = pdev->dev.of_node; 194 194 struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); ··· 198 198 mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, 199 199 ARRAY_SIZE(pllfhs), clk_data); 200 200 mtk_free_clk_data(clk_data); 201 - 202 - return 0; 203 201 } 204 202 205 203 static struct platform_driver clk_mt8192_apmixed_drv = { ··· 206 208 .of_match_table = of_match_clk_mt8192_apmixed, 207 209 }, 208 210 .probe = clk_mt8192_apmixed_probe, 209 - .remove = clk_mt8192_apmixed_remove, 211 + .remove_new = clk_mt8192_apmixed_remove, 210 212 }; 211 213 module_platform_driver(clk_mt8192_apmixed_drv); 212 214 MODULE_DESCRIPTION("MediaTek MT8192 apmixed clocks driver");
+2 -4
drivers/clk/mediatek/clk-mt8195-apmixedsys.c
··· 209 209 return r; 210 210 } 211 211 212 - static int clk_mt8195_apmixed_remove(struct platform_device *pdev) 212 + static void clk_mt8195_apmixed_remove(struct platform_device *pdev) 213 213 { 214 214 struct device_node *node = pdev->dev.of_node; 215 215 struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); ··· 219 219 mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs, 220 220 ARRAY_SIZE(pllfhs), clk_data); 221 221 mtk_free_clk_data(clk_data); 222 - 223 - return 0; 224 222 } 225 223 226 224 static struct platform_driver clk_mt8195_apmixed_drv = { 227 225 .probe = clk_mt8195_apmixed_probe, 228 - .remove = clk_mt8195_apmixed_remove, 226 + .remove_new = clk_mt8195_apmixed_remove, 229 227 .driver = { 230 228 .name = "clk-mt8195-apmixed", 231 229 .of_match_table = of_match_clk_mt8195_apmixed,
+2 -4
drivers/clk/mediatek/clk-mt8195-apusys_pll.c
··· 85 85 return r; 86 86 } 87 87 88 - static int clk_mt8195_apusys_pll_remove(struct platform_device *pdev) 88 + static void clk_mt8195_apusys_pll_remove(struct platform_device *pdev) 89 89 { 90 90 struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); 91 91 struct device_node *node = pdev->dev.of_node; ··· 93 93 of_clk_del_provider(node); 94 94 mtk_clk_unregister_plls(apusys_plls, ARRAY_SIZE(apusys_plls), clk_data); 95 95 mtk_free_clk_data(clk_data); 96 - 97 - return 0; 98 96 } 99 97 100 98 static const struct of_device_id of_match_clk_mt8195_apusys_pll[] = { ··· 103 105 104 106 static struct platform_driver clk_mt8195_apusys_pll_drv = { 105 107 .probe = clk_mt8195_apusys_pll_probe, 106 - .remove = clk_mt8195_apusys_pll_remove, 108 + .remove_new = clk_mt8195_apusys_pll_remove, 107 109 .driver = { 108 110 .name = "clk-mt8195-apusys_pll", 109 111 .of_match_table = of_match_clk_mt8195_apusys_pll,
+2 -4
drivers/clk/mediatek/clk-mt8195-topckgen.c
··· 1317 1317 return r; 1318 1318 } 1319 1319 1320 - static int clk_mt8195_topck_remove(struct platform_device *pdev) 1320 + static void clk_mt8195_topck_remove(struct platform_device *pdev) 1321 1321 { 1322 1322 struct clk_hw_onecell_data *top_clk_data = platform_get_drvdata(pdev); 1323 1323 struct device_node *node = pdev->dev.of_node; ··· 1329 1329 mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data); 1330 1330 mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), top_clk_data); 1331 1331 mtk_free_clk_data(top_clk_data); 1332 - 1333 - return 0; 1334 1332 } 1335 1333 1336 1334 static struct platform_driver clk_mt8195_topck_drv = { 1337 1335 .probe = clk_mt8195_topck_probe, 1338 - .remove = clk_mt8195_topck_remove, 1336 + .remove_new = clk_mt8195_topck_remove, 1339 1337 .driver = { 1340 1338 .name = "clk-mt8195-topck", 1341 1339 .of_match_table = of_match_clk_mt8195_topck,