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

serial: 8250: Convert to platform remove callback returning void

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 ignored (apart
from emitting a warning) 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. Eventually after all drivers
are converted, .remove_new() will be renamed to .remove().

Trivially convert this driver 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>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> # 8250_bcm*
Link: https://lore.kernel.org/r/20231110152927.70601-4-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Uwe Kleine-König and committed by
Greg Kroah-Hartman
7e1efdf8 7635d71e

+32 -56
+2 -4
drivers/tty/serial/8250/8250_aspeed_vuart.c
··· 566 566 return rc; 567 567 } 568 568 569 - static int aspeed_vuart_remove(struct platform_device *pdev) 569 + static void aspeed_vuart_remove(struct platform_device *pdev) 570 570 { 571 571 struct aspeed_vuart *vuart = platform_get_drvdata(pdev); 572 572 ··· 574 574 aspeed_vuart_set_enabled(vuart, false); 575 575 serial8250_unregister_port(vuart->line); 576 576 sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group); 577 - 578 - return 0; 579 577 } 580 578 581 579 static const struct of_device_id aspeed_vuart_table[] = { ··· 588 590 .of_match_table = aspeed_vuart_table, 589 591 }, 590 592 .probe = aspeed_vuart_probe, 591 - .remove = aspeed_vuart_remove, 593 + .remove_new = aspeed_vuart_remove, 592 594 }; 593 595 594 596 module_platform_driver(aspeed_vuart_driver);
+2 -4
drivers/tty/serial/8250/8250_bcm2835aux.c
··· 195 195 return ret; 196 196 } 197 197 198 - static int bcm2835aux_serial_remove(struct platform_device *pdev) 198 + static void bcm2835aux_serial_remove(struct platform_device *pdev) 199 199 { 200 200 struct bcm2835aux_data *data = platform_get_drvdata(pdev); 201 201 202 202 serial8250_unregister_port(data->line); 203 203 clk_disable_unprepare(data->clk); 204 - 205 - return 0; 206 204 } 207 205 208 206 static const struct bcm2835_aux_serial_driver_data bcm2835_acpi_data = { ··· 226 228 .acpi_match_table = bcm2835aux_serial_acpi_match, 227 229 }, 228 230 .probe = bcm2835aux_serial_probe, 229 - .remove = bcm2835aux_serial_remove, 231 + .remove_new = bcm2835aux_serial_remove, 230 232 }; 231 233 module_platform_driver(bcm2835aux_serial_driver); 232 234
+2 -3
drivers/tty/serial/8250/8250_bcm7271.c
··· 1121 1121 return ret; 1122 1122 } 1123 1123 1124 - static int brcmuart_remove(struct platform_device *pdev) 1124 + static void brcmuart_remove(struct platform_device *pdev) 1125 1125 { 1126 1126 struct brcmuart_priv *priv = platform_get_drvdata(pdev); 1127 1127 ··· 1131 1131 brcmuart_free_bufs(&pdev->dev, priv); 1132 1132 if (priv->dma_enabled) 1133 1133 brcmuart_arbitration(priv, 0); 1134 - return 0; 1135 1134 } 1136 1135 1137 1136 static int __maybe_unused brcmuart_suspend(struct device *dev) ··· 1206 1207 .of_match_table = brcmuart_dt_ids, 1207 1208 }, 1208 1209 .probe = brcmuart_probe, 1209 - .remove = brcmuart_remove, 1210 + .remove_new = brcmuart_remove, 1210 1211 }; 1211 1212 1212 1213 static int __init brcmuart_init(void)
+2 -3
drivers/tty/serial/8250/8250_core.c
··· 883 883 /* 884 884 * Remove serial ports registered against a platform device. 885 885 */ 886 - static int serial8250_remove(struct platform_device *dev) 886 + static void serial8250_remove(struct platform_device *dev) 887 887 { 888 888 int i; 889 889 ··· 893 893 if (up->port.dev == &dev->dev) 894 894 serial8250_unregister_port(i); 895 895 } 896 - return 0; 897 896 } 898 897 899 898 static int serial8250_suspend(struct platform_device *dev, pm_message_t state) ··· 925 926 926 927 static struct platform_driver serial8250_isa_driver = { 927 928 .probe = serial8250_probe, 928 - .remove = serial8250_remove, 929 + .remove_new = serial8250_remove, 929 930 .suspend = serial8250_suspend, 930 931 .resume = serial8250_resume, 931 932 .driver = {
+2 -4
drivers/tty/serial/8250/8250_dw.c
··· 663 663 return 0; 664 664 } 665 665 666 - static int dw8250_remove(struct platform_device *pdev) 666 + static void dw8250_remove(struct platform_device *pdev) 667 667 { 668 668 struct dw8250_data *data = platform_get_drvdata(pdev); 669 669 struct device *dev = &pdev->dev; ··· 680 680 681 681 pm_runtime_disable(dev); 682 682 pm_runtime_put_noidle(dev); 683 - 684 - return 0; 685 683 } 686 684 687 685 static int dw8250_suspend(struct device *dev) ··· 787 789 .acpi_match_table = dw8250_acpi_match, 788 790 }, 789 791 .probe = dw8250_probe, 790 - .remove = dw8250_remove, 792 + .remove_new = dw8250_remove, 791 793 }; 792 794 793 795 module_platform_driver(dw8250_platform_driver);
+2 -3
drivers/tty/serial/8250/8250_em.c
··· 200 200 return 0; 201 201 } 202 202 203 - static int serial8250_em_remove(struct platform_device *pdev) 203 + static void serial8250_em_remove(struct platform_device *pdev) 204 204 { 205 205 struct serial8250_em_priv *priv = platform_get_drvdata(pdev); 206 206 207 207 serial8250_unregister_port(priv->line); 208 - return 0; 209 208 } 210 209 211 210 static const struct of_device_id serial8250_em_dt_ids[] = { ··· 219 220 .of_match_table = serial8250_em_dt_ids, 220 221 }, 221 222 .probe = serial8250_em_probe, 222 - .remove = serial8250_em_remove, 223 + .remove_new = serial8250_em_remove, 223 224 }; 224 225 225 226 module_platform_driver(serial8250_em_platform_driver);
+2 -3
drivers/tty/serial/8250/8250_fsl.c
··· 159 159 return 0; 160 160 } 161 161 162 - static int fsl8250_acpi_remove(struct platform_device *pdev) 162 + static void fsl8250_acpi_remove(struct platform_device *pdev) 163 163 { 164 164 struct fsl8250_data *data = platform_get_drvdata(pdev); 165 165 166 166 serial8250_unregister_port(data->line); 167 - return 0; 168 167 } 169 168 170 169 static const struct acpi_device_id fsl_8250_acpi_id[] = { ··· 178 179 .acpi_match_table = ACPI_PTR(fsl_8250_acpi_id), 179 180 }, 180 181 .probe = fsl8250_acpi_probe, 181 - .remove = fsl8250_acpi_remove, 182 + .remove_new = fsl8250_acpi_remove, 182 183 }; 183 184 184 185 module_platform_driver(fsl8250_platform_driver);
+2 -3
drivers/tty/serial/8250/8250_ingenic.c
··· 320 320 return err; 321 321 } 322 322 323 - static int ingenic_uart_remove(struct platform_device *pdev) 323 + static void ingenic_uart_remove(struct platform_device *pdev) 324 324 { 325 325 struct ingenic_uart_data *data = platform_get_drvdata(pdev); 326 326 327 327 serial8250_unregister_port(data->line); 328 328 clk_disable_unprepare(data->clk_module); 329 329 clk_disable_unprepare(data->clk_baud); 330 - return 0; 331 330 } 332 331 333 332 static const struct ingenic_uart_config jz4740_uart_config = { ··· 367 368 .of_match_table = of_match, 368 369 }, 369 370 .probe = ingenic_uart_probe, 370 - .remove = ingenic_uart_remove, 371 + .remove_new = ingenic_uart_remove, 371 372 }; 372 373 373 374 module_platform_driver(ingenic_uart_platform_driver);
+2 -3
drivers/tty/serial/8250/8250_ioc3.c
··· 75 75 return 0; 76 76 } 77 77 78 - static int serial8250_ioc3_remove(struct platform_device *pdev) 78 + static void serial8250_ioc3_remove(struct platform_device *pdev) 79 79 { 80 80 struct ioc3_8250_data *data = platform_get_drvdata(pdev); 81 81 82 82 serial8250_unregister_port(data->line); 83 - return 0; 84 83 } 85 84 86 85 static struct platform_driver serial8250_ioc3_driver = { 87 86 .probe = serial8250_ioc3_probe, 88 - .remove = serial8250_ioc3_remove, 87 + .remove_new = serial8250_ioc3_remove, 89 88 .driver = { 90 89 .name = "ioc3-serial8250", 91 90 }
+2 -4
drivers/tty/serial/8250/8250_lpc18xx.c
··· 182 182 return ret; 183 183 } 184 184 185 - static int lpc18xx_serial_remove(struct platform_device *pdev) 185 + static void lpc18xx_serial_remove(struct platform_device *pdev) 186 186 { 187 187 struct lpc18xx_uart_data *data = platform_get_drvdata(pdev); 188 188 189 189 serial8250_unregister_port(data->line); 190 190 clk_disable_unprepare(data->clk_uart); 191 191 clk_disable_unprepare(data->clk_reg); 192 - 193 - return 0; 194 192 } 195 193 196 194 static const struct of_device_id lpc18xx_serial_match[] = { ··· 199 201 200 202 static struct platform_driver lpc18xx_serial_driver = { 201 203 .probe = lpc18xx_serial_probe, 202 - .remove = lpc18xx_serial_remove, 204 + .remove_new = lpc18xx_serial_remove, 203 205 .driver = { 204 206 .name = "lpc18xx-uart", 205 207 .of_match_table = lpc18xx_serial_match,
+2 -4
drivers/tty/serial/8250/8250_mtk.c
··· 581 581 return 0; 582 582 } 583 583 584 - static int mtk8250_remove(struct platform_device *pdev) 584 + static void mtk8250_remove(struct platform_device *pdev) 585 585 { 586 586 struct mtk8250_data *data = platform_get_drvdata(pdev); 587 587 ··· 591 591 592 592 pm_runtime_disable(&pdev->dev); 593 593 pm_runtime_put_noidle(&pdev->dev); 594 - 595 - return 0; 596 594 } 597 595 598 596 static int __maybe_unused mtk8250_suspend(struct device *dev) ··· 650 652 .of_match_table = mtk8250_of_match, 651 653 }, 652 654 .probe = mtk8250_probe, 653 - .remove = mtk8250_remove, 655 + .remove_new = mtk8250_remove, 654 656 }; 655 657 module_platform_driver(mtk8250_platform_driver); 656 658
+2 -3
drivers/tty/serial/8250/8250_of.c
··· 251 251 /* 252 252 * Release a line 253 253 */ 254 - static int of_platform_serial_remove(struct platform_device *ofdev) 254 + static void of_platform_serial_remove(struct platform_device *ofdev) 255 255 { 256 256 struct of_serial_info *info = platform_get_drvdata(ofdev); 257 257 ··· 261 261 pm_runtime_put_sync(&ofdev->dev); 262 262 pm_runtime_disable(&ofdev->dev); 263 263 kfree(info); 264 - return 0; 265 264 } 266 265 267 266 #ifdef CONFIG_PM_SLEEP ··· 336 337 .pm = &of_serial_pm_ops, 337 338 }, 338 339 .probe = of_platform_serial_probe, 339 - .remove = of_platform_serial_remove, 340 + .remove_new = of_platform_serial_remove, 340 341 }; 341 342 342 343 module_platform_driver(of_platform_serial_driver);
+2 -3
drivers/tty/serial/8250/8250_omap.c
··· 1584 1584 return ret; 1585 1585 } 1586 1586 1587 - static int omap8250_remove(struct platform_device *pdev) 1587 + static void omap8250_remove(struct platform_device *pdev) 1588 1588 { 1589 1589 struct omap8250_priv *priv = platform_get_drvdata(pdev); 1590 1590 struct uart_8250_port *up; ··· 1604 1604 pm_runtime_disable(&pdev->dev); 1605 1605 cpu_latency_qos_remove_request(&priv->pm_qos_request); 1606 1606 device_init_wakeup(&pdev->dev, false); 1607 - return 0; 1608 1607 } 1609 1608 1610 1609 static int omap8250_prepare(struct device *dev) ··· 1862 1863 .of_match_table = omap8250_dt_ids, 1863 1864 }, 1864 1865 .probe = omap8250_probe, 1865 - .remove = omap8250_remove, 1866 + .remove_new = omap8250_remove, 1866 1867 }; 1867 1868 module_platform_driver(omap8250_platform_driver); 1868 1869
+2 -4
drivers/tty/serial/8250/8250_pxa.c
··· 146 146 return ret; 147 147 } 148 148 149 - static int serial_pxa_remove(struct platform_device *pdev) 149 + static void serial_pxa_remove(struct platform_device *pdev) 150 150 { 151 151 struct pxa8250_data *data = platform_get_drvdata(pdev); 152 152 153 153 serial8250_unregister_port(data->line); 154 154 155 155 clk_unprepare(data->clk); 156 - 157 - return 0; 158 156 } 159 157 160 158 static struct platform_driver serial_pxa_driver = { 161 159 .probe = serial_pxa_probe, 162 - .remove = serial_pxa_remove, 160 + .remove_new = serial_pxa_remove, 163 161 164 162 .driver = { 165 163 .name = "pxa2xx-uart",
+2 -4
drivers/tty/serial/8250/8250_tegra.c
··· 128 128 return ret; 129 129 } 130 130 131 - static int tegra_uart_remove(struct platform_device *pdev) 131 + static void tegra_uart_remove(struct platform_device *pdev) 132 132 { 133 133 struct tegra_uart *uart = platform_get_drvdata(pdev); 134 134 135 135 serial8250_unregister_port(uart->line); 136 136 reset_control_assert(uart->rst); 137 137 clk_disable_unprepare(uart->clk); 138 - 139 - return 0; 140 138 } 141 139 142 140 #ifdef CONFIG_PM_SLEEP ··· 190 192 .acpi_match_table = ACPI_PTR(tegra_uart_acpi_match), 191 193 }, 192 194 .probe = tegra_uart_probe, 193 - .remove = tegra_uart_remove, 195 + .remove_new = tegra_uart_remove, 194 196 }; 195 197 196 198 module_platform_driver(tegra_uart_driver);
+2 -4
drivers/tty/serial/8250/8250_uniphier.c
··· 241 241 return 0; 242 242 } 243 243 244 - static int uniphier_uart_remove(struct platform_device *pdev) 244 + static void uniphier_uart_remove(struct platform_device *pdev) 245 245 { 246 246 struct uniphier8250_priv *priv = platform_get_drvdata(pdev); 247 247 248 248 serial8250_unregister_port(priv->line); 249 249 clk_disable_unprepare(priv->clk); 250 - 251 - return 0; 252 250 } 253 251 254 252 static int __maybe_unused uniphier_uart_suspend(struct device *dev) ··· 291 293 292 294 static struct platform_driver uniphier_uart_platform_driver = { 293 295 .probe = uniphier_uart_probe, 294 - .remove = uniphier_uart_remove, 296 + .remove_new = uniphier_uart_remove, 295 297 .driver = { 296 298 .name = "uniphier-uart", 297 299 .of_match_table = uniphier_uart_match,