diff mbox series

[13/89] i2c: cht-wc: Convert to platform remove callback returning void

Message ID 20230508205306.1474415-14-u.kleine-koenig@pengutronix.de
State Accepted
Headers show
Series i2c: Convert to platform remove callback returning void | expand

Commit Message

Uwe Kleine-König May 8, 2023, 8:51 p.m. UTC
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 (mostly) ignored
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.

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

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/i2c/busses/i2c-cht-wc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Hans de Goede May 9, 2023, 8:13 a.m. UTC | #1
Hi,

On 5/8/23 22:51, Uwe Kleine-König wrote:
> 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 (mostly) ignored
> 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.
> 
> Trivially convert this driver from always returning zero in the remove
> callback to the void returning variant.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
>  drivers/i2c/busses/i2c-cht-wc.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-cht-wc.c b/drivers/i2c/busses/i2c-cht-wc.c
> index 2b2c3d090089..0209933b9a84 100644
> --- a/drivers/i2c/busses/i2c-cht-wc.c
> +++ b/drivers/i2c/busses/i2c-cht-wc.c
> @@ -529,15 +529,13 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev)
>  	return ret;
>  }
>  
> -static int cht_wc_i2c_adap_i2c_remove(struct platform_device *pdev)
> +static void cht_wc_i2c_adap_i2c_remove(struct platform_device *pdev)
>  {
>  	struct cht_wc_i2c_adap *adap = platform_get_drvdata(pdev);
>  
>  	i2c_unregister_device(adap->client);
>  	i2c_del_adapter(&adap->adapter);
>  	irq_domain_remove(adap->irq_domain);
> -
> -	return 0;
>  }
>  
>  static const struct platform_device_id cht_wc_i2c_adap_id_table[] = {
> @@ -548,7 +546,7 @@ MODULE_DEVICE_TABLE(platform, cht_wc_i2c_adap_id_table);
>  
>  static struct platform_driver cht_wc_i2c_adap_driver = {
>  	.probe = cht_wc_i2c_adap_i2c_probe,
> -	.remove = cht_wc_i2c_adap_i2c_remove,
> +	.remove_new = cht_wc_i2c_adap_i2c_remove,
>  	.driver = {
>  		.name = "cht_wcove_ext_chgr",
>  	},
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-cht-wc.c b/drivers/i2c/busses/i2c-cht-wc.c
index 2b2c3d090089..0209933b9a84 100644
--- a/drivers/i2c/busses/i2c-cht-wc.c
+++ b/drivers/i2c/busses/i2c-cht-wc.c
@@ -529,15 +529,13 @@  static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int cht_wc_i2c_adap_i2c_remove(struct platform_device *pdev)
+static void cht_wc_i2c_adap_i2c_remove(struct platform_device *pdev)
 {
 	struct cht_wc_i2c_adap *adap = platform_get_drvdata(pdev);
 
 	i2c_unregister_device(adap->client);
 	i2c_del_adapter(&adap->adapter);
 	irq_domain_remove(adap->irq_domain);
-
-	return 0;
 }
 
 static const struct platform_device_id cht_wc_i2c_adap_id_table[] = {
@@ -548,7 +546,7 @@  MODULE_DEVICE_TABLE(platform, cht_wc_i2c_adap_id_table);
 
 static struct platform_driver cht_wc_i2c_adap_driver = {
 	.probe = cht_wc_i2c_adap_i2c_probe,
-	.remove = cht_wc_i2c_adap_i2c_remove,
+	.remove_new = cht_wc_i2c_adap_i2c_remove,
 	.driver = {
 		.name = "cht_wcove_ext_chgr",
 	},