[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJZ5v0gw=vddN9kHMSECwCye9q3qbN0Hr=DL6EC=fQ9eHF9faA@mail.gmail.com>
Date: Fri, 14 Jul 2023 21:01:28 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Yangtao Li <frank.li@...o.com>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Amit Kucheria <amitk@...nel.org>,
Zhang Rui <rui.zhang@...el.com>,
Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 27/27] thermal: intel: int340x: Convert to platform remove
callback returning void
On Wed, Jul 12, 2023 at 10:14 AM Yangtao Li <frank.li@...o.com> 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.
>
> Cc: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
> Signed-off-by: Yangtao Li <frank.li@...o.com>
Acked-by: Rafael J. Wysocki <rafael@...nel.org>
or please let me know if you want me to pick this up.
Thanks!
> ---
> drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 5 ++---
> drivers/thermal/intel/int340x_thermal/int3401_thermal.c | 6 ++----
> drivers/thermal/intel/int340x_thermal/int3402_thermal.c | 6 ++----
> drivers/thermal/intel/int340x_thermal/int3403_thermal.c | 6 ++----
> drivers/thermal/intel/int340x_thermal/int3406_thermal.c | 5 ++---
> 5 files changed, 10 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> index 5e1164226ada..8fbc97641740 100644
> --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> @@ -674,7 +674,7 @@ static int int3400_thermal_probe(struct platform_device *pdev)
> return result;
> }
>
> -static int int3400_thermal_remove(struct platform_device *pdev)
> +static void int3400_thermal_remove(struct platform_device *pdev)
> {
> struct int3400_thermal_priv *priv = platform_get_drvdata(pdev);
>
> @@ -698,7 +698,6 @@ static int int3400_thermal_remove(struct platform_device *pdev)
> kfree(priv->trts);
> kfree(priv->arts);
> kfree(priv);
> - return 0;
> }
>
> static const struct acpi_device_id int3400_thermal_match[] = {
> @@ -714,7 +713,7 @@ MODULE_DEVICE_TABLE(acpi, int3400_thermal_match);
>
> static struct platform_driver int3400_thermal_driver = {
> .probe = int3400_thermal_probe,
> - .remove = int3400_thermal_remove,
> + .remove_new = int3400_thermal_remove,
> .driver = {
> .name = "int3400 thermal",
> .acpi_match_table = ACPI_PTR(int3400_thermal_match),
> diff --git a/drivers/thermal/intel/int340x_thermal/int3401_thermal.c b/drivers/thermal/intel/int340x_thermal/int3401_thermal.c
> index 217786fba185..714f4cb59cfd 100644
> --- a/drivers/thermal/intel/int340x_thermal/int3401_thermal.c
> +++ b/drivers/thermal/intel/int340x_thermal/int3401_thermal.c
> @@ -36,11 +36,9 @@ static int int3401_add(struct platform_device *pdev)
> return ret;
> }
>
> -static int int3401_remove(struct platform_device *pdev)
> +static void int3401_remove(struct platform_device *pdev)
> {
> proc_thermal_remove(platform_get_drvdata(pdev));
> -
> - return 0;
> }
>
> #ifdef CONFIG_PM_SLEEP
> @@ -62,7 +60,7 @@ static SIMPLE_DEV_PM_OPS(int3401_proc_thermal_pm, int3401_thermal_suspend,
>
> static struct platform_driver int3401_driver = {
> .probe = int3401_add,
> - .remove = int3401_remove,
> + .remove_new = int3401_remove,
> .driver = {
> .name = "int3401 thermal",
> .acpi_match_table = int3401_device_ids,
> diff --git a/drivers/thermal/intel/int340x_thermal/int3402_thermal.c b/drivers/thermal/intel/int340x_thermal/int3402_thermal.c
> index 43fa351e2b9e..ab8bfb5a3946 100644
> --- a/drivers/thermal/intel/int340x_thermal/int3402_thermal.c
> +++ b/drivers/thermal/intel/int340x_thermal/int3402_thermal.c
> @@ -71,15 +71,13 @@ static int int3402_thermal_probe(struct platform_device *pdev)
> return 0;
> }
>
> -static int int3402_thermal_remove(struct platform_device *pdev)
> +static void int3402_thermal_remove(struct platform_device *pdev)
> {
> struct int3402_thermal_data *d = platform_get_drvdata(pdev);
>
> acpi_remove_notify_handler(d->handle,
> ACPI_DEVICE_NOTIFY, int3402_notify);
> int340x_thermal_zone_remove(d->int340x_zone);
> -
> - return 0;
> }
>
> static const struct acpi_device_id int3402_thermal_match[] = {
> @@ -91,7 +89,7 @@ MODULE_DEVICE_TABLE(acpi, int3402_thermal_match);
>
> static struct platform_driver int3402_thermal_driver = {
> .probe = int3402_thermal_probe,
> - .remove = int3402_thermal_remove,
> + .remove_new = int3402_thermal_remove,
> .driver = {
> .name = "int3402 thermal",
> .acpi_match_table = int3402_thermal_match,
> diff --git a/drivers/thermal/intel/int340x_thermal/int3403_thermal.c b/drivers/thermal/intel/int340x_thermal/int3403_thermal.c
> index e418d270bc76..9b33fd3a66da 100644
> --- a/drivers/thermal/intel/int340x_thermal/int3403_thermal.c
> +++ b/drivers/thermal/intel/int340x_thermal/int3403_thermal.c
> @@ -262,7 +262,7 @@ static int int3403_add(struct platform_device *pdev)
> return result;
> }
>
> -static int int3403_remove(struct platform_device *pdev)
> +static void int3403_remove(struct platform_device *pdev)
> {
> struct int3403_priv *priv = platform_get_drvdata(pdev);
>
> @@ -277,8 +277,6 @@ static int int3403_remove(struct platform_device *pdev)
> default:
> break;
> }
> -
> - return 0;
> }
>
> static const struct acpi_device_id int3403_device_ids[] = {
> @@ -293,7 +291,7 @@ MODULE_DEVICE_TABLE(acpi, int3403_device_ids);
>
> static struct platform_driver int3403_driver = {
> .probe = int3403_add,
> - .remove = int3403_remove,
> + .remove_new = int3403_remove,
> .driver = {
> .name = "int3403 thermal",
> .acpi_match_table = int3403_device_ids,
> diff --git a/drivers/thermal/intel/int340x_thermal/int3406_thermal.c b/drivers/thermal/intel/int340x_thermal/int3406_thermal.c
> index f5e42fc2acc0..1c266493c1aa 100644
> --- a/drivers/thermal/intel/int340x_thermal/int3406_thermal.c
> +++ b/drivers/thermal/intel/int340x_thermal/int3406_thermal.c
> @@ -178,13 +178,12 @@ static int int3406_thermal_probe(struct platform_device *pdev)
> return -ENODEV;
> }
>
> -static int int3406_thermal_remove(struct platform_device *pdev)
> +static void int3406_thermal_remove(struct platform_device *pdev)
> {
> struct int3406_thermal_data *d = platform_get_drvdata(pdev);
>
> thermal_cooling_device_unregister(d->cooling_dev);
> kfree(d->br);
> - return 0;
> }
>
> static const struct acpi_device_id int3406_thermal_match[] = {
> @@ -196,7 +195,7 @@ MODULE_DEVICE_TABLE(acpi, int3406_thermal_match);
>
> static struct platform_driver int3406_thermal_driver = {
> .probe = int3406_thermal_probe,
> - .remove = int3406_thermal_remove,
> + .remove_new = int3406_thermal_remove,
> .driver = {
> .name = "int3406 thermal",
> .acpi_match_table = int3406_thermal_match,
> --
> 2.39.0
>
Powered by blists - more mailing lists