Skip to contentSkip to conversation

extcon: Convert to platform remove callback returning void

PATCH Applied Uwe Kleine-König 3 participants 10 messages Feb 25, 2024 – Mar 7, 2024

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

cover extcon: Convert to platform remove callback returning void

Hello,

this series converts all drivers below drivers/extcon 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 conversations are trivial, because their .remove() callbacks returned zero unconditionally.

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 the extcon maintainer team.

Best regards
Uwe

Uwe Kleine-König (7):
extcon: adc-jack: Convert to platform remove callback returning void
extcon: intel-cht-wc: Convert to platform remove callback returning void
extcon: intel-mrfld: Convert to platform remove callback returning void
extcon: max3355: Convert to platform remove callback returning void
extcon: max77843: Convert to platform remove callback returning void
extcon: usb-gpio: Convert to platform remove callback returning void
extcon: usbc-cros-ec: Convert to platform remove callback returning void

 drivers/extcon/extcon-adc-jack.c     | 6 ++----
 drivers/extcon/extcon-intel-cht-wc.c | 6 ++----
 drivers/extcon/extcon-intel-mrfld.c  | 6 ++----
 drivers/extcon/extcon-max3355.c      | 6 ++----
 drivers/extcon/extcon-max77843.c     | 6 ++----
 drivers/extcon/extcon-usb-gpio.c     | 6 ++----
 drivers/extcon/extcon-usbc-cros-ec.c | 6 ++----
 7 files changed, 14 insertions(+), 28 deletions(-)

base-commit: 33e1d31873f87d119e5120b88cd350efa68ef276

Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/7 extcon: adc-jack: 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/extcon/extcon-adc-jack.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/extcon/extcon-adc-jack.c +2 -4
index 0317b614b680..cf5050a244b2 100644
@@ -158,14 +158,12 @@ static int adc_jack_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int adc_jack_remove(struct platform_device *pdev)
+static void adc_jack_remove(struct platform_device *pdev)
 {
 	struct adc_jack_data *data = platform_get_drvdata(pdev);
 
 	free_irq(data->irq, data);
 	cancel_work_sync(&data->handler.work);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -196,7 +194,7 @@ static SIMPLE_DEV_PM_OPS(adc_jack_pm_ops,
 
 static struct platform_driver adc_jack_driver = {
 	.probe          = adc_jack_probe,
-	.remove         = adc_jack_remove,
+	.remove_new     = adc_jack_remove,
 	.driver         = {
 		.name   = "adc-jack",
 		.pm = &adc_jack_pm_ops,
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/7 extcon: intel-cht-wc: 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/extcon/extcon-intel-cht-wc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/extcon/extcon-intel-cht-wc.c +2 -4
index 2c55f06ba699..733c470c3102 100644
@@ -617,13 +617,11 @@ static int cht_wc_extcon_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int cht_wc_extcon_remove(struct platform_device *pdev)
+static void cht_wc_extcon_remove(struct platform_device *pdev)
 {
 	struct cht_wc_extcon_data *ext = platform_get_drvdata(pdev);
 
 	cht_wc_extcon_sw_control(ext, false);
-
-	return 0;
 }
 
 static const struct platform_device_id cht_wc_extcon_table[] = {
@@ -634,7 +632,7 @@ MODULE_DEVICE_TABLE(platform, cht_wc_extcon_table);
 
 static struct platform_driver cht_wc_extcon_driver = {
 	.probe = cht_wc_extcon_probe,
-	.remove = cht_wc_extcon_remove,
+	.remove_new = cht_wc_extcon_remove,
 	.id_table = cht_wc_extcon_table,
 	.driver = {
 		.name = "cht_wcove_pwrsrc",
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/7 extcon: intel-mrfld: 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/extcon/extcon-intel-mrfld.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/extcon/extcon-intel-mrfld.c +2 -4
index e96947fb76ee..12a041a58578 100644
@@ -257,13 +257,11 @@ static int mrfld_extcon_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int mrfld_extcon_remove(struct platform_device *pdev)
+static void mrfld_extcon_remove(struct platform_device *pdev)
 {
 	struct mrfld_extcon_data *data = platform_get_drvdata(pdev);
 
 	mrfld_extcon_sw_control(data, false);
-
-	return 0;
 }
 
 static const struct platform_device_id mrfld_extcon_id_table[] = {
@@ -277,7 +275,7 @@ static struct platform_driver mrfld_extcon_driver = {
 		.name	= "mrfld_bcove_pwrsrc",
 	},
 	.probe		= mrfld_extcon_probe,
-	.remove		= mrfld_extcon_remove,
+	.remove_new	= mrfld_extcon_remove,
 	.id_table	= mrfld_extcon_id_table,
 };
 module_platform_driver(mrfld_extcon_driver);
Signature · 1 line
2.43.0
#4 lore raw

PATCH 4/7 extcon: max3355: 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/extcon/extcon-max3355.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/extcon/extcon-max3355.c +2 -4
index d7795607f693..e62ce7a8d131 100644
@@ -112,13 +112,11 @@ static int max3355_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int max3355_remove(struct platform_device *pdev)
+static void max3355_remove(struct platform_device *pdev)
 {
 	struct max3355_data *data = platform_get_drvdata(pdev);
 
 	gpiod_set_value_cansleep(data->shdn_gpiod, 0);
-
-	return 0;
 }
 
 static const struct of_device_id max3355_match_table[] = {
@@ -129,7 +127,7 @@ MODULE_DEVICE_TABLE(of, max3355_match_table);
 
 static struct platform_driver max3355_driver = {
 	.probe		= max3355_probe,
-	.remove		= max3355_remove,
+	.remove_new	= max3355_remove,
 	.driver		= {
 		.name	= "extcon-max3355",
 		.of_match_table = max3355_match_table,
Signature · 1 line
2.43.0
#5 lore raw

PATCH 5/7 extcon: max77843: 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/extcon/extcon-max77843.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/extcon/extcon-max77843.c +2 -4
index acb11a54f875..9849e3b8327e 100644
@@ -928,7 +928,7 @@ static int max77843_muic_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int max77843_muic_remove(struct platform_device *pdev)
+static void max77843_muic_remove(struct platform_device *pdev)
 {
 	struct max77843_muic_info *info = platform_get_drvdata(pdev);
 	struct max77693_dev *max77843 = info->max77843;
@@ -936,8 +936,6 @@ static int max77843_muic_remove(struct platform_device *pdev)
 	cancel_work_sync(&info->irq_work);
 	regmap_del_irq_chip(max77843->irq, max77843->irq_data_muic);
 	i2c_unregister_device(max77843->i2c_muic);
-
-	return 0;
 }
 
 static const struct platform_device_id max77843_muic_id[] = {
@@ -958,7 +956,7 @@ static struct platform_driver max77843_muic_driver = {
 		.of_match_table = of_max77843_muic_dt_match,
 	},
 	.probe		= max77843_muic_probe,
-	.remove		= max77843_muic_remove,
+	.remove_new	= max77843_muic_remove,
 	.id_table	= max77843_muic_id,
 };
 
Signature · 1 line
2.43.0
#6 lore raw

PATCH 6/7 extcon: usb-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/extcon/extcon-usb-gpio.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/extcon/extcon-usb-gpio.c +2 -4
index 40d967a11e87..9b61eb99b7dc 100644
@@ -193,14 +193,12 @@ static int usb_extcon_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int usb_extcon_remove(struct platform_device *pdev)
+static void usb_extcon_remove(struct platform_device *pdev)
 {
 	struct usb_extcon_info *info = platform_get_drvdata(pdev);
 
 	cancel_delayed_work_sync(&info->wq_detcable);
 	device_init_wakeup(&pdev->dev, false);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -281,7 +279,7 @@ MODULE_DEVICE_TABLE(platform, usb_extcon_platform_ids);
 
 static struct platform_driver usb_extcon_driver = {
 	.probe		= usb_extcon_probe,
-	.remove		= usb_extcon_remove,
+	.remove_new	= usb_extcon_remove,
 	.driver		= {
 		.name	= "extcon-usb-gpio",
 		.pm	= &usb_extcon_pm_ops,
Signature · 1 line
2.43.0
#7 lore raw

PATCH 7/7 extcon: usbc-cros-ec: 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/extcon/extcon-usbc-cros-ec.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/extcon/extcon-usbc-cros-ec.c +2 -4
index fde1db62be0d..805a47230689 100644
@@ -480,14 +480,12 @@ static int extcon_cros_ec_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int extcon_cros_ec_remove(struct platform_device *pdev)
+static void extcon_cros_ec_remove(struct platform_device *pdev)
 {
 	struct cros_ec_extcon_info *info = platform_get_drvdata(pdev);
 
 	blocking_notifier_chain_unregister(&info->ec->event_notifier,
 					   &info->notifier);
-
-	return 0;
 }
 
 #ifdef CONFIG_PM_SLEEP
@@ -531,7 +529,7 @@ static struct platform_driver extcon_cros_ec_driver = {
 		.of_match_table = of_match_ptr(extcon_cros_ec_of_match),
 		.pm = DEV_PM_OPS,
 	},
-	.remove  = extcon_cros_ec_remove,
+	.remove_new = extcon_cros_ec_remove,
 	.probe   = extcon_cros_ec_probe,
 };
 
Signature · 1 line
2.43.0
Reviewed-by on v1 7/7
#8 lore raw

Re: [PATCH 7/7] extcon: usbc-cros-ec: Convert to platform remove callback returning void

Quoted 10 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() will be renamed to .remove().

Quoted 4 lines

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

maintainer Applied
#9 lore raw
In reply to Uwe Kleine-König
Quoted 39 lines

-----Original Message-----
From: Uwe Kleine-König <[email protected]>
Sent: Monday, February 26, 2024 12:55 AM
To: MyungJoo Ham <[email protected]>; Chanwoo Choi <[email protected]>
Cc: [email protected]; Krzysztof Kozlowski <[email protected]>; Benson Leung <[email protected]>; Guenter Roeck <[email protected]>; [email protected]
Subject: [PATCH 0/7] extcon: Convert to platform remove callback returning void

Hello,

this series converts all drivers below drivers/extcon 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 conversations are trivial, because their .remove() callbacks returned zero unconditionally.

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 the extcon maintainer team.

Best regards
Uwe

Uwe Kleine-König (7):
extcon: adc-jack: Convert to platform remove callback returning void
extcon: intel-cht-wc: Convert to platform remove callback returning void
extcon: intel-mrfld: Convert to platform remove callback returning void
extcon: max3355: Convert to platform remove callback returning void
extcon: max77843: Convert to platform remove callback returning void
extcon: usb-gpio: Convert to platform remove callback returning void
extcon: usbc-cros-ec: Convert to platform remove callback returning void

Quoted 9 lines
 drivers/extcon/extcon-adc-jack.c     | 6 ++----
 drivers/extcon/extcon-intel-cht-wc.c | 6 ++----  drivers/extcon/extcon-
intel-mrfld.c  | 6 ++----
 drivers/extcon/extcon-max3355.c      | 6 ++----
 drivers/extcon/extcon-max77843.c     | 6 ++----
 drivers/extcon/extcon-usb-gpio.c     | 6 ++----
 drivers/extcon/extcon-usbc-cros-ec.c | 6 ++----
 7 files changed, 14 insertions(+), 28 deletions(-)

Applied them. Thanks.

Best Regards,
Chanwoo Choi