Skip to contentSkip to conversation

ptp: Convert to platform remove callback returning void

PATCH Applied Uwe Kleine-König 3 participants 8 messages Apr 10, 2024 – Apr 13, 2024

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

cover ptp: Convert to platform remove callback returning void

Hello,

this series converts all platform drivers below drivers/ptp/ to not use struct platform_device::remove() any more. See commit 5c5a7680e67b ("platform: Provide a remove callback that returns no value") for an extended explanation and the eventual goal.

All conversations are trivial, because the driver's .remove() callbacks returned zero unconditionally.

There are no interdependencies between these patches, so they can be applied independently if needed. This is merge window material.

Best regards
Uwe

Uwe Kleine-König (5):
ptp: ptp_clockmatrix: Convert to platform remove callback returning
void
ptp: ptp_dte: Convert to platform remove callback returning void
ptp: ptp_idt82p33: Convert to platform remove callback returning void
ptp: ptp_ines: Convert to platform remove callback returning void
ptp: ptp_qoriq: Convert to platform remove callback returning void

 drivers/ptp/ptp_clockmatrix.c | 6 ++----
 drivers/ptp/ptp_dte.c         | 6 ++----
 drivers/ptp/ptp_idt82p33.c    | 6 ++----
 drivers/ptp/ptp_ines.c        | 5 ++---
 drivers/ptp/ptp_qoriq.c       | 5 ++---
 5 files changed, 10 insertions(+), 18 deletions(-)

base-commit: 6ebf211bb11dfc004a2ff73a9de5386fa309c430

Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/5 ptp: ptp_clockmatrix: 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.

---
 drivers/ptp/ptp_clockmatrix.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ptp/ptp_clockmatrix.c +2 -4
index f6f9d4adce04..209a45a76e6b 100644
@@ -2457,15 +2457,13 @@ static int idtcm_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int idtcm_remove(struct platform_device *pdev)
+static void idtcm_remove(struct platform_device *pdev)
 {
 	struct idtcm *idtcm = platform_get_drvdata(pdev);
 
 	idtcm->extts_mask = 0;
 	ptp_clock_unregister_all(idtcm);
 	cancel_delayed_work_sync(&idtcm->extts_work);
-
-	return 0;
 }
 
 static struct platform_driver idtcm_driver = {
@@ -2473,7 +2471,7 @@ static struct platform_driver idtcm_driver = {
 		.name = "8a3400x-phc",
 	},
 	.probe = idtcm_probe,
-	.remove	= idtcm_remove,
+	.remove_new = idtcm_remove,
 };
 
 module_platform_driver(idtcm_driver);
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/5 ptp: ptp_dte: 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() will be renamed to .remove().

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

---
 drivers/ptp/ptp_dte.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ptp/ptp_dte.c +2 -4
index 7cc5a00e625b..449ff90927be 100644
@@ -258,7 +258,7 @@ static int ptp_dte_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int ptp_dte_remove(struct platform_device *pdev)
+static void ptp_dte_remove(struct platform_device *pdev)
 {
 	struct ptp_dte *ptp_dte = platform_get_drvdata(pdev);
 	u8 i;
@@ -267,8 +267,6 @@ static int ptp_dte_remove(struct platform_device *pdev)
 
 	for (i = 0; i < DTE_NUM_REGS_TO_RESTORE; i++)
 		writel(0, ptp_dte->regs + (i * sizeof(u32)));
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -329,7 +327,7 @@ static struct platform_driver ptp_dte_driver = {
 		.of_match_table = ptp_dte_of_match,
 	},
 	.probe    = ptp_dte_probe,
-	.remove   = ptp_dte_remove,
+	.remove_new = ptp_dte_remove,
 };
 module_platform_driver(ptp_dte_driver);
 
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/5 ptp: ptp_idt82p33: 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() will be renamed to .remove().

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

---
 drivers/ptp/ptp_idt82p33.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ptp/ptp_idt82p33.c +2 -4
index 057190b9cd3d..92bb42c43fb2 100644
@@ -1447,15 +1447,13 @@ static int idt82p33_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int idt82p33_remove(struct platform_device *pdev)
+static void idt82p33_remove(struct platform_device *pdev)
 {
 	struct idt82p33 *idt82p33 = platform_get_drvdata(pdev);
 
 	cancel_delayed_work_sync(&idt82p33->extts_work);
 
 	idt82p33_ptp_clock_unregister_all(idt82p33);
-
-	return 0;
 }
 
 static struct platform_driver idt82p33_driver = {
@@ -1463,7 +1461,7 @@ static struct platform_driver idt82p33_driver = {
 		.name = "82p33x1x-phc",
 	},
 	.probe = idt82p33_probe,
-	.remove	= idt82p33_remove,
+	.remove_new = idt82p33_remove,
 };
 
 module_platform_driver(idt82p33_driver);
Signature · 1 line
2.43.0
#4 lore raw

PATCH 4/5 ptp: ptp_ines: 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() will be renamed to .remove().

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

---
 drivers/ptp/ptp_ines.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/ptp/ptp_ines.c +2 -3
index 1d2940a78455..385643f3f8fe 100644
@@ -765,7 +765,7 @@ static int ines_ptp_ctrl_probe(struct platform_device *pld)
 	return err;
 }
 
-static int ines_ptp_ctrl_remove(struct platform_device *pld)
+static void ines_ptp_ctrl_remove(struct platform_device *pld)
 {
 	struct ines_clock *clock = dev_get_drvdata(&pld->dev);
 
@@ -775,7 +775,6 @@ static int ines_ptp_ctrl_remove(struct platform_device *pld)
 	mutex_unlock(&ines_clocks_lock);
 	ines_clock_cleanup(clock);
 	kfree(clock);
-	return 0;
 }
 
 static const struct of_device_id ines_ptp_ctrl_of_match[] = {
@@ -787,7 +786,7 @@ MODULE_DEVICE_TABLE(of, ines_ptp_ctrl_of_match);
 
 static struct platform_driver ines_ptp_ctrl_driver = {
 	.probe  = ines_ptp_ctrl_probe,
-	.remove = ines_ptp_ctrl_remove,
+	.remove_new = ines_ptp_ctrl_remove,
 	.driver = {
 		.name = "ines_ptp_ctrl",
 		.of_match_table = ines_ptp_ctrl_of_match,
Signature · 1 line
2.43.0
#5 lore raw

PATCH 5/5 ptp: ptp_qoriq: 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() will be renamed to .remove().

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

---
 drivers/ptp/ptp_qoriq.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/ptp/ptp_qoriq.c +2 -3
index a52859d024f0..879cfc1537ac 100644
@@ -648,14 +648,13 @@ static int ptp_qoriq_probe(struct platform_device *dev)
 	return err;
 }
 
-static int ptp_qoriq_remove(struct platform_device *dev)
+static void ptp_qoriq_remove(struct platform_device *dev)
 {
 	struct ptp_qoriq *ptp_qoriq = platform_get_drvdata(dev);
 
 	ptp_qoriq_free(ptp_qoriq);
 	release_resource(ptp_qoriq->rsrc);
 	kfree(ptp_qoriq);
-	return 0;
 }
 
 static const struct of_device_id match_table[] = {
@@ -671,7 +670,7 @@ static struct platform_driver ptp_qoriq_driver = {
 		.of_match_table	= match_table,
 	},
 	.probe       = ptp_qoriq_probe,
-	.remove      = ptp_qoriq_remove,
+	.remove_new  = ptp_qoriq_remove,
 };
 
 module_platform_driver(ptp_qoriq_driver);
Signature · 1 line
2.43.0
maintainer Acked-by on the v1 series
#6 lore raw
In reply to Uwe Kleine-König
Quoted 7 lines · Uwe Kleine-König

Hello,

this series converts all platform drivers below drivers/ptp/ to not use struct platform_device::remove() any more. See commit 5c5a7680e67b ("platform: Provide a remove callback that returns no value") for an extended explanation and the eventual goal.

Quoted 8 lines

All conversations are trivial, because the driver's .remove() callbacks returned zero unconditionally.

There are no interdependencies between these patches, so they can be applied independently if needed. This is merge window material.

Best regards
Uwe

For the series:

#7 lore raw
In reply to Uwe Kleine-König
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Wed, 10 Apr 2024 09:34:49 +0200 you wrote:

Hello,

this series converts all platform drivers below drivers/ptp/ to not use struct platform_device::remove() any more. See commit 5c5a7680e67b ("platform: Provide a remove callback that returns no value") for an extended explanation and the eventual goal.

[...]

Here is the summary with links:
- [net-next,1/5] ptp: ptp_clockmatrix: Convert to platform remove callback returning void

    https://git.kernel.org/netdev/net-next/c/32080ec2db65
  - [net-next,2/5] ptp: ptp_dte: Convert to platform remove callback returning void
    https://git.kernel.org/netdev/net-next/c/5c025082f8bc
  - [net-next,3/5] ptp: ptp_idt82p33: Convert to platform remove callback returning void
    https://git.kernel.org/netdev/net-next/c/740c031861a7
  - [net-next,4/5] ptp: ptp_ines: Convert to platform remove callback returning void
    https://git.kernel.org/netdev/net-next/c/cff5236946b7
  - [net-next,5/5] ptp: ptp_qoriq: Convert to platform remove callback returning void
    https://git.kernel.org/netdev/net-next/c/145473b2950a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html