Skip to contentSkip to conversation

w1: Convert to platform remove callback returning void

PATCH Applied Uwe Kleine-König 2 participants 9 messages Feb 19, 2024 – Feb 20, 2024

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

cover w1: Convert to platform remove callback returning void

Hello,

this series converts all drivers below drivers/w1 to struct platform_driver::remove_new(). See commit 5c5a7680e67b ("platform:
Provide a remove callback that returns no value") for an extended explanation and the eventual goal.

All four conversations are trivial, because their .remove() callbacks returned zero unconditionally.

There are no interdependencies between these patches, so they could be picked up individually. However I'd expect them to go in all together via Krzysztof's tree.

Thanks
Uwe

Uwe Kleine-König (4):
w1: mxc_w1: Convert to platform remove callback returning void
w1: omap_hdq: Convert to platform remove callback returning void
w1: sgi_w1: Convert to platform remove callback returning void
w1: w1-gpio: Convert to platform remove callback returning void

 drivers/w1/masters/mxc_w1.c   | 6 ++----
 drivers/w1/masters/omap_hdq.c | 6 ++----
 drivers/w1/masters/sgi_w1.c   | 6 ++----
 drivers/w1/masters/w1-gpio.c  | 6 ++----
 4 files changed, 8 insertions(+), 16 deletions(-)

base-commit: 35a4fdde2466b9d90af297f249436a270ef9d30e

Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/4 w1: mxc_w1: 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/w1/masters/mxc_w1.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/w1/masters/mxc_w1.c +2 -4
index 090cbbf9e1e2..ba1d0866d1c4 100644
@@ -151,15 +151,13 @@ static int mxc_w1_probe(struct platform_device *pdev)
 /*
  * disassociate the w1 device from the driver
  */
-static int mxc_w1_remove(struct platform_device *pdev)
+static void mxc_w1_remove(struct platform_device *pdev)
 {
 	struct mxc_w1_device *mdev = platform_get_drvdata(pdev);
 
 	w1_remove_master_device(&mdev->bus_master);
 
 	clk_disable_unprepare(mdev->clk);
-
-	return 0;
 }
 
 static const struct of_device_id mxc_w1_dt_ids[] = {
@@ -174,7 +172,7 @@ static struct platform_driver mxc_w1_driver = {
 		.of_match_table = mxc_w1_dt_ids,
 	},
 	.probe = mxc_w1_probe,
-	.remove = mxc_w1_remove,
+	.remove_new = mxc_w1_remove,
 };
 module_platform_driver(mxc_w1_driver);
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/4 w1: omap_hdq: 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/w1/masters/omap_hdq.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/w1/masters/omap_hdq.c +2 -4
index 6a39b71eb718..d1cb5190445a 100644
@@ -647,7 +647,7 @@ static int omap_hdq_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int omap_hdq_remove(struct platform_device *pdev)
+static void omap_hdq_remove(struct platform_device *pdev)
 {
 	int active;
 
@@ -661,8 +661,6 @@ static int omap_hdq_remove(struct platform_device *pdev)
 	if (active >= 0)
 		pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-
-	return 0;
 }
 
 static const struct of_device_id omap_hdq_dt_ids[] = {
@@ -674,7 +672,7 @@ MODULE_DEVICE_TABLE(of, omap_hdq_dt_ids);
 
 static struct platform_driver omap_hdq_driver = {
 	.probe = omap_hdq_probe,
-	.remove = omap_hdq_remove,
+	.remove_new = omap_hdq_remove,
 	.driver = {
 		.name =	"omap_hdq",
 		.of_match_table = omap_hdq_dt_ids,
Signature · 1 line
2.43.0
#3 lore raw
In reply to Uwe Kleine-König

Hello,

Quoted 11 lines · Uwe Kleine-König

this series converts all drivers below drivers/w1 to struct platform_driver::remove_new(). See commit 5c5a7680e67b ("platform:
Provide a remove callback that returns no value") for an extended explanation and the eventual goal.

All four conversations are trivial, because their .remove() callbacks returned zero unconditionally.

There are no interdependencies between these patches, so they could be picked up individually. However I'd expect them to go in all together via Krzysztof's tree.

This series hit a corner case in my patch sending scripts (because the maintainer entry title has a ' which I failed to properly quote). I'll try to resend the patches that didn't hit the mailing list.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |
#4 lore raw
Quoted 11 lines · Uwe Kleine-König

Hello,

Quoted 8 lines · Uwe Kleine-König

this series converts all drivers below drivers/w1 to struct platform_driver::remove_new(). See commit 5c5a7680e67b ("platform:
Provide a remove callback that returns no value") for an extended explanation and the eventual goal.

All four conversations are trivial, because their .remove() callbacks returned zero unconditionally.

Quoted 7 lines
Quoted 3 lines

There are no interdependencies between these patches, so they could be picked up individually. However I'd expect them to go in all together via Krzysztof's tree.

This series hit a corner case in my patch sending scripts (because the maintainer entry title has a ' which I failed to properly quote). I'll try to resend the patches that didn't hit the mailing list.

I don't know what you are referring to. I don't think I ever received your patchset and from another patchset - linked here, but not marked as resend? - I got only two patches.

Please make a proper submission. Don't attach your patchsets to some other threads. If this is resend, add proper "RESEND PATCH" prefix.

Best regards,
Krzysztof

#5 lore raw
Quoted 20 lines · Krzysztof Kozlowski
Quoted 11 lines · Uwe Kleine-König

Hello,

Quoted 8 lines · Uwe Kleine-König

this series converts all drivers below drivers/w1 to struct platform_driver::remove_new(). See commit 5c5a7680e67b ("platform:
Provide a remove callback that returns no value") for an extended explanation and the eventual goal.

All four conversations are trivial, because their .remove() callbacks returned zero unconditionally.

Quoted 7 lines
Quoted 3 lines

There are no interdependencies between these patches, so they could be picked up individually. However I'd expect them to go in all together via Krzysztof's tree.

This series hit a corner case in my patch sending scripts (because the maintainer entry title has a ' which I failed to properly quote). I'll try to resend the patches that didn't hit the mailing list.

Quoted 7 lines

I don't know what you are referring to. I don't think I ever received your patchset and from another patchset - linked here, but not marked as resend? - I got only two patches.

Please make a proper submission. Don't attach your patchsets to some other threads. If this is resend, add proper "RESEND PATCH" prefix.

I think I got the rest of patches here, although this is still oddly threaded.

Best regards,
Krzysztof

#6 lore raw

PATCH 3/4 w1: sgi_w1: 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/w1/masters/sgi_w1.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/w1/masters/sgi_w1.c +2 -4
index d7fbc3c146e1..7bb7876aa70e 100644
@@ -105,13 +105,11 @@ static int sgi_w1_probe(struct platform_device *pdev)
 /*
  * disassociate the w1 device from the driver
  */
-static int sgi_w1_remove(struct platform_device *pdev)
+static void sgi_w1_remove(struct platform_device *pdev)
 {
 	struct sgi_w1_device *sdev = platform_get_drvdata(pdev);
 
 	w1_remove_master_device(&sdev->bus_master);
-
-	return 0;
 }
 
 static struct platform_driver sgi_w1_driver = {
@@ -119,7 +117,7 @@ static struct platform_driver sgi_w1_driver = {
 		.name = "sgi_w1",
 	},
 	.probe = sgi_w1_probe,
-	.remove = sgi_w1_remove,
+	.remove_new = sgi_w1_remove,
 };
 module_platform_driver(sgi_w1_driver);
 
Signature · 1 line
2.43.0
#7 lore raw

PATCH 4/4 w1: w1-gpio: 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/w1/masters/w1-gpio.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/w1/masters/w1-gpio.c +2 -4
index 05c67038ed20..34128e6bbbfa 100644
@@ -141,7 +141,7 @@ static int w1_gpio_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int w1_gpio_remove(struct platform_device *pdev)
+static void w1_gpio_remove(struct platform_device *pdev)
 {
 	struct w1_bus_master *master = platform_get_drvdata(pdev);
 	struct w1_gpio_ddata *ddata = master->data;
@@ -150,8 +150,6 @@ static int w1_gpio_remove(struct platform_device *pdev)
 		gpiod_set_value(ddata->pullup_gpiod, 0);
 
 	w1_remove_master_device(master);
-
-	return 0;
 }
 
 static struct platform_driver w1_gpio_driver = {
@@ -160,7 +158,7 @@ static struct platform_driver w1_gpio_driver = {
 		.of_match_table = of_match_ptr(w1_gpio_dt_ids),
 	},
 	.probe = w1_gpio_probe,
-	.remove = w1_gpio_remove,
+	.remove_new = w1_gpio_remove,
 };
 
 module_platform_driver(w1_gpio_driver);
Signature · 1 line
2.43.0
#8 lore raw
In reply to Uwe Kleine-König
Quoted 9 lines · Uwe Kleine-König

this series converts all drivers below drivers/w1 to struct platform_driver::remove_new(). See commit 5c5a7680e67b ("platform:
Provide a remove callback that returns no value") for an extended explanation and the eventual goal.

All four conversations are trivial, because their .remove() callbacks returned zero unconditionally.

[...]

Applied, thanks!

[1/4] w1: mxc_w1: Convert to platform remove callback returning void

      https://git.kernel.org/krzk/linux-w1/c/63724bbfb1e6b5e202f9393da4b25d4e7a46f5ec
[2/4] w1: omap_hdq: Convert to platform remove callback returning void
      https://git.kernel.org/krzk/linux-w1/c/aa68465cf3d39996b291fb2080946c2e4d7cc100
[3/4] w1: sgi_w1: Convert to platform remove callback returning void
      https://git.kernel.org/krzk/linux-w1/c/d7516044f167b219dae13010e6ff790e3fc96ef5
[4/4] w1: w1-gpio: Convert to platform remove callback returning void
      https://git.kernel.org/krzk/linux-w1/c/d97d263132a69a0bda54efce3df04e55fa6341f7

Best regards,

Signature · 1 line
Krzysztof Kozlowski <[email protected]>