606fd75
From 0e9df6a74f9573409e5a2fbe29c1389188280bfc Mon Sep 17 00:00:00 2001
606fd75
From: Hans de Goede <hdegoede@redhat.com>
606fd75
Date: Thu, 5 Oct 2017 16:02:33 +0200
606fd75
Subject: [PATCH] platform/x86: peaq-wmi: Add DMI check before binding to the
606fd75
 WMI interface
606fd75
606fd75
It seems that the WMI GUID used by the PEAQ 2-in-1 WMI hotkeys is not
606fd75
as unique as a GUID should be and is used on some other devices too.
606fd75
606fd75
This is causing spurious key-press reports on these other devices.
606fd75
606fd75
This commits adds a DMI check to the PEAQ 2-in-1 WMI hotkeys driver to
606fd75
ensure that it is actually running on a PEAQ 2-in-1, fixing the
606fd75
spurious key-presses on these other devices.
606fd75
606fd75
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1497861
606fd75
BugLink: https://bugzilla.suse.com/attachment.cgi?id=743182
606fd75
Cc: stable@vger.kernel.org
606fd75
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
606fd75
---
606fd75
 drivers/platform/x86/peaq-wmi.c | 18 ++++++++++++++++++
606fd75
 1 file changed, 18 insertions(+)
606fd75
606fd75
diff --git a/drivers/platform/x86/peaq-wmi.c b/drivers/platform/x86/peaq-wmi.c
606fd75
index bc98ef95514a..67fa3fa32011 100644
606fd75
--- a/drivers/platform/x86/peaq-wmi.c
606fd75
+++ b/drivers/platform/x86/peaq-wmi.c
606fd75
@@ -8,6 +8,7 @@
606fd75
  */
606fd75
 
606fd75
 #include <linux/acpi.h>
606fd75
+#include <linux/dmi.h>
606fd75
 #include <linux/input-polldev.h>
606fd75
 #include <linux/kernel.h>
606fd75
 #include <linux/module.h>
606fd75
@@ -64,8 +65,22 @@ static void peaq_wmi_poll(struct input_polled_dev *dev)
606fd75
 	}
606fd75
 }
606fd75
 
606fd75
+/* Some other devices (Shuttle XS35) use the same WMI GUID for other purposes */
606fd75
+static const struct dmi_system_id peaq_dmi_table[] = {
606fd75
+	{
606fd75
+		.matches = {
606fd75
+			DMI_MATCH(DMI_SYS_VENDOR, "PEAQ"),
606fd75
+			DMI_MATCH(DMI_PRODUCT_NAME, "PEAQ PMM C1010 MD99187"),
606fd75
+		},
606fd75
+	},
606fd75
+};
606fd75
+
606fd75
 static int __init peaq_wmi_init(void)
606fd75
 {
606fd75
+	/* WMI GUID is not unique, also check for a DMI match */
606fd75
+	if (!dmi_check_system(peaq_dmi_table))
606fd75
+		return -ENODEV;
606fd75
+
606fd75
 	if (!wmi_has_guid(PEAQ_DOLBY_BUTTON_GUID))
606fd75
 		return -ENODEV;
606fd75
 
606fd75
@@ -86,6 +101,9 @@ static int __init peaq_wmi_init(void)
606fd75
 
606fd75
 static void __exit peaq_wmi_exit(void)
606fd75
 {
606fd75
+	if (!dmi_check_system(peaq_dmi_table))
606fd75
+		return;
606fd75
+
606fd75
 	if (!wmi_has_guid(PEAQ_DOLBY_BUTTON_GUID))
606fd75
 		return;
606fd75
 
606fd75
-- 
606fd75
2.14.2
606fd75