public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] platform/x86: Convert to platform remove callback returning void (part II)
@ 2023-12-04 21:52 Uwe Kleine-König
  2023-12-04 21:52 ` [PATCH 1/2] platform/x86: asus-wmi: Convert to platform remove callback returning void Uwe Kleine-König
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2023-12-04 21:52 UTC (permalink / raw)
  To: Corentin Chary, Hans de Goede, Ilpo Järvinen, Rishit Bansal,
	Mario Limonciello, Jonathan Singer, Krzysztof Kozlowski,
	SungHwan Jung
  Cc: acpi4asus-user, platform-driver-x86, linux-kernel, kernel

Hello,

back when I sent a series to convert all platform drivers below
drivers/platform to use .remove_new()[1] I missed the two drivers
converted here.

The two patches have no dependency, so each can be picked individually
if needed by the driver maintainers. (But I won't say no if Hans picks
up both patches together :-)

See commit 5c5a7680e67b ("platform: Provide a remove callback that
returns no value") for an extended explanation and the eventual goal.

Best regards
Uwe

[1] https://lore.kernel.org/r/20230927081040.2198742-1-u.kleine-koenig@pengutronix.de


Uwe Kleine-König (2):
  platform/x86: asus-wmi: Convert to platform remove callback returning
    void
  platform/x86: hp-wmi: Convert to platform remove callback returning
    void

 drivers/platform/x86/asus-wmi.c  | 5 ++---
 drivers/platform/x86/hp/hp-wmi.c | 6 ++----
 2 files changed, 4 insertions(+), 7 deletions(-)

base-commit: 629a3b49f3f957e975253c54846090b8d5ed2e9b
-- 
2.42.0


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

* [PATCH 1/2] platform/x86: asus-wmi: Convert to platform remove callback returning void
  2023-12-04 21:52 [PATCH 0/2] platform/x86: Convert to platform remove callback returning void (part II) Uwe Kleine-König
@ 2023-12-04 21:52 ` Uwe Kleine-König
  2023-12-04 21:52 ` [PATCH 2/2] platform/x86: hp-wmi: " Uwe Kleine-König
  2023-12-11 10:04 ` [PATCH 0/2] platform/x86: Convert to platform remove callback returning void (part II) Hans de Goede
  2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2023-12-04 21:52 UTC (permalink / raw)
  To: Corentin Chary, Hans de Goede, Ilpo Järvinen
  Cc: acpi4asus-user, platform-driver-x86, linux-kernel, 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 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.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/platform/x86/asus-wmi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index ca668cf04020..d1ec40e4881d 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -4604,7 +4604,7 @@ static int asus_wmi_add(struct platform_device *pdev)
 	return err;
 }
 
-static int asus_wmi_remove(struct platform_device *device)
+static void asus_wmi_remove(struct platform_device *device)
 {
 	struct asus_wmi *asus;
 
@@ -4627,7 +4627,6 @@ static int asus_wmi_remove(struct platform_device *device)
 		platform_profile_remove();
 
 	kfree(asus);
-	return 0;
 }
 
 /* Platform driver - hibernate/resume callbacks *******************************/
@@ -4749,7 +4748,7 @@ int __init_or_module asus_wmi_register_driver(struct asus_wmi_driver *driver)
 		return -EBUSY;
 
 	platform_driver = &driver->platform_driver;
-	platform_driver->remove = asus_wmi_remove;
+	platform_driver->remove_new = asus_wmi_remove;
 	platform_driver->driver.owner = driver->owner;
 	platform_driver->driver.name = driver->name;
 	platform_driver->driver.pm = &asus_pm_ops;
-- 
2.42.0


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

* [PATCH 2/2] platform/x86: hp-wmi: Convert to platform remove callback returning void
  2023-12-04 21:52 [PATCH 0/2] platform/x86: Convert to platform remove callback returning void (part II) Uwe Kleine-König
  2023-12-04 21:52 ` [PATCH 1/2] platform/x86: asus-wmi: Convert to platform remove callback returning void Uwe Kleine-König
@ 2023-12-04 21:52 ` Uwe Kleine-König
  2023-12-11 10:04 ` [PATCH 0/2] platform/x86: Convert to platform remove callback returning void (part II) Hans de Goede
  2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2023-12-04 21:52 UTC (permalink / raw)
  To: Hans de Goede, Ilpo Järvinen, Rishit Bansal,
	Mario Limonciello, Jonathan Singer, Krzysztof Kozlowski,
	SungHwan Jung
  Cc: platform-driver-x86, linux-kernel, 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 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.

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

diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
index 8ebb7be52ee7..e536604225c5 100644
--- a/drivers/platform/x86/hp/hp-wmi.c
+++ b/drivers/platform/x86/hp/hp-wmi.c
@@ -1478,7 +1478,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
 	return 0;
 }
 
-static int __exit hp_wmi_bios_remove(struct platform_device *device)
+static void __exit hp_wmi_bios_remove(struct platform_device *device)
 {
 	int i;
 
@@ -1502,8 +1502,6 @@ static int __exit hp_wmi_bios_remove(struct platform_device *device)
 
 	if (platform_profile_support)
 		platform_profile_remove();
-
-	return 0;
 }
 
 static int hp_wmi_resume_handler(struct device *device)
@@ -1560,7 +1558,7 @@ static struct platform_driver hp_wmi_driver __refdata = {
 		.pm = &hp_wmi_pm_ops,
 		.dev_groups = hp_wmi_groups,
 	},
-	.remove = __exit_p(hp_wmi_bios_remove),
+	.remove_new = __exit_p(hp_wmi_bios_remove),
 };
 
 static umode_t hp_wmi_hwmon_is_visible(const void *data,
-- 
2.42.0


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

* Re: [PATCH 0/2] platform/x86: Convert to platform remove callback returning void (part II)
  2023-12-04 21:52 [PATCH 0/2] platform/x86: Convert to platform remove callback returning void (part II) Uwe Kleine-König
  2023-12-04 21:52 ` [PATCH 1/2] platform/x86: asus-wmi: Convert to platform remove callback returning void Uwe Kleine-König
  2023-12-04 21:52 ` [PATCH 2/2] platform/x86: hp-wmi: " Uwe Kleine-König
@ 2023-12-11 10:04 ` Hans de Goede
  2 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2023-12-11 10:04 UTC (permalink / raw)
  To: Uwe Kleine-König, Corentin Chary, Ilpo Järvinen,
	Rishit Bansal, Mario Limonciello, Jonathan Singer,
	Krzysztof Kozlowski, SungHwan Jung
  Cc: acpi4asus-user, platform-driver-x86, linux-kernel, kernel

Hi,

On 12/4/23 22:52, Uwe Kleine-König wrote:
> Hello,
> 
> back when I sent a series to convert all platform drivers below
> drivers/platform to use .remove_new()[1] I missed the two drivers
> converted here.
> 
> The two patches have no dependency, so each can be picked individually
> if needed by the driver maintainers. (But I won't say no if Hans picks
> up both patches together :-)

Thank you for your patch-series, I've applied the series to my
review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans





> See commit 5c5a7680e67b ("platform: Provide a remove callback that
> returns no value") for an extended explanation and the eventual goal.
> 
> Best regards
> Uwe
> 
> [1] https://lore.kernel.org/r/20230927081040.2198742-1-u.kleine-koenig@pengutronix.de
> 
> 
> Uwe Kleine-König (2):
>   platform/x86: asus-wmi: Convert to platform remove callback returning
>     void
>   platform/x86: hp-wmi: Convert to platform remove callback returning
>     void
> 
>  drivers/platform/x86/asus-wmi.c  | 5 ++---
>  drivers/platform/x86/hp/hp-wmi.c | 6 ++----
>  2 files changed, 4 insertions(+), 7 deletions(-)
> 
> base-commit: 629a3b49f3f957e975253c54846090b8d5ed2e9b


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

end of thread, other threads:[~2023-12-11 10:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-04 21:52 [PATCH 0/2] platform/x86: Convert to platform remove callback returning void (part II) Uwe Kleine-König
2023-12-04 21:52 ` [PATCH 1/2] platform/x86: asus-wmi: Convert to platform remove callback returning void Uwe Kleine-König
2023-12-04 21:52 ` [PATCH 2/2] platform/x86: hp-wmi: " Uwe Kleine-König
2023-12-11 10:04 ` [PATCH 0/2] platform/x86: Convert to platform remove callback returning void (part II) Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox