On 1/9/2025 09:06, Kurt Borja wrote:
Replace platform_profile_register() with it's device managed version.
While at it, pass asus_wmi to the class device as drvdata and replace
uses of container_of() with dev_get_drvdata().
Signed-off-by: Kurt Borja <kuurtb@xxxxxxxxx>
Reviewed-by: Mario Limonciello <mario.limonciello@xxxxxxx>
---
drivers/platform/x86/asus-wmi.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 248490571e8c..5c7099dc6109 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -3806,7 +3806,7 @@ static int asus_wmi_platform_profile_get(struct platform_profile_handler *pprof,
struct asus_wmi *asus;
int tp;
- asus = container_of(pprof, struct asus_wmi, platform_profile_handler);
+ asus = dev_get_drvdata(&pprof->class_dev);
tp = asus->throttle_thermal_policy_mode;
switch (tp) {
@@ -3832,7 +3832,7 @@ static int asus_wmi_platform_profile_set(struct platform_profile_handler *pprof,
struct asus_wmi *asus;
int tp;
- asus = container_of(pprof, struct asus_wmi, platform_profile_handler);
+ asus = dev_get_drvdata(&pprof->class_dev);
switch (profile) {
case PLATFORM_PROFILE_PERFORMANCE:
@@ -3895,12 +3895,12 @@ static int platform_profile_setup(struct asus_wmi *asus)
asus->platform_profile_handler.dev = dev;
asus->platform_profile_handler.ops = &asus_wmi_platform_profile_ops;
- err = platform_profile_register(&asus->platform_profile_handler, NULL);
+ err = devm_platform_profile_register(&asus->platform_profile_handler, asus);
if (err == -EEXIST) {
pr_warn("%s, a platform_profile handler is already registered\n", __func__);
return 0;
} else if (err) {
- pr_err("%s, failed at platform_profile_register: %d\n", __func__, err);
+ pr_err("%s, failed at devm_platform_profile_register: %d\n", __func__, err);
return err;
}
@@ -4859,8 +4859,6 @@ static int asus_wmi_add(struct platform_device *pdev)
fail_sysfs:
fail_custom_fan_curve:
fail_platform_profile_setup:
- if (asus->platform_profile_support)
- platform_profile_remove(&asus->platform_profile_handler);
fail_fan_boost_mode:
fail_platform:
kfree(asus);
@@ -4886,9 +4884,6 @@ static void asus_wmi_remove(struct platform_device *device)
throttle_thermal_policy_set_default(asus);
asus_wmi_battery_exit(asus);
- if (asus->platform_profile_support)
- platform_profile_remove(&asus->platform_profile_handler);
-
kfree(asus);
}