[PATCH v3 09/19] platform/x86: asus-wmi: Use devm_platform_profile_register()

Kurt Borja posted 19 patches 11 months ago
There is a newer version of this series
[PATCH v3 09/19] platform/x86: asus-wmi: Use devm_platform_profile_register()
Posted by Kurt Borja 11 months ago
Replace platform_profile_register() with it's device managed version.

Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
 drivers/platform/x86/asus-wmi.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 3d77f7454953..f8437cff66df 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -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, asus);
+	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);
 }
 
-- 
2.48.0
Re: [PATCH v3 09/19] platform/x86: asus-wmi: Use devm_platform_profile_register()
Posted by Ilpo Järvinen 11 months ago
On Wed, 15 Jan 2025, Kurt Borja wrote:

> Replace platform_profile_register() with it's device managed version.
> 
> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> Signed-off-by: Kurt Borja <kuurtb@gmail.com>
> ---
>  drivers/platform/x86/asus-wmi.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 3d77f7454953..f8437cff66df 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -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, asus);
> +	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);

Hi,

I'm sorry I didn't notice this while passing through the patches 
yesterday.

Could you please make this error message plain english instead of piling 
even more kernel C specifics to it? Preferrably, an user seeing a kernel 
error message should not be required to know/understand any C, so don't 
print __func__ nor write function names into any error/warning/info level 
messages.

Also, it should use dev_err() I think (platform_profile_setup() seems to
mix pr_*() & dev_*() prints with no good reason).

-- 
 i.

>  		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);
>  }
>  
>
Re: [PATCH v3 09/19] platform/x86: asus-wmi: Use devm_platform_profile_register()
Posted by Kurt Borja 11 months ago
On Wed, Jan 15, 2025 at 04:08:35PM +0200, Ilpo Järvinen wrote:
> On Wed, 15 Jan 2025, Kurt Borja wrote:
> 
> > Replace platform_profile_register() with it's device managed version.
> > 
> > Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> > Signed-off-by: Kurt Borja <kuurtb@gmail.com>
> > ---
> >  drivers/platform/x86/asus-wmi.c | 9 ++-------
> >  1 file changed, 2 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> > index 3d77f7454953..f8437cff66df 100644
> > --- a/drivers/platform/x86/asus-wmi.c
> > +++ b/drivers/platform/x86/asus-wmi.c
> > @@ -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, asus);
> > +	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);
> 
> Hi,
> 
> I'm sorry I didn't notice this while passing through the patches 
> yesterday.
> 
> Could you please make this error message plain english instead of piling 
> even more kernel C specifics to it? Preferrably, an user seeing a kernel 
> error message should not be required to know/understand any C, so don't 
> print __func__ nor write function names into any error/warning/info level 
> messages.

Hi,

Sure!

> 
> Also, it should use dev_err() I think (platform_profile_setup() seems to
> mix pr_*() & dev_*() prints with no good reason).

I also think this should be dev_err, but I don't know this driver
enough. Also I think driver specific platform_profile_register error
messages are a bit redundant, as platform_profile_registers already logs
most important failures with dev_err.

~ Kurt

> 
> -- 
>  i.
> 
> >  		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);
> >  }
> >  
> >