Commit 1c3fdf12 authored by Darren Hart (VMware)'s avatar Darren Hart (VMware)

platform/x86: intel-vbtn: Simplify autorelease logic

The new notify_handler logic determining if autorelease should be used or
not is a bit awkward, and can result in more than one call to
sparse_keymap_report_event for the same event (scancode). The nesting
and long lines also made it difficult to read.

Simplify the logic by eliminating a level of nesting with a goto and
always calculate autorelease and val so we can make a single call to
sparse_keymap_report_event.
Signed-off-by: default avatarDarren Hart (VMware) <dvhart@infradead.org>
Reviewed-by: default avatarStefan Brüns <stefan.bruens@rwth-aachen.de>
Tested-by: default avatarStefan Brüns <stefan.bruens@rwth-aachen.de>
Cc: AceLan Kao <acelan.kao@canonical.com>
parent 9678d0ef
...@@ -80,6 +80,7 @@ static void notify_handler(acpi_handle handle, u32 event, void *context) ...@@ -80,6 +80,7 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
{ {
struct platform_device *device = context; struct platform_device *device = context;
struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
unsigned int val = !(event & 1); /* Even=press, Odd=release */
const struct key_entry *ke_rel; const struct key_entry *ke_rel;
bool autorelease; bool autorelease;
...@@ -88,20 +89,20 @@ static void notify_handler(acpi_handle handle, u32 event, void *context) ...@@ -88,20 +89,20 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
pm_wakeup_hard_event(&device->dev); pm_wakeup_hard_event(&device->dev);
return; return;
} }
} else { goto out_unknown;
/* Use the fact press/release come in even/odd pairs */ }
if ((event & 1) && sparse_keymap_report_event(priv->input_dev,
event, 0, false))
return;
ke_rel = sparse_keymap_entry_from_scancode(priv->input_dev, /*
event | 1); * Even press events are autorelease if there is no corresponding odd
autorelease = !ke_rel || ke_rel->type == KE_IGNORE; * release event, or if the odd event is KE_IGNORE.
*/
ke_rel = sparse_keymap_entry_from_scancode(priv->input_dev, event | 1);
autorelease = val && (!ke_rel || ke_rel->type == KE_IGNORE);
if (sparse_keymap_report_event(priv->input_dev, event, 1, if (sparse_keymap_report_event(priv->input_dev, event, val, autorelease))
autorelease))
return; return;
}
out_unknown:
dev_dbg(&device->dev, "unknown event index 0x%x\n", event); dev_dbg(&device->dev, "unknown event index 0x%x\n", event);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment