platform/x86: msi-wmi: Reformat msi_wmi_notify()

Reformats msi_wmi_notify() to use a switch statement that reduces nesting
and prepares the function to support additional ACPI types.

Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Link: https://patch.msgid.link/20260613021654.933618-2-derekjohn.clark@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
Derek J. Clark
2026-06-12 19:16:53 -07:00
committed by Ilpo Järvinen
parent b8f0a45fed
commit dee82409a8

View File

@@ -172,44 +172,51 @@ static const struct backlight_ops msi_backlight_ops = {
static void msi_wmi_notify(union acpi_object *obj, void *context)
{
struct key_entry *key;
struct key_entry *key = NULL;
int eventcode = 0;
if (obj && obj->type == ACPI_TYPE_INTEGER) {
int eventcode = obj->integer.value;
if (!obj)
return;
switch (obj->type) {
case ACPI_TYPE_INTEGER:
eventcode = obj->integer.value;
pr_debug("Eventcode: 0x%x\n", eventcode);
key = sparse_keymap_entry_from_scancode(msi_wmi_input_dev,
eventcode);
if (!key) {
pr_info("Unknown key pressed - %x\n", eventcode);
break;
default:
pr_info("Unknown event received\n");
return;
}
key = sparse_keymap_entry_from_scancode(msi_wmi_input_dev, eventcode);
if (!key) {
pr_info("Unknown key pressed - 0x%x\n", eventcode);
return;
}
if (event_wmi->quirk_last_pressed) {
ktime_t cur = ktime_get_real();
ktime_t diff = ktime_sub(cur, last_pressed);
/* Ignore event if any event happened in a 50 ms
* timeframe -> Key press may result in 10-20 GPEs
*/
if (ktime_to_us(diff) < 1000 * 50) {
pr_debug("Suppressed key event 0x%X - Last press was %lld us ago\n",
key->code, ktime_to_us(diff));
return;
}
last_pressed = cur;
}
if (event_wmi->quirk_last_pressed) {
ktime_t cur = ktime_get_real();
ktime_t diff = ktime_sub(cur, last_pressed);
/* Ignore event if any event happened in a 50 ms
timeframe -> Key press may result in 10-20 GPEs */
if (ktime_to_us(diff) < 1000 * 50) {
pr_debug("Suppressed key event 0x%X - "
"Last press was %lld us ago\n",
key->code, ktime_to_us(diff));
return;
}
last_pressed = cur;
}
/* Brightness is served via acpi video driver */
if (key->type == KE_KEY &&
(backlight || (key->code == MSI_KEY_BRIGHTNESSUP ||
key->code == MSI_KEY_BRIGHTNESSDOWN)))
return;
if (key->type == KE_KEY &&
/* Brightness is served via acpi video driver */
(backlight ||
(key->code != MSI_KEY_BRIGHTNESSUP &&
key->code != MSI_KEY_BRIGHTNESSDOWN))) {
pr_debug("Send key: 0x%X - Input layer keycode: %d\n",
key->code, key->keycode);
sparse_keymap_report_entry(msi_wmi_input_dev, key, 1,
true);
}
} else
pr_info("Unknown event received\n");
pr_debug("Send key: 0x%X - Input layer keycode: %d\n", key->code, key->keycode);
sparse_keymap_report_entry(msi_wmi_input_dev, key, 1, true);
}
static int __init msi_wmi_backlight_setup(void)