[PATCH] platform/x86: dell-wmi-aio: Use named defines for event types

Armin Wolf posted 1 patch 1 day, 18 hours ago
drivers/platform/x86/dell/dell-wmi-aio.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
[PATCH] platform/x86: dell-wmi-aio: Use named defines for event types
Posted by Armin Wolf 1 day, 18 hours ago
There exist two types of events recognized by this driver:
single hotkey events (0x0000) and sequences of hotkey events (0x000F).
Until now both literals are used without a named define, making it
harder to understand their meaning.

Fix this by using named defines for both event types.

Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/platform/x86/dell/dell-wmi-aio.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/x86/dell/dell-wmi-aio.c b/drivers/platform/x86/dell/dell-wmi-aio.c
index 8849ad93480b..42c0032991d2 100644
--- a/drivers/platform/x86/dell/dell-wmi-aio.c
+++ b/drivers/platform/x86/dell/dell-wmi-aio.c
@@ -32,10 +32,13 @@ struct dell_wmi_aio_data {
 	struct mutex input_lock;
 };
 
+/* A hot key was pressed or an event occurred */
+#define DELL_AIO_EVENT_TYPE_SINGLE	0x0000
+/* A sequence of hot keys was pressed */
+#define DELL_AIO_EVENT_TYPE_SEQUENCE	0x000F
+
 struct dell_wmi_event {
 	__le16	length;
-	/* 0x000: A hot key pressed or an event occurred
-	 * 0x00F: A sequence of hot keys are pressed */
 	__le16	type;
 	__le16	event[];
 } __packed;
@@ -68,10 +71,14 @@ static bool dell_wmi_aio_event_check(const struct wmi_buffer *buffer)
 	event = buffer->data;
 	length = le16_to_cpu(event->length);
 	type = le16_to_cpu(event->type);
-	if ((type == 0 || type == 0xf) && length >= 2)
-		return true;
 
-	return false;
+	if (type != DELL_AIO_EVENT_TYPE_SINGLE && type != DELL_AIO_EVENT_TYPE_SEQUENCE)
+		return false;
+
+	if (length < 2)
+		return false;
+
+	return true;
 }
 
 static void dell_wmi_aio_notify(struct wmi_device *wdev, const struct wmi_buffer *data)
-- 
2.55.0