[PATCH 04/89] i2c: at91-core: Convert to platform remove callback returning void

Claudiu.Beznea at microchip.com Claudiu.Beznea at microchip.com
Mon May 8 21:42:59 PDT 2023


On 08.05.2023 23:51, Uwe Kleine-König wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> 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 at pengutronix.de>

Reviewed-by: Claudiu Beznea <claudiu.beznea at microchip.com>


> ---
>  drivers/i2c/busses/i2c-at91-core.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-at91-core.c b/drivers/i2c/busses/i2c-at91-core.c
> index 2df9df585131..05ad3bc3578a 100644
> --- a/drivers/i2c/busses/i2c-at91-core.c
> +++ b/drivers/i2c/busses/i2c-at91-core.c
> @@ -273,7 +273,7 @@ static int at91_twi_probe(struct platform_device *pdev)
>         return 0;
>  }
> 
> -static int at91_twi_remove(struct platform_device *pdev)
> +static void at91_twi_remove(struct platform_device *pdev)
>  {
>         struct at91_twi_dev *dev = platform_get_drvdata(pdev);
> 
> @@ -282,8 +282,6 @@ static int at91_twi_remove(struct platform_device *pdev)
> 
>         pm_runtime_disable(dev->dev);
>         pm_runtime_set_suspended(dev->dev);
> -
> -       return 0;
>  }
> 
>  static int __maybe_unused at91_twi_runtime_suspend(struct device *dev)
> @@ -342,7 +340,7 @@ static const struct dev_pm_ops __maybe_unused at91_twi_pm = {
> 
>  static struct platform_driver at91_twi_driver = {
>         .probe          = at91_twi_probe,
> -       .remove         = at91_twi_remove,
> +       .remove_new     = at91_twi_remove,
>         .id_table       = at91_twi_devtypes,
>         .driver         = {
>                 .name   = "at91_i2c",
> --
> 2.39.2
> 



More information about the linux-arm-kernel mailing list