Skip to content

Commit c2f2d9b

Browse files
committed
[FROM-ML] platform/x86: asus-armoury: fix mini-LED mode get/set on MODE2 devices
The mini-LED current_value attribute does not work on devices that use ASUS_WMI_DEVID_MINI_LED_MODE2 (2024 and newer models). Reading is broken: mini_led_mode_current_value_show() fetches the mode from the device but then decodes a literal 0 instead of the value it just read: mode = FIELD_GET(ASUS_MINI_LED_MODE_MASK, 0); So mode is always 0, and the attribute always reports the same thing regardless of the real hardware state. Writing is broken too. The number a user writes is an index; the value the firmware actually wants is looked up from that index in mini_led_mode_map[]. mini_led_mode_current_value_store() skips that lookup and passes the raw index straight to armoury_attr_uint_store(). On 2024 devices the firmware numbers its modes differently from the index, so some writes are rejected with -EINVAL and the rest send the wrong mode to the hardware. Fix both paths: decode the value actually read from the device when reading, and look up the firmware value before sending it when writing. Older (MODE1) devices were unaffected because there the index and the firmware value are the same. Fixes: f99eb09 ("platform/x86: asus-armoury: move existing tunings to asus-armoury module") Signed-off-by: Ahmed Yaseen <yaseen@ghoul.dev>
1 parent dcad54d commit c2f2d9b

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

drivers/platform/x86/asus-armoury.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ static ssize_t mini_led_mode_current_value_show(struct kobject *kobj,
370370
if (err)
371371
return err;
372372

373-
mode = FIELD_GET(ASUS_MINI_LED_MODE_MASK, 0);
373+
mode = FIELD_GET(ASUS_MINI_LED_MODE_MASK, mode);
374374

375375
for (i = 0; i < mini_led_mode_map_size; i++)
376376
if (mode == mini_led_mode_map[i])
@@ -386,6 +386,7 @@ static ssize_t mini_led_mode_current_value_store(struct kobject *kobj,
386386
{
387387
u32 *mini_led_mode_map;
388388
size_t mini_led_mode_map_size;
389+
char mapped_value[12];
389390
u32 mode;
390391
int err;
391392

@@ -414,9 +415,16 @@ static ssize_t mini_led_mode_current_value_store(struct kobject *kobj,
414415
return -ENODEV;
415416
}
416417

417-
return armoury_attr_uint_store(kobj, attr, buf, count,
418-
0, mini_led_mode_map[mode],
419-
NULL, asus_armoury.mini_led_dev_id);
418+
/*
419+
* armoury_attr_uint_store() parses and sends the value from the
420+
* passed buffer; hand it the mapped firmware value so the device
421+
* receives the translated mode instead of the raw index.
422+
*/
423+
snprintf(mapped_value, sizeof(mapped_value), "%u", mini_led_mode_map[mode]);
424+
425+
return armoury_attr_uint_store(kobj, attr, mapped_value, count, 0,
426+
mini_led_mode_map[mode], NULL,
427+
asus_armoury.mini_led_dev_id);
420428
}
421429

422430
static ssize_t mini_led_mode_possible_values_show(struct kobject *kobj,

0 commit comments

Comments
 (0)