All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: host: fhci-hcd: Convert to platform remove callback returning void
@ 2023-05-18 20:26 Uwe Kleine-König
  2023-05-19  1:04 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Kleine-König @ 2023-05-18 20:26 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Arnd Bergmann, Linus Walleij, Christophe Leroy, Dmitry Torokhov,
	linux-usb, kernel

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 to the void
returning variant.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/usb/host/fhci-hcd.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c
index 92794ffc25c8..66a045e01dad 100644
--- a/drivers/usb/host/fhci-hcd.c
+++ b/drivers/usb/host/fhci-hcd.c
@@ -757,7 +757,7 @@ static int of_fhci_probe(struct platform_device *ofdev)
 	return ret;
 }
 
-static int fhci_remove(struct device *dev)
+static void fhci_remove(struct device *dev)
 {
 	struct usb_hcd *hcd = dev_get_drvdata(dev);
 	struct fhci_hcd *fhci = hcd_to_fhci(hcd);
@@ -771,12 +771,11 @@ static int fhci_remove(struct device *dev)
 		qe_pin_free(fhci->pins[j]);
 	fhci_dfs_destroy(fhci);
 	usb_put_hcd(hcd);
-	return 0;
 }
 
-static int of_fhci_remove(struct platform_device *ofdev)
+static void of_fhci_remove(struct platform_device *ofdev)
 {
-	return fhci_remove(&ofdev->dev);
+	fhci_remove(&ofdev->dev);
 }
 
 static const struct of_device_id of_fhci_match[] = {
@@ -791,7 +790,7 @@ static struct platform_driver of_fhci_driver = {
 		.of_match_table = of_fhci_match,
 	},
 	.probe		= of_fhci_probe,
-	.remove		= of_fhci_remove,
+	.remove_new	= of_fhci_remove,
 };
 
 module_platform_driver(of_fhci_driver);

base-commit: ac9a78681b921877518763ba0e89202254349d1b
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: host: fhci-hcd: Convert to platform remove callback returning void
  2023-05-18 20:26 [PATCH] usb: host: fhci-hcd: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-05-19  1:04 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2023-05-19  1:04 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Greg Kroah-Hartman, Arnd Bergmann, Linus Walleij,
	Christophe Leroy, linux-usb, kernel

On Thu, May 18, 2023 at 10:26:36PM +0200, 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 to the void
> returning variant.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

> ---
>  drivers/usb/host/fhci-hcd.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/host/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c
> index 92794ffc25c8..66a045e01dad 100644
> --- a/drivers/usb/host/fhci-hcd.c
> +++ b/drivers/usb/host/fhci-hcd.c
> @@ -757,7 +757,7 @@ static int of_fhci_probe(struct platform_device *ofdev)
>  	return ret;
>  }
>  
> -static int fhci_remove(struct device *dev)
> +static void fhci_remove(struct device *dev)
>  {
>  	struct usb_hcd *hcd = dev_get_drvdata(dev);
>  	struct fhci_hcd *fhci = hcd_to_fhci(hcd);
> @@ -771,12 +771,11 @@ static int fhci_remove(struct device *dev)
>  		qe_pin_free(fhci->pins[j]);
>  	fhci_dfs_destroy(fhci);
>  	usb_put_hcd(hcd);
> -	return 0;
>  }
>  
> -static int of_fhci_remove(struct platform_device *ofdev)
> +static void of_fhci_remove(struct platform_device *ofdev)
>  {
> -	return fhci_remove(&ofdev->dev);
> +	fhci_remove(&ofdev->dev);
>  }
>  
>  static const struct of_device_id of_fhci_match[] = {
> @@ -791,7 +790,7 @@ static struct platform_driver of_fhci_driver = {
>  		.of_match_table = of_fhci_match,
>  	},
>  	.probe		= of_fhci_probe,
> -	.remove		= of_fhci_remove,
> +	.remove_new	= of_fhci_remove,
>  };
>  
>  module_platform_driver(of_fhci_driver);
> 
> base-commit: ac9a78681b921877518763ba0e89202254349d1b
> -- 
> 2.39.2
> 

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-19  1:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-18 20:26 [PATCH] usb: host: fhci-hcd: Convert to platform remove callback returning void Uwe Kleine-König
2023-05-19  1:04 ` Dmitry Torokhov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.