platform/x86: Convert to platform remove callback returning void (part II)
cover platform/x86: Convert to platform remove callback returning void (part II)
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/[email protected]
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
Signature · 1 line
2.42.0
PATCH 1/2 platform/x86: asus-wmi: Convert to platform remove callback returning void
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.
--- drivers/platform/x86/asus-wmi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/platform/x86/asus-wmi.c +2 -3
@@ -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;
Signature · 1 line
2.42.0
PATCH 2/2 platform/x86: hp-wmi: Convert to platform remove callback returning void
In reply to Uwe Kleine-KönigThe .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.
--- drivers/platform/x86/hp/hp-wmi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +2 -4
@@ -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,
Signature · 1 line
2.42.0
Hi,
Quoted 9 lines · Uwe Kleine-König
Hello,
back when I sent a series to convert all platform drivers below
drivers/platformto 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
Quoted 20 lines
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/[email protected]
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
voiddrivers/platform/x86/asus-wmi.c | 5 ++--- drivers/platform/x86/hp/hp-wmi.c | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-)base-commit:
629a3b49f3f957e975253c54846090b8d5ed2e9b