diff mbox series

[38/87] spi: mpc512x-psc: Convert to platform remove callback returning void

Message ID 20230303172041.2103336-39-u.kleine-koenig@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series spi: Convert to platform remove callback returning void | expand

Commit Message

Uwe Kleine-König March 3, 2023, 5:19 p.m. UTC
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.

Fold mpc512x_psc_spi_do_remove() into its only caller and then 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>
---
 drivers/spi/spi-mpc512x-psc.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c
index 03630359ce70..f5bea6df0690 100644
--- a/drivers/spi/spi-mpc512x-psc.c
+++ b/drivers/spi/spi-mpc512x-psc.c
@@ -561,17 +561,6 @@  static int mpc512x_psc_spi_do_probe(struct device *dev, u32 regaddr,
 	return ret;
 }
 
-static int mpc512x_psc_spi_do_remove(struct device *dev)
-{
-	struct spi_master *master = dev_get_drvdata(dev);
-	struct mpc512x_psc_spi *mps = spi_master_get_devdata(master);
-
-	clk_disable_unprepare(mps->clk_mclk);
-	clk_disable_unprepare(mps->clk_ipg);
-
-	return 0;
-}
-
 static int mpc512x_psc_spi_of_probe(struct platform_device *op)
 {
 	const u32 *regaddr_p;
@@ -588,9 +577,14 @@  static int mpc512x_psc_spi_of_probe(struct platform_device *op)
 				irq_of_parse_and_map(op->dev.of_node, 0));
 }
 
-static int mpc512x_psc_spi_of_remove(struct platform_device *op)
+static void mpc512x_psc_spi_of_remove(struct platform_device *op)
 {
-	return mpc512x_psc_spi_do_remove(&op->dev);
+	struct device *dev = &op->dev;
+	struct spi_master *master = dev_get_drvdata(dev);
+	struct mpc512x_psc_spi *mps = spi_master_get_devdata(master);
+
+	clk_disable_unprepare(mps->clk_mclk);
+	clk_disable_unprepare(mps->clk_ipg);
 }
 
 static const struct of_device_id mpc512x_psc_spi_of_match[] = {
@@ -603,7 +597,7 @@  MODULE_DEVICE_TABLE(of, mpc512x_psc_spi_of_match);
 
 static struct platform_driver mpc512x_psc_spi_of_driver = {
 	.probe = mpc512x_psc_spi_of_probe,
-	.remove = mpc512x_psc_spi_of_remove,
+	.remove_new = mpc512x_psc_spi_of_remove,
 	.driver = {
 		.name = "mpc512x-psc-spi",
 		.of_match_table = mpc512x_psc_spi_of_match,