Skip to contentSkip to conversation

ata: Convert to platform remove callback returning void

PATCH Applied Uwe Kleine-König 5 participants 25 messages Jul 31, 2023 – Aug 2, 2023

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover ata: Convert to platform remove callback returning void

Hello,

this series adapts the platform drivers below drivers/ata to use the .remove_new() callback. Compared to the traditional .remove() callback .remove_new() returns no value. This is a good thing because the driver core doesn't (and cannot) cope for errors during remove. The only effect of a non-zero return value in .remove() is that the driver core emits a warning. The device is removed anyhow and an early return from .remove() usually yields a resource leak.

By changing the remove callback to return void driver authors cannot reasonably assume any more that there is some kind of cleanup later.

All drivers touched here returned zero unconditionally in their remove callback, so they could all be converted trivially to .remove_new().

Once all drivers are converted to .remove_new(), .remove() will be changed to match today's .remove_new(). Then the drivers here will be converted back trivially using s/remove_new/remove/. Given the amount of platform drivers this is still a bit in the future, though.

Best regards
Uwe

Uwe Kleine-König (12):
ata/pata_arasan_cf: Convert to platform remove callback returning void ata/pata_ep93xx: Convert to platform remove callback returning void ata/pata_ftide010: Convert to platform remove callback returning void ata/pata_imx: Convert to platform remove callback returning void ata/pata_mpc52xx: Convert to platform remove callback returning void ata/pata_pxa: Convert to platform remove callback returning void ata/pata_rb532_cf: Convert to platform remove callback returning void ata/sata_dwc_460ex: Convert to platform remove callback returning void ata/sata_fsl: Convert to platform remove callback returning void ata/sata_gemini: Convert to platform remove callback returning void ata/sata_mv: Convert to platform remove callback returning void ata/sata_rcar: Convert to platform remove callback returning void

 drivers/ata/pata_arasan_cf.c | 6 ++----
 drivers/ata/pata_ep93xx.c    | 5 ++---
 drivers/ata/pata_ftide010.c  | 6 ++----
 drivers/ata/pata_imx.c       | 6 ++----
 drivers/ata/pata_mpc52xx.c   | 6 ++----
 drivers/ata/pata_pxa.c       | 6 ++----
 drivers/ata/pata_rb532_cf.c  | 6 ++----
 drivers/ata/sata_dwc_460ex.c | 5 ++---
 drivers/ata/sata_fsl.c       | 6 ++----
 drivers/ata/sata_gemini.c    | 6 ++----
 drivers/ata/sata_mv.c        | 5 ++---
 drivers/ata/sata_rcar.c      | 6 ++----
 12 files changed, 24 insertions(+), 45 deletions(-)

base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5

Signature · 7 lines
2.39.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw

PATCH 1/12 ata/pata_arasan_cf: 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() is renamed to .remove().

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

---
 drivers/ata/pata_arasan_cf.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/pata_arasan_cf.c +2 -4
index 6ab294322e79..e11eea2e749a 100644
@@ -916,15 +916,13 @@ static int arasan_cf_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int arasan_cf_remove(struct platform_device *pdev)
+static void arasan_cf_remove(struct platform_device *pdev)
 {
 	struct ata_host *host = platform_get_drvdata(pdev);
 	struct arasan_cf_dev *acdev = host->ports[0]->private_data;
 
 	ata_host_detach(host);
 	cf_exit(acdev);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -965,7 +963,7 @@ MODULE_DEVICE_TABLE(of, arasan_cf_id_table);
 
 static struct platform_driver arasan_cf_driver = {
 	.probe		= arasan_cf_probe,
-	.remove		= arasan_cf_remove,
+	.remove_new	= arasan_cf_remove,
 	.driver		= {
 		.name	= DRIVER_NAME,
 		.pm	= &arasan_cf_pm_ops,
Signature · 1 line
2.39.2
Acked-by on v1 1/12
#2 lore raw

Re: [PATCH 01/12] ata/pata_arasan_cf: Convert to platform remove callback returning void

Quoted 39 lines · Uwe Kleine-König

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() is renamed to .remove().

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

---
 drivers/ata/pata_arasan_cf.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/pata_arasan_cf.c +1 -3
index 6ab294322e79..e11eea2e749a 100644
@@ -916,15 +916,13 @@ static int arasan_cf_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int arasan_cf_remove(struct platform_device *pdev)
+static void arasan_cf_remove(struct platform_device *pdev)
 {
 	struct ata_host *host = platform_get_drvdata(pdev);
 	struct arasan_cf_dev *acdev = host->ports[0]->private_data;
 
 	ata_host_detach(host);
 	cf_exit(acdev);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP

drivers/ata/pata_arasan_cf.c MODULE_DEVICE_TABLE(of, arasan_cf_id_table); · line 969

Quoted 8 lines
drivers/ata/pata_arasan_cf.c +1 -1
@@ -965,7 +963,7 @@ MODULE_DEVICE_TABLE(of, arasan_cf_id_table);
 
 static struct platform_driver arasan_cf_driver = {
 	.probe		= arasan_cf_probe,
-	.remove		= arasan_cf_remove,
+	.remove_new	= arasan_cf_remove,
 	.driver		= {
 		.name	= DRIVER_NAME,
 		.pm	= &arasan_cf_pm_ops,
Signature · 1 line
viresh
Reviewed-by on v1 1/12
#3 lore raw

Re: [PATCH 01/12] ata/pata_arasan_cf: Convert to platform remove callback returning void

In reply to Uwe Kleine-König
Quoted 9 lines · Uwe Kleine-König

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() is renamed to .remove().

Quoted 4 lines

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

[...]

MBR, Sergey

#4 lore raw

PATCH 2/12 ata/pata_ep93xx: Convert to platform remove callback returning void

In reply to Uwe Kleine-König

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() is renamed to .remove().

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

---
 drivers/ata/pata_ep93xx.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/ata/pata_ep93xx.c +2 -3
index c6e043e05d43..744ad5e8cfbf 100644
@@ -1004,7 +1004,7 @@ static int ep93xx_pata_probe(struct platform_device *pdev)
 	return err;
 }
 
-static int ep93xx_pata_remove(struct platform_device *pdev)
+static void ep93xx_pata_remove(struct platform_device *pdev)
 {
 	struct ata_host *host = platform_get_drvdata(pdev);
 	struct ep93xx_pata_data *drv_data = host->private_data;
@@ -1013,7 +1013,6 @@ static int ep93xx_pata_remove(struct platform_device *pdev)
 	ep93xx_pata_release_dma(drv_data);
 	ep93xx_pata_clear_regs(drv_data->ide_base);
 	ep93xx_ide_release_gpio(pdev);
-	return 0;
 }
 
 static struct platform_driver ep93xx_pata_platform_driver = {
@@ -1021,7 +1020,7 @@ static struct platform_driver ep93xx_pata_platform_driver = {
 		.name = DRV_NAME,
 	},
 	.probe = ep93xx_pata_probe,
-	.remove = ep93xx_pata_remove,
+	.remove_new = ep93xx_pata_remove,
 };
 
 module_platform_driver(ep93xx_pata_platform_driver);
Signature · 1 line
2.39.2
Reviewed-by on v1 2/12
#5 lore raw

Re: [PATCH 02/12] ata/pata_ep93xx: Convert to platform remove callback returning void

Quoted 9 lines · Uwe Kleine-König

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() is renamed to .remove().

Quoted 4 lines

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

[...]

MBR, Sergey

#6 lore raw

PATCH 3/12 ata/pata_ftide010: Convert to platform remove callback returning void

In reply to Uwe Kleine-König

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() is renamed to .remove().

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

---
 drivers/ata/pata_ftide010.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/pata_ftide010.c +2 -4
index 6f6734c09b11..27509ee100c7 100644
@@ -541,15 +541,13 @@ static int pata_ftide010_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int pata_ftide010_remove(struct platform_device *pdev)
+static void pata_ftide010_remove(struct platform_device *pdev)
 {
 	struct ata_host *host = platform_get_drvdata(pdev);
 	struct ftide010 *ftide = host->private_data;
 
 	ata_host_detach(ftide->host);
 	clk_disable_unprepare(ftide->pclk);
-
-	return 0;
 }
 
 static const struct of_device_id pata_ftide010_of_match[] = {
@@ -563,7 +561,7 @@ static struct platform_driver pata_ftide010_driver = {
 		.of_match_table = pata_ftide010_of_match,
 	},
 	.probe = pata_ftide010_probe,
-	.remove = pata_ftide010_remove,
+	.remove_new = pata_ftide010_remove,
 };
 module_platform_driver(pata_ftide010_driver);
 
Signature · 1 line
2.39.2
Reviewed-by on v1 3/12
#7 lore raw

Re: [PATCH 03/12] ata/pata_ftide010: Convert to platform remove callback returning void

Quoted 9 lines · Uwe Kleine-König

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() is renamed to .remove().

Quoted 4 lines

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

[...]

MBR, Sergey

#8 lore raw

PATCH 4/12 ata/pata_imx: Convert to platform remove callback returning void

In reply to Uwe Kleine-König

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() is renamed to .remove().

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

---
 drivers/ata/pata_imx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/pata_imx.c +2 -4
index 4013f28679a9..6c62b1feade5 100644
@@ -204,7 +204,7 @@ static int pata_imx_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int pata_imx_remove(struct platform_device *pdev)
+static void pata_imx_remove(struct platform_device *pdev)
 {
 	struct ata_host *host = platform_get_drvdata(pdev);
 	struct pata_imx_priv *priv = host->private_data;
@@ -214,8 +214,6 @@ static int pata_imx_remove(struct platform_device *pdev)
 	__raw_writel(0, priv->host_regs + PATA_IMX_ATA_INT_EN);
 
 	clk_disable_unprepare(priv->clk);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -266,7 +264,7 @@ MODULE_DEVICE_TABLE(of, imx_pata_dt_ids);
 
 static struct platform_driver pata_imx_driver = {
 	.probe		= pata_imx_probe,
-	.remove		= pata_imx_remove,
+	.remove_new	= pata_imx_remove,
 	.driver = {
 		.name		= DRV_NAME,
 		.of_match_table	= imx_pata_dt_ids,
Signature · 7 lines
2.39.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Reviewed-by on v1 4/12
#9 lore raw

Re: [PATCH 04/12] ata/pata_imx: Convert to platform remove callback returning void

Quoted 9 lines · Uwe Kleine-König

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() is renamed to .remove().

Quoted 4 lines

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

[...]

MBR, Sergey

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#10 lore raw

PATCH 5/12 ata/pata_mpc52xx: Convert to platform remove callback returning void

In reply to Uwe Kleine-König

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() is renamed to .remove().

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

---
 drivers/ata/pata_mpc52xx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/pata_mpc52xx.c +2 -4
index 66c9dea4ea6e..bca7f552e2b5 100644
@@ -800,7 +800,7 @@ static int mpc52xx_ata_probe(struct platform_device *op)
 	return rv;
 }
 
-static int
+static void
 mpc52xx_ata_remove(struct platform_device *op)
 {
 	struct ata_host *host = platform_get_drvdata(op);
@@ -815,8 +815,6 @@ mpc52xx_ata_remove(struct platform_device *op)
 	irq_dispose_mapping(task_irq);
 	bcom_ata_release(priv->dmatsk);
 	irq_dispose_mapping(priv->ata_irq);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -857,7 +855,7 @@ static const struct of_device_id mpc52xx_ata_of_match[] = {
 
 static struct platform_driver mpc52xx_ata_of_platform_driver = {
 	.probe		= mpc52xx_ata_probe,
-	.remove		= mpc52xx_ata_remove,
+	.remove_new	= mpc52xx_ata_remove,
 #ifdef CONFIG_PM_SLEEP
 	.suspend	= mpc52xx_ata_suspend,
 	.resume		= mpc52xx_ata_resume,
Signature · 1 line
2.39.2
maintainer
#11 lore raw

Re: [PATCH 05/12] ata/pata_mpc52xx: Convert to platform remove callback returning void

Quoted 22 lines · Uwe Kleine-König

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() is renamed to .remove().

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

---
 drivers/ata/pata_mpc52xx.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/pata_mpc52xx.c +0 -0
index 66c9dea4ea6e..bca7f552e2b5 100644

drivers/ata/pata_mpc52xx.c static int mpc52xx_ata_probe(struct platform_device *op) · line 804

Quoted 6 lines
drivers/ata/pata_mpc52xx.c +1 -1
@@ -800,7 +800,7 @@ static int mpc52xx_ata_probe(struct platform_device *op)
 	return rv;
 }
 
-static int
+static void
 mpc52xx_ata_remove(struct platform_device *op)

While at it, it would be nice to remove the unusual line break here. Will do that when applying.

Quoted 20 lines
drivers/ata/pata_mpc52xx.c +1 -3
 {
 	struct ata_host *host = platform_get_drvdata(op);
@@ -815,8 +815,6 @@ mpc52xx_ata_remove(struct platform_device *op)
 	irq_dispose_mapping(task_irq);
 	bcom_ata_release(priv->dmatsk);
 	irq_dispose_mapping(priv->ata_irq);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -857,7 +855,7 @@ static const struct of_device_id mpc52xx_ata_of_match[] = {
 
 static struct platform_driver mpc52xx_ata_of_platform_driver = {
 	.probe		= mpc52xx_ata_probe,
-	.remove		= mpc52xx_ata_remove,
+	.remove_new	= mpc52xx_ata_remove,
 #ifdef CONFIG_PM_SLEEP
 	.suspend	= mpc52xx_ata_suspend,
 	.resume		= mpc52xx_ata_resume,
Signature · 2 lines
Damien Le Moal
Western Digital Research
Reviewed-by on v1 5/12
#12 lore raw

Re: [PATCH 05/12] ata/pata_mpc52xx: Convert to platform remove callback returning void

In reply to Uwe Kleine-König
Quoted 9 lines · Uwe Kleine-König

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() is renamed to .remove().

Quoted 4 lines

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

[...]

MBR, Sergey

#13 lore raw

PATCH 6/12 ata/pata_pxa: Convert to platform remove callback returning void

In reply to Uwe Kleine-König

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() is renamed to .remove().

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

---
 drivers/ata/pata_pxa.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/pata_pxa.c +2 -4
index ea402e02c46e..5275c6464f57 100644
@@ -295,7 +295,7 @@ static int pxa_ata_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int pxa_ata_remove(struct platform_device *pdev)
+static void pxa_ata_remove(struct platform_device *pdev)
 {
 	struct ata_host *host = platform_get_drvdata(pdev);
 	struct pata_pxa_data *data = host->ports[0]->private_data;
@@ -303,13 +303,11 @@ static int pxa_ata_remove(struct platform_device *pdev)
 	dma_release_channel(data->dma_chan);
 
 	ata_host_detach(host);
-
-	return 0;
 }
 
 static struct platform_driver pxa_ata_driver = {
 	.probe		= pxa_ata_probe,
-	.remove		= pxa_ata_remove,
+	.remove_new	= pxa_ata_remove,
 	.driver		= {
 		.name		= DRV_NAME,
 	},
Signature · 1 line
2.39.2
Reviewed-by on v1 6/12
#14 lore raw

Re: [PATCH 06/12] ata/pata_pxa: Convert to platform remove callback returning void

Quoted 9 lines · Uwe Kleine-König

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() is renamed to .remove().

Quoted 4 lines

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

[...]

MBR, Sergey

#15 lore raw

PATCH 7/12 ata/pata_rb532_cf: Convert to platform remove callback returning void

In reply to Uwe Kleine-König

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() is renamed to .remove().

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

---
 drivers/ata/pata_rb532_cf.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/pata_rb532_cf.c +2 -4
index 3974d294a341..0fa253ad7c93 100644
@@ -155,18 +155,16 @@ static int rb532_pata_driver_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int rb532_pata_driver_remove(struct platform_device *pdev)
+static void rb532_pata_driver_remove(struct platform_device *pdev)
 {
 	struct ata_host *ah = platform_get_drvdata(pdev);
 
 	ata_host_detach(ah);
-
-	return 0;
 }
 
 static struct platform_driver rb532_pata_platform_driver = {
 	.probe		= rb532_pata_driver_probe,
-	.remove		= rb532_pata_driver_remove,
+	.remove_new	= rb532_pata_driver_remove,
 	.driver	 = {
 		.name   = DRV_NAME,
 	},
Signature · 1 line
2.39.2
Reviewed-by on v1 7/12
#16 lore raw

Re: [PATCH 07/12] ata/pata_rb532_cf: Convert to platform remove callback returning void

Quoted 9 lines · Uwe Kleine-König

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() is renamed to .remove().

Quoted 4 lines

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

[...]

MBR, Sergey

#17 lore raw

PATCH 8/12 ata/sata_dwc_460ex: Convert to platform remove callback returning void

In reply to Uwe Kleine-König

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() is renamed to .remove().

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

---
 drivers/ata/sata_dwc_460ex.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/ata/sata_dwc_460ex.c +2 -3
index fabdd1e380f9..20ac56da6b47 100644
@@ -1211,7 +1211,7 @@ static int sata_dwc_probe(struct platform_device *ofdev)
 	return err;
 }
 
-static int sata_dwc_remove(struct platform_device *ofdev)
+static void sata_dwc_remove(struct platform_device *ofdev)
 {
 	struct device *dev = &ofdev->dev;
 	struct ata_host *host = dev_get_drvdata(dev);
@@ -1227,7 +1227,6 @@ static int sata_dwc_remove(struct platform_device *ofdev)
 #endif
 
 	dev_dbg(dev, "done\n");
-	return 0;
 }
 
 static const struct of_device_id sata_dwc_match[] = {
@@ -1242,7 +1241,7 @@ static struct platform_driver sata_dwc_driver = {
 		.of_match_table = sata_dwc_match,
 	},
 	.probe = sata_dwc_probe,
-	.remove = sata_dwc_remove,
+	.remove_new = sata_dwc_remove,
 };
 
 module_platform_driver(sata_dwc_driver);
Signature · 1 line
2.39.2
#18 lore raw

PATCH 9/12 ata/sata_fsl: Convert to platform remove callback returning void

In reply to Uwe Kleine-König

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() is renamed to .remove().

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

---
 drivers/ata/sata_fsl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/sata_fsl.c +2 -4
index ccd99b9aa9ff..744b91fb0022 100644
@@ -1526,7 +1526,7 @@ static int sata_fsl_probe(struct platform_device *ofdev)
 	return retval;
 }
 
-static int sata_fsl_remove(struct platform_device *ofdev)
+static void sata_fsl_remove(struct platform_device *ofdev)
 {
 	struct ata_host *host = platform_get_drvdata(ofdev);
 	struct sata_fsl_host_priv *host_priv = host->private_data;
@@ -1535,8 +1535,6 @@ static int sata_fsl_remove(struct platform_device *ofdev)
 	device_remove_file(&ofdev->dev, &host_priv->rx_watermark);
 
 	ata_host_detach(host);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -1591,7 +1589,7 @@ static struct platform_driver fsl_sata_driver = {
 		.of_match_table = fsl_sata_match,
 	},
 	.probe		= sata_fsl_probe,
-	.remove		= sata_fsl_remove,
+	.remove_new	= sata_fsl_remove,
 #ifdef CONFIG_PM_SLEEP
 	.suspend	= sata_fsl_suspend,
 	.resume		= sata_fsl_resume,
Signature · 1 line
2.39.2
#19 lore raw

PATCH 10/12 ata/sata_gemini: Convert to platform remove callback returning void

In reply to Uwe Kleine-König

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() is renamed to .remove().

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

---
 drivers/ata/sata_gemini.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/sata_gemini.c +2 -4
index c42cc9bbbc4e..94bbb9b69f50 100644
@@ -400,7 +400,7 @@ static int gemini_sata_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int gemini_sata_remove(struct platform_device *pdev)
+static void gemini_sata_remove(struct platform_device *pdev)
 {
 	struct sata_gemini *sg = platform_get_drvdata(pdev);
 
@@ -409,8 +409,6 @@ static int gemini_sata_remove(struct platform_device *pdev)
 		clk_unprepare(sg->sata0_pclk);
 	}
 	sg_singleton = NULL;
-
-	return 0;
 }
 
 static const struct of_device_id gemini_sata_of_match[] = {
@@ -424,7 +422,7 @@ static struct platform_driver gemini_sata_driver = {
 		.of_match_table = gemini_sata_of_match,
 	},
 	.probe = gemini_sata_probe,
-	.remove = gemini_sata_remove,
+	.remove_new = gemini_sata_remove,
 };
 module_platform_driver(gemini_sata_driver);
 
Signature · 1 line
2.39.2
Acked-by on v1 10/12
#20 lore raw

Re: [PATCH 10/12] ata/sata_gemini: Convert to platform remove callback returning void

Quoted 9 lines · Uwe Kleine-König

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() is renamed to .remove().

Quoted 4 lines

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

Yours,
Linus Walleij

#21 lore raw

PATCH 11/12 ata/sata_mv: Convert to platform remove callback returning void

In reply to Uwe Kleine-König

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() is renamed to .remove().

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

---
 drivers/ata/sata_mv.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/ata/sata_mv.c +2 -3
index d404e631d152..c691b89a417b 100644
@@ -4210,7 +4210,7 @@ static int mv_platform_probe(struct platform_device *pdev)
  *      A platform bus SATA device has been unplugged. Perform the needed
  *      cleanup. Also called on module unload for any active devices.
  */
-static int mv_platform_remove(struct platform_device *pdev)
+static void mv_platform_remove(struct platform_device *pdev)
 {
 	struct ata_host *host = platform_get_drvdata(pdev);
 	struct mv_host_priv *hpriv = host->private_data;
@@ -4228,7 +4228,6 @@ static int mv_platform_remove(struct platform_device *pdev)
 		}
 		phy_power_off(hpriv->port_phys[port]);
 	}
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -4284,7 +4283,7 @@ MODULE_DEVICE_TABLE(of, mv_sata_dt_ids);
 
 static struct platform_driver mv_platform_driver = {
 	.probe		= mv_platform_probe,
-	.remove		= mv_platform_remove,
+	.remove_new	= mv_platform_remove,
 	.suspend	= mv_platform_suspend,
 	.resume		= mv_platform_resume,
 	.driver		= {
Signature · 1 line
2.39.2
#22 lore raw

PATCH 12/12 ata/sata_rcar: Convert to platform remove callback returning void

In reply to Uwe Kleine-König

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() is renamed to .remove().

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

---
 drivers/ata/sata_rcar.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/sata_rcar.c +2 -4
index 34790f15c1b8..1a0752255959 100644
@@ -914,7 +914,7 @@ static int sata_rcar_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int sata_rcar_remove(struct platform_device *pdev)
+static void sata_rcar_remove(struct platform_device *pdev)
 {
 	struct ata_host *host = platform_get_drvdata(pdev);
 	struct sata_rcar_priv *priv = host->private_data;
@@ -930,8 +930,6 @@ static int sata_rcar_remove(struct platform_device *pdev)
 
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -1016,7 +1014,7 @@ static const struct dev_pm_ops sata_rcar_pm_ops = {
 
 static struct platform_driver sata_rcar_driver = {
 	.probe		= sata_rcar_probe,
-	.remove		= sata_rcar_remove,
+	.remove_new	= sata_rcar_remove,
 	.driver = {
 		.name		= DRV_NAME,
 		.of_match_table	= sata_rcar_match,
Signature · 1 line
2.39.2
Reviewed-by on v1 12/12
#23 lore raw

Re: [PATCH 12/12] ata/sata_rcar: Convert to platform remove callback returning void

Quoted 9 lines · Uwe Kleine-König

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() is renamed to .remove().

Quoted 4 lines

Trivially convert this driver from always returning zero in the remove callback to the void returning variant.

[...]

MBR, Sergey

maintainer Applied
#24 lore raw
In reply to Uwe Kleine-König
Quoted 13 lines · Uwe Kleine-König

Hello,

this series adapts the platform drivers below drivers/ata to use the .remove_new() callback. Compared to the traditional .remove() callback .remove_new() returns no value. This is a good thing because the driver core doesn't (and cannot) cope for errors during remove. The only effect of a non-zero return value in .remove() is that the driver core emits a warning. The device is removed anyhow and an early return from .remove() usually yields a resource leak.

By changing the remove callback to return void driver authors cannot reasonably assume any more that there is some kind of cleanup later.

Quoted 7 lines

All drivers touched here returned zero unconditionally in their remove callback, so they could all be converted trivially to .remove_new().

Once all drivers are converted to .remove_new(), .remove() will be changed to match today's .remove_new(). Then the drivers here will be converted back trivially using s/remove_new/remove/. Given the amount of platform drivers this is still a bit in the future, though.

Applied to for-6.6 with minor tweaks to the patch titles prefix. Thanks !

Signature · 2 lines
Damien Le Moal
Western Digital Research