mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Ethan Tidmore <ethantidmore06@gmail.com>
Cc: Corentin Chary <corentin.chary@gmail.com>,
	 "Luke D . Jones" <luke@ljones.dev>,
	Denis Benato <denis.benato@linux.dev>,
	 Hans de Goede <hansg@kernel.org>,
	platform-driver-x86@vger.kernel.org,
	 LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] platform/x86: asus-wmi: Refactor control flow
Date: Tue, 31 Mar 2026 16:07:18 +0300 (EEST)	[thread overview]
Message-ID: <3d612e74-f224-1dd1-11d8-3d25592614d6@linux.intel.com> (raw)
In-Reply-To: <20260326231154.856729-3-ethantidmore06@gmail.com>

On Thu, 26 Mar 2026, Ethan Tidmore wrote:

> Refactor control flow in update_screenpad_bl_status() to avoid
> unnecessary if statements and error checking.
> 
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> ---
>  drivers/platform/x86/asus-wmi.c | 22 +++++++---------------
>  1 file changed, 7 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 80144c412b90..f8e389c54fe4 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -4422,25 +4422,17 @@ static int read_screenpad_brightness(struct backlight_device *bd)
>  static int update_screenpad_bl_status(struct backlight_device *bd)
>  {
>  	u32 ctrl_param = bd->props.brightness;
> -	int err = 0;
> +	int err;
>  
> -	if (bd->props.power) {
> -		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 1, NULL);
> -		if (err < 0)
> -			return err;
> +	if (!bd->props.power)
> +		return asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 0, NULL);
>  
> -		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_LIGHT, ctrl_param, NULL);
> -		if (err < 0)
> -			return err;
> -	}
>  
> -	if (!bd->props.power) {
> -		err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 0, NULL);
> -		if (err < 0)
> -			return err;
> -	}
> +	err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 1, NULL);

Couldn't this 0 / 1 variation be handled without if?

> +	if (err < 0)
> +		return err;
>  
> -	return err;
> +	return asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_LIGHT, ctrl_param, NULL);
>  }
>  
>  static const struct backlight_ops asus_screenpad_bl_ops = {
> 

-- 
 i.


  reply	other threads:[~2026-03-31 13:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-26 23:11 [PATCH 0/2] platform/x86: asus-wmi: Clean up asus_wmi_set_devstate() Ethan Tidmore
2026-03-26 23:11 ` [PATCH 1/2] platform/x86: asus-wmi: Remove redundant condition Ethan Tidmore
2026-03-31 13:07   ` Ilpo Järvinen
2026-03-26 23:11 ` [PATCH 2/2] platform/x86: asus-wmi: Refactor control flow Ethan Tidmore
2026-03-31 13:07   ` Ilpo Järvinen [this message]
2026-03-26 23:14 ` [PATCH 0/2] platform/x86: asus-wmi: Clean up asus_wmi_set_devstate() Ethan Tidmore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3d612e74-f224-1dd1-11d8-3d25592614d6@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=corentin.chary@gmail.com \
    --cc=denis.benato@linux.dev \
    --cc=ethantidmore06@gmail.com \
    --cc=hansg@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luke@ljones.dev \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®