platform/x86: asus-wmi: Accept buffer result from DSTS
PATCH 1/1 platform/x86: asus-wmi: Accept buffer result from DSTS
On the ASUS Zenbook S14 UX5406AA (BIOS UX5406AA.310) the WMNB method returns an 8-byte buffer instead of an integer when DSTS is called for ASUS_WMI_DEVID_RSOC (0x00120057). The first dword holds the usual status bits, including ASUS_WMI_DSTS_PRESENCE_BIT, and the second dword holds the current charge limit:
If ((IIA0 == 0x00120057))
{
Name (BCMV, Buffer (0x08) { ... })
CreateDWordField (BCMV, Zero, BCML)
CreateDWordField (BCMV, 0x04, BCMH)
...
Local0 = 0x00010000
...
BCML = Local0
Return (BCMV)
}asus_wmi_evaluate_method3() only handles ACPI_TYPE_INTEGER results and treats anything else as 0. asus_wmi_dev_is_present() therefore reports RSOC as absent, the battery hook is never registered and charge_control_end_threshold is not exposed, even though setting the limit through DEVS works on this machine.
Accept a buffer of at least four bytes and use its first dword as the result. Integer results are handled as before.
Tested on a UX5406AA: charge_control_end_threshold is now present and upower/GNOME can set an 80% charge limit.
The firmware analysis and this patch were prepared with the help of an AI coding assistant (Claude Opus 5.5, Anthropic); see the notes below.
--- drivers/platform/asus/asus-wmi.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/platform/asus/asus-wmi.c +9 -0
@@ -41,6 +41,7 @@#include <linux/slab.h> #include <linux/spinlock.h> #include <linux/types.h> +#include <linux/unaligned.h> #include <linux/units.h> #include <acpi/battery.h>
@@ -395,6 +396,14 @@ static int asus_wmi_evaluate_method3(u32 method_id, obj = (union acpi_object *)output.pointer;if (obj && obj->type ==ACPI_TYPE_INTEGER ) tmp = (u32 ) obj->integer.value; +/* +* Some firmware returns a buffer from DSTS instead of an integer, with +* the status bits in the first dword, e.g. for ASUS_WMI_DEVID_RSOC on +* the Zenbook S14 UX5406AA. +*/ +else if (obj && obj->type ==ACPI_TYPE_BUFFER && + obj->buffer.length >=sizeof (u32)) + tmp =get_unaligned_le32 (obj->buffer.pointer);pr_debug ("Result: 0x%08x\n" , tmp);if (retval)
base-commit: 61c0dac952b9308884936d05cce97565a5c89af4
Signature · 1 line
2.55.0