From: Ethan Tidmore <ethantidmore06@gmail.com>
To: "Corentin Chary" <corentin.chary@gmail.com>,
"Luke D . Jones" <luke@ljones.dev>,
"Denis Benato" <denis.benato@linux.dev>,
"Hans de Goede" <hansg@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org,
Ethan Tidmore <ethantidmore06@gmail.com>
Subject: [PATCH 2/2] platform/x86: asus-wmi: Refactor control flow
Date: Thu, 26 Mar 2026 18:11:54 -0500 [thread overview]
Message-ID: <20260326231154.856729-3-ethantidmore06@gmail.com> (raw)
In-Reply-To: <20260326231154.856729-1-ethantidmore06@gmail.com>
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);
+ 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 = {
--
2.53.0
next prev parent reply other threads:[~2026-03-26 23:12 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 ` Ethan Tidmore [this message]
2026-03-31 13:07 ` [PATCH 2/2] platform/x86: asus-wmi: Refactor control flow Ilpo Järvinen
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=20260326231154.856729-3-ethantidmore06@gmail.com \
--to=ethantidmore06@gmail.com \
--cc=corentin.chary@gmail.com \
--cc=denis.benato@linux.dev \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--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®