[PATCH] platform/x86: ideapad-laptop: Use str_on_off() helper

Rong Zhang posted 1 patch 3 months, 1 week ago
drivers/platform/x86/lenovo/ideapad-laptop.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
[PATCH] platform/x86: ideapad-laptop: Use str_on_off() helper
Posted by Rong Zhang 3 months, 1 week ago
Use the str_on_off() helper instead of open-coding the same operation.
This improves code readability.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@inria.fr>
Closes: https://lore.kernel.org/r/202510311551.xjWbHTrm-lkp@intel.com/
Suggested-by: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/2bae2ea7-2ef9-0cfa-0c2c-39a7043b2aa5@linux.intel.com/
Signed-off-by: Rong Zhang <i@rong.moe>
---
This patch is based on 'review-ilpo-next' of pdx86/platform-drivers-x86,
hence depends on my previous patch ("platform/x86: ideapad-laptop:
Protect GBMD/SBMC calls with mutex").
---
 drivers/platform/x86/lenovo/ideapad-laptop.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c b/drivers/platform/x86/lenovo/ideapad-laptop.c
index d2bfaa532020..931a72a2a487 100644
--- a/drivers/platform/x86/lenovo/ideapad-laptop.c
+++ b/drivers/platform/x86/lenovo/ideapad-laptop.c
@@ -475,25 +475,25 @@ static int debugfs_status_show(struct seq_file *s, void *data)
 		if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL, &value))
 			seq_printf(s, "Backlight now:  %lu\n", value);
 		if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &value))
-			seq_printf(s, "BL power value: %s (%lu)\n", value ? "on" : "off", value);
+			seq_printf(s, "BL power value: %s (%lu)\n", str_on_off(value), value);
 
 		seq_puts(s, "=====================\n");
 
 		if (!read_ec_data(priv->adev->handle, VPCCMD_R_RF, &value))
-			seq_printf(s, "Radio status: %s (%lu)\n", value ? "on" : "off", value);
+			seq_printf(s, "Radio status: %s (%lu)\n", str_on_off(value), value);
 		if (!read_ec_data(priv->adev->handle, VPCCMD_R_WIFI, &value))
-			seq_printf(s, "Wifi status:  %s (%lu)\n", value ? "on" : "off", value);
+			seq_printf(s, "Wifi status:  %s (%lu)\n", str_on_off(value), value);
 		if (!read_ec_data(priv->adev->handle, VPCCMD_R_BT, &value))
-			seq_printf(s, "BT status:    %s (%lu)\n", value ? "on" : "off", value);
+			seq_printf(s, "BT status:    %s (%lu)\n", str_on_off(value), value);
 		if (!read_ec_data(priv->adev->handle, VPCCMD_R_3G, &value))
-			seq_printf(s, "3G status:    %s (%lu)\n", value ? "on" : "off", value);
+			seq_printf(s, "3G status:    %s (%lu)\n", str_on_off(value), value);
 
 		seq_puts(s, "=====================\n");
 
 		if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value))
-			seq_printf(s, "Touchpad status: %s (%lu)\n", value ? "on" : "off", value);
+			seq_printf(s, "Touchpad status: %s (%lu)\n", str_on_off(value), value);
 		if (!read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &value))
-			seq_printf(s, "Camera status:   %s (%lu)\n", value ? "on" : "off", value);
+			seq_printf(s, "Camera status:   %s (%lu)\n", str_on_off(value), value);
 	}
 
 	seq_puts(s, "=====================\n");

base-commit: ba06b928f05bfd2785260819f6b34b658a04a4e6
-- 
2.51.0

Re: [PATCH] platform/x86: ideapad-laptop: Use str_on_off() helper
Posted by Ilpo Järvinen 3 months ago
On Sat, 1 Nov 2025, Rong Zhang wrote:

> Use the str_on_off() helper instead of open-coding the same operation.
> This improves code readability.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Julia Lawall <julia.lawall@inria.fr>
> Closes: https://lore.kernel.org/r/202510311551.xjWbHTrm-lkp@intel.com/
> Suggested-by: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
> Link: https://lore.kernel.org/r/2bae2ea7-2ef9-0cfa-0c2c-39a7043b2aa5@linux.intel.com/
> Signed-off-by: Rong Zhang <i@rong.moe>
> ---
> This patch is based on 'review-ilpo-next' of pdx86/platform-drivers-x86,
> hence depends on my previous patch ("platform/x86: ideapad-laptop:
> Protect GBMD/SBMC calls with mutex").
> ---
>  drivers/platform/x86/lenovo/ideapad-laptop.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/platform/x86/lenovo/ideapad-laptop.c b/drivers/platform/x86/lenovo/ideapad-laptop.c
> index d2bfaa532020..931a72a2a487 100644
> --- a/drivers/platform/x86/lenovo/ideapad-laptop.c
> +++ b/drivers/platform/x86/lenovo/ideapad-laptop.c
> @@ -475,25 +475,25 @@ static int debugfs_status_show(struct seq_file *s, void *data)
>  		if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL, &value))
>  			seq_printf(s, "Backlight now:  %lu\n", value);
>  		if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_POWER, &value))
> -			seq_printf(s, "BL power value: %s (%lu)\n", value ? "on" : "off", value);
> +			seq_printf(s, "BL power value: %s (%lu)\n", str_on_off(value), value);

This change should also add the include for str_on_off().

--
 i.

>  
>  		seq_puts(s, "=====================\n");
>  
>  		if (!read_ec_data(priv->adev->handle, VPCCMD_R_RF, &value))
> -			seq_printf(s, "Radio status: %s (%lu)\n", value ? "on" : "off", value);
> +			seq_printf(s, "Radio status: %s (%lu)\n", str_on_off(value), value);
>  		if (!read_ec_data(priv->adev->handle, VPCCMD_R_WIFI, &value))
> -			seq_printf(s, "Wifi status:  %s (%lu)\n", value ? "on" : "off", value);
> +			seq_printf(s, "Wifi status:  %s (%lu)\n", str_on_off(value), value);
>  		if (!read_ec_data(priv->adev->handle, VPCCMD_R_BT, &value))
> -			seq_printf(s, "BT status:    %s (%lu)\n", value ? "on" : "off", value);
> +			seq_printf(s, "BT status:    %s (%lu)\n", str_on_off(value), value);
>  		if (!read_ec_data(priv->adev->handle, VPCCMD_R_3G, &value))
> -			seq_printf(s, "3G status:    %s (%lu)\n", value ? "on" : "off", value);
> +			seq_printf(s, "3G status:    %s (%lu)\n", str_on_off(value), value);
>  
>  		seq_puts(s, "=====================\n");
>  
>  		if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value))
> -			seq_printf(s, "Touchpad status: %s (%lu)\n", value ? "on" : "off", value);
> +			seq_printf(s, "Touchpad status: %s (%lu)\n", str_on_off(value), value);
>  		if (!read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, &value))
> -			seq_printf(s, "Camera status:   %s (%lu)\n", value ? "on" : "off", value);
> +			seq_printf(s, "Camera status:   %s (%lu)\n", str_on_off(value), value);
>  	}
>  
>  	seq_puts(s, "=====================\n");
> 
> base-commit: ba06b928f05bfd2785260819f6b34b658a04a4e6
>