Skip to contentSkip to conversation

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

PATCH In review Armin Wolf 2 participants 2 messages Sep 22 – Oct 5 x86 platform drivers

lore
Share & tools
lore

Armin Wolf

author
#0 lore raw

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

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.

---
 drivers/platform/x86/dell/dell-wmi-aio.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/platform/x86/dell/dell-wmi-aio.c +12 -5
index 8849ad93480b..42c0032991d2 100644
@@ -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)
Signature · 1 line
2.55.0
maintainer
#1 lore raw
Quoted 8 lines · Armin Wolf

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.

[...]

Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.

FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.

The list of commits applied:
[1/1] platform/x86: dell-wmi-aio: Use named defines for event types

      commit: 6b46240b96b2ebb20af5da9f27a3ffdfbe94a90d

--
i.