mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bartu Alev <bartualev@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>,
	"Antheas Kapenekakis" <lkml@antheas.dev>,
	"Benjamin Tissoires" <bentiss@kernel.org>
Cc: Alex Bogusta <alex@bogusta.com>,
	 Denis Benato <benato.denis96@gmail.com>,
	 platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org,  Bartu Alev <bartualev@gmail.com>,
	stable@vger.kernel.org
Subject: [PATCH v2 0/2] platform/asus: asus-wmi: fix and unify keyboard brightness key handling
Date: Sat, 21 Nov 2026 02:42:26 +0300	[thread overview]
Message-ID: <20261121-b4-asus-kbd-fixes-v2-0-52cda07d233f@gmail.com> (raw)

The WMI hotkey path and the HID event path in asus-wmi step the
keyboard backlight with two separate copies of the same arithmetic, and
the two copies disagree. The WMI copy computes the step in the unsigned
enum led_brightness and stores the new level without clamping it, so
holding brightness-down at zero drives the cached level negative, the
"value >= 0" apply check then drops every following transition, and the
hardware-changed notification hands the wrapped negative to userspace as
4294967294+ (or -ENODATA for -1). Pressing brightness-up at maximum
reports 4, above max_brightness.

The first patch fixes the signedness, bounds clamping, and notification
snapshot on its own so -stable trees can pick it up without the rest of
the series. The second patch removes the duplication: both paths now
step through one shared helper that reads, computes, and writes the
level inside a single hold of asus_ref.lock.

With the series applied, the level stays within
[0, ASUS_EV_MAX_BRIGHTNESS] on every transition and userspace sees no
wrapped or out-of-range values.

Signed-off-by: Bartu Alev <bartualev@gmail.com>
---
Changes in v2:
- Rebase onto review-ilpo-next, where the driver moved to
  drivers/platform/asus/asus-wmi.c, and update subject prefixes to
  'platform/asus:'.
- Patch 1: Fix Fixes: tag to fac55d29581f ("platform/x86: asus-wmi:
  Add support for multiple kbd led handlers") and reference Alex
  Bogusta's earlier patch [1].
- Patch 1: Step in signed int instead of unsigned enum led_brightness
  and add an explanatory comment; prevents 0 - 1 from wrapping and
  clamping to max brightness (3) if patch 1 is applied standalone on
  -stable.
- Patch 1: Clear kbd_led_notify atomically when snapshotting it at the
  top of kbd_led_update_all() instead of after do_kbd_led_set().
- Patch 2: Drop inline from asus_kbd_led_calc_next(), drop the
  unreachable default case (all enum values are covered), drop the
  redundant NULL check in void asus_kbd_led_step(), and normalize an
  unknown (-1) starting level to 0 before stepping.
- Link to v1: https://patch.msgid.link/20261025-b4-asus-kbd-fixes-v1-0-fa4dcf7d2a69@gmail.com

[1] https://lore.kernel.org/r/20261016015117.32174-1-alex@bogusta.com/

---
Bartu Alev (2):
      platform/asus: asus-wmi: clamp keyboard brightness hotkey updates
      platform/asus: asus-wmi: unify WMI and HID keyboard brightness stepping

 drivers/platform/asus/asus-wmi.c | 77 +++++++++++++++++++---------------------
 1 file changed, 36 insertions(+), 41 deletions(-)
---
base-commit: 2268d837dea13a78639fa3dad60472bb67478709
change-id: 20261025-b4-asus-kbd-fixes-6c7e3780597b

Best regards,
--  
Bartu Alev <bartualev@gmail.com>


             reply	other threads:[~2026-11-20 23:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 23:42 Bartu Alev [this message]
2026-11-20 23:42 ` [PATCH v2 1/2] platform/asus: asus-wmi: clamp keyboard brightness hotkey updates Bartu Alev
2026-11-20 23:42 ` [PATCH v2 2/2] platform/asus: asus-wmi: unify WMI and HID keyboard brightness stepping Bartu Alev

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=20261121-b4-asus-kbd-fixes-v2-0-52cda07d233f@gmail.com \
    --to=bartualev@gmail.com \
    --cc=alex@bogusta.com \
    --cc=benato.denis96@gmail.com \
    --cc=bentiss@kernel.org \
    --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=lkml@antheas.dev \
    --cc=luke@ljones.dev \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=stable@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®