Skip to contentSkip to conversation

sbus: Convert to platform remove callback returning void

PATCH In review Uwe Kleine-König 2 participants 8 messages Mar 4, 2024 – Mar 8, 2024 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

cover sbus: Convert to platform remove callback returning void

Hello,

this series converts all platform drivers below drivers/sbus/platform 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.

The first commit is a build fix. The remaining patches implement that actual conversion. All conversations are trivial, because their .remove() callbacks returned zero unconditionally.

Apart from patch #2 building on top of #1, there are no interdependencies between these patches, so they could be picked up individually. But I'd hope that they get picked up all together by Andreas (or Dave?).

Best regards
Uwe

Uwe Kleine-König (6):
sbus: Add prototype for bbc_envctrl_init and bbc_envctrl_cleanup to
header
sbus: bbc_i2c: Convert to platform remove callback returning void
sbus: display7seg: Convert to platform remove callback returning void
sbus: envctrl: Convert to platform remove callback returning void
sbus: flash: Convert to platform remove callback returning void
sbus: uctrl: Convert to platform remove callback returning void

 drivers/sbus/char/bbc_i2c.c     | 9 ++-------
 drivers/sbus/char/bbc_i2c.h     | 3 +++
 drivers/sbus/char/display7seg.c | 6 ++----
 drivers/sbus/char/envctrl.c     | 6 ++----
 drivers/sbus/char/flash.c       | 6 ++----
 drivers/sbus/char/uctrl.c       | 5 ++---
 6 files changed, 13 insertions(+), 22 deletions(-)

base-commit: 67908bf6954b7635d33760ff6dfc189fc26ccc89

Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/6 sbus: Add prototype for bbc_envctrl_init and bbc_envctrl_cleanup to header

This fixes the following build warning:

drivers/sbus/char/bbc_envctrl.c:566:5: error: no previous prototype for ‘bbc_envctrl_init’ [-Werror=missing-prototypes]
566 | int bbc_envctrl_init(struct bbc_i2c_bus *bp)
| ^~~~~~~~~~~~~~~~
drivers/sbus/char/bbc_envctrl.c:594:6: error: no previous prototype for ‘bbc_envctrl_cleanup’ [-Werror=missing-prototypes]
594 | void bbc_envctrl_cleanup(struct bbc_i2c_bus *bp)
| ^~~~~~~~~~~~~~~~~~~

which in the presence of -Werror=missing-prototypes yields a compiler error.

---
 drivers/sbus/char/bbc_i2c.c | 3 ---
 drivers/sbus/char/bbc_i2c.h | 3 +++
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/sbus/char/bbc_i2c.c +0 -3
index 1c76e27d527a..970e04d8937d 100644
@@ -358,9 +358,6 @@ static struct bbc_i2c_bus * attach_one_i2c(struct platform_device *op, int index
 	return NULL;
 }
 
-extern int bbc_envctrl_init(struct bbc_i2c_bus *bp);
-extern void bbc_envctrl_cleanup(struct bbc_i2c_bus *bp);
-
 static int bbc_i2c_probe(struct platform_device *op)
 {
 	struct bbc_i2c_bus *bp;
drivers/sbus/char/bbc_i2c.h +3 -0
index 7ffe908c62dc..6c748836754b 100644
@@ -82,4 +82,7 @@ extern int bbc_i2c_readb(struct bbc_i2c_client *, unsigned char *byte, int off);
 extern int bbc_i2c_write_buf(struct bbc_i2c_client *, char *buf, int len, int off);
 extern int bbc_i2c_read_buf(struct bbc_i2c_client *, char *buf, int len, int off);
 
+extern int bbc_envctrl_init(struct bbc_i2c_bus *bp);
+extern void bbc_envctrl_cleanup(struct bbc_i2c_bus *bp);
+
 #endif /* _BBC_I2C_H */
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/6 sbus: bbc_i2c: 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/sbus/char/bbc_i2c.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/sbus/char/bbc_i2c.c +2 -4
index 970e04d8937d..3192dcb83b86 100644
@@ -382,7 +382,7 @@ static int bbc_i2c_probe(struct platform_device *op)
 	return err;
 }
 
-static int bbc_i2c_remove(struct platform_device *op)
+static void bbc_i2c_remove(struct platform_device *op)
 {
 	struct bbc_i2c_bus *bp = dev_get_drvdata(&op->dev);
 
@@ -396,8 +396,6 @@ static int bbc_i2c_remove(struct platform_device *op)
 		of_iounmap(&op->resource[1], bp->i2c_control_regs, 2);
 
 	kfree(bp);
-
-	return 0;
 }
 
 static const struct of_device_id bbc_i2c_match[] = {
@@ -415,7 +413,7 @@ static struct platform_driver bbc_i2c_driver = {
 		.of_match_table = bbc_i2c_match,
 	},
 	.probe		= bbc_i2c_probe,
-	.remove		= bbc_i2c_remove,
+	.remove_new	= bbc_i2c_remove,
 };
 
 module_platform_driver(bbc_i2c_driver);
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/6 sbus: display7seg: 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/sbus/char/display7seg.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/sbus/char/display7seg.c +2 -4
index 18e6f84e754f..521cf8affe65 100644
@@ -229,7 +229,7 @@ static int d7s_probe(struct platform_device *op)
 	goto out;
 }
 
-static int d7s_remove(struct platform_device *op)
+static void d7s_remove(struct platform_device *op)
 {
 	struct d7s *p = dev_get_drvdata(&op->dev);
 	u8 regs = readb(p->regs);
@@ -245,8 +245,6 @@ static int d7s_remove(struct platform_device *op)
 
 	misc_deregister(&d7s_miscdev);
 	of_iounmap(&op->resource[0], p->regs, sizeof(u8));
-
-	return 0;
 }
 
 static const struct of_device_id d7s_match[] = {
@@ -263,7 +261,7 @@ static struct platform_driver d7s_driver = {
 		.of_match_table = d7s_match,
 	},
 	.probe		= d7s_probe,
-	.remove		= d7s_remove,
+	.remove_new	= d7s_remove,
 };
 
 module_platform_driver(d7s_driver);
Signature · 1 line
2.43.0
#4 lore raw

PATCH 4/6 sbus: envctrl: 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/sbus/char/envctrl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/sbus/char/envctrl.c +2 -4
index 3dd7274cb0a3..491cc6c0b3f9 100644
@@ -1097,7 +1097,7 @@ static int envctrl_probe(struct platform_device *op)
 	return err;
 }
 
-static int envctrl_remove(struct platform_device *op)
+static void envctrl_remove(struct platform_device *op)
 {
 	int index;
 
@@ -1108,8 +1108,6 @@ static int envctrl_remove(struct platform_device *op)
 
 	for (index = 0; index < ENVCTRL_MAX_CPU * 2; index++)
 		kfree(i2c_childlist[index].tables);
-
-	return 0;
 }
 
 static const struct of_device_id envctrl_match[] = {
@@ -1127,7 +1125,7 @@ static struct platform_driver envctrl_driver = {
 		.of_match_table = envctrl_match,
 	},
 	.probe		= envctrl_probe,
-	.remove		= envctrl_remove,
+	.remove_new	= envctrl_remove,
 };
 
 module_platform_driver(envctrl_driver);
Signature · 1 line
2.43.0
#5 lore raw

PATCH 5/6 sbus: flash: 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/sbus/char/flash.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/sbus/char/flash.c +2 -4
index ea2d903ba673..05d37d31c3b8 100644
@@ -187,11 +187,9 @@ static int flash_probe(struct platform_device *op)
 	return misc_register(&flash_dev);
 }
 
-static int flash_remove(struct platform_device *op)
+static void flash_remove(struct platform_device *op)
 {
 	misc_deregister(&flash_dev);
-
-	return 0;
 }
 
 static const struct of_device_id flash_match[] = {
@@ -208,7 +206,7 @@ static struct platform_driver flash_driver = {
 		.of_match_table = flash_match,
 	},
 	.probe		= flash_probe,
-	.remove		= flash_remove,
+	.remove_new	= flash_remove,
 };
 
 module_platform_driver(flash_driver);
Signature · 1 line
2.43.0
#6 lore raw

PATCH 6/6 sbus: uctrl: 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/sbus/char/uctrl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/sbus/char/uctrl.c +2 -3
index 0660425e3a5a..cf15a4186d03 100644
@@ -399,7 +399,7 @@ static int uctrl_probe(struct platform_device *op)
 	goto out;
 }
 
-static int uctrl_remove(struct platform_device *op)
+static void uctrl_remove(struct platform_device *op)
 {
 	struct uctrl_driver *p = dev_get_drvdata(&op->dev);
 
@@ -409,7 +409,6 @@ static int uctrl_remove(struct platform_device *op)
 		of_iounmap(&op->resource[0], p->regs, resource_size(&op->resource[0]));
 		kfree(p);
 	}
-	return 0;
 }
 
 static const struct of_device_id uctrl_match[] = {
@@ -426,7 +425,7 @@ static struct platform_driver uctrl_driver = {
 		.of_match_table = uctrl_match,
 	},
 	.probe		= uctrl_probe,
-	.remove		= uctrl_remove,
+	.remove_new	= uctrl_remove,
 };
 
 
Signature · 1 line
2.43.0
maintainer Reviewed-by on the v1 series
#7 lore raw
In reply to Uwe Kleine-König
Quoted 36 lines · Uwe Kleine-König

Hello,

this series converts all platform drivers below drivers/sbus/platform 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.

The first commit is a build fix. The remaining patches implement that actual conversion. All conversations are trivial, because their .remove() callbacks returned zero unconditionally.

Apart from patch #2 building on top of #1, there are no interdependencies between these patches, so they could be picked up individually. But I'd hope that they get picked up all together by Andreas (or Dave?).

Best regards
Uwe

Uwe Kleine-König (6):
sbus: Add prototype for bbc_envctrl_init and bbc_envctrl_cleanup to
header
sbus: bbc_i2c: Convert to platform remove callback returning void
sbus: display7seg: Convert to platform remove callback returning void
sbus: envctrl: Convert to platform remove callback returning void
sbus: flash: Convert to platform remove callback returning void
sbus: uctrl: Convert to platform remove callback returning void

 drivers/sbus/char/bbc_i2c.c     | 9 ++-------
 drivers/sbus/char/bbc_i2c.h     | 3 +++
 drivers/sbus/char/display7seg.c | 6 ++----
 drivers/sbus/char/envctrl.c     | 6 ++----
 drivers/sbus/char/flash.c       | 6 ++----
 drivers/sbus/char/uctrl.c       | 5 ++---
 6 files changed, 13 insertions(+), 22 deletions(-)
Quoted 1 line

base-commit: 67908bf6954b7635d33760ff6dfc189fc26ccc89

For the whole series,

Picking this up to my for-next.

Thanks,
Andreas