aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/intel-hid.c
diff options
context:
space:
mode:
authorZhen Gong <zhengong@usc.edu>2020-11-08 01:23:19 -0800
committerHans de Goede <hdegoede@redhat.com>2020-11-09 15:16:30 +0100
commit97ab4516205eedde0b6565e47175d825b88d6759 (patch)
tree4f111e1d32f22b7832a8c1d661e8285eae4b0ce3 /drivers/platform/x86/intel-hid.c
parentplatform/x86: intel_pmc_core: Assign boolean values to a bool variable (diff)
downloadlinux-dev-97ab4516205eedde0b6565e47175d825b88d6759.tar.xz
linux-dev-97ab4516205eedde0b6565e47175d825b88d6759.zip
platform/x86: intel-hid: fix _DSM function index handling
According to the ACPI spec 9.1.1 _DSM (Device Specific Method), intel_hid_dsm_fn_mask, acquired from function index 0, is "a buffer containing one bit for each function index". When validitaing fn_index, it should be compared with corresponding bit. This buffer is usually longer than a byte. Depending on whether INTEL_HID_DSM_HEBC_V2_FN exist, it could be either "Buffer (0x02) { 0xFF, 0x01 }" or "Buffer (0x02) { 0xFF, 0x03 }". Probably it won't grow larger according to the description. On older platforms, available functions could be fewer or not supported at all, i.e., "Buffer (One) { 0x00 }". Signed-off-by: Zhen Gong <zhengong@usc.edu> Link: https://lore.kernel.org/r/CAJCLVRCyp0ASdWTx-PxsrDC9zFBPw0U2AtPip+_Hpj2r5gUPwA@mail.gmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/platform/x86/intel-hid.c')
-rw-r--r--drivers/platform/x86/intel-hid.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/platform/x86/intel-hid.c b/drivers/platform/x86/intel-hid.c
index 86261970bd8f..9a52e56f75da 100644
--- a/drivers/platform/x86/intel-hid.c
+++ b/drivers/platform/x86/intel-hid.c
@@ -141,7 +141,7 @@ static bool intel_hid_execute_method(acpi_handle handle,
method_name = (char *)intel_hid_dsm_fn_to_method[fn_index];
- if (!(intel_hid_dsm_fn_mask & fn_index))
+ if (!(intel_hid_dsm_fn_mask & BIT(fn_index)))
goto skip_dsm_exec;
/* All methods expects a package with one integer element */
@@ -214,7 +214,19 @@ static void intel_hid_init_dsm(acpi_handle handle)
obj = acpi_evaluate_dsm_typed(handle, &intel_dsm_guid, 1, 0, NULL,
ACPI_TYPE_BUFFER);
if (obj) {
- intel_hid_dsm_fn_mask = *obj->buffer.pointer;
+ switch (obj->buffer.length) {
+ default:
+ case 2:
+ intel_hid_dsm_fn_mask = *(u16 *)obj->buffer.pointer;
+ break;
+ case 1:
+ intel_hid_dsm_fn_mask = *obj->buffer.pointer;
+ break;
+ case 0:
+ acpi_handle_warn(handle, "intel_hid_dsm_fn_mask length is zero\n");
+ intel_hid_dsm_fn_mask = 0;
+ break;
+ }
ACPI_FREE(obj);
}