Skip to contentSkip to conversation

x86: Easy way of detecting MS Surface 3

PATCH Superseded Andy Shevchenko 3 participants 15 messages Jan 20, 2020 – Jan 21, 2020

Subsystems (7)
x86 Sound PCI ASoC +3 more subsystems

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover x86: Easy way of detecting MS Surface 3

While working on RTC regression, I noticed that we are using the same DMI check over and over in the drivers for MS Surface 3 platform. This series dedicated for making it easier in the same way how it's done for Apple machines.

Changelog v2:
- removed RTC patches for now
- added couple more clean ups to arch/x86/kernel/quirks.c
- redone DMI quirk to use driver_data instead of callback
- simplified check in soc-acpi-intel-cht-match.c to be oneliner
- added a new patch to cover rt5645 codec driver

Cc Cezary Rojewski <[email protected]>
Cc Pierre-Louis Bossart <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Jie Yang <[email protected]>
Cc Mark Brown <[email protected]>

Andy Shevchenko (9):
x86/platform: Rename x86/apple.h -> x86/machine.h x86/quirks: Add missed include to satisfy static checker x86/quirks: Introduce hpet_dev_print_force_hpet_address() helper x86/quirks: Join string literals back
x86/quirks: Convert DMI matching to use a table x86/quirks: Add a DMI quirk for Microsoft Surface 3 platform/x86: surface3_wmi: Switch DMI table match to a test of
variable
ASoC: rt5645: Switch DMI table match to a test of variable
ASoC: Intel: Switch DMI table match to a test of variable

 arch/x86/kernel/quirks.c                      | 91 +++++++++++++------
 drivers/platform/x86/surface3-wmi.c           | 16 +---
 include/linux/platform_data/x86/apple.h       | 14 +--
 include/linux/platform_data/x86/machine.h     | 20 ++++
 sound/soc/codecs/rt5645.c                     | 14 ++-
 .../intel/common/soc-acpi-intel-cht-match.c   | 33 +------
 6 files changed, 93 insertions(+), 95 deletions(-)
 create mode 100644 include/linux/platform_data/x86/machine.h
Signature · 1 line
2.24.1
#1 lore raw

PATCH v2 1/9 x86/platform: Rename x86/apple.h -> x86/machine.h

Rename linux/platform_data/x86/apple.h to linux/platform_data/x86/machine.h in order to add new quirks later on. For sake of being less intrusive, leave former file that includes a latter one.

While here, add include to linux/types.h due to bool type in use.

---
 include/linux/platform_data/x86/apple.h   | 14 +-------------
 include/linux/platform_data/x86/machine.h | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 13 deletions(-)
 create mode 100644 include/linux/platform_data/x86/machine.h
include/linux/platform_data/x86/apple.h +1 -13
index 079e816c3c21..1fd0af6ffea9 100644
@@ -1,13 +1 @@
-#ifndef PLATFORM_DATA_X86_APPLE_H
-#define PLATFORM_DATA_X86_APPLE_H
-
-#ifdef CONFIG_X86
-/**
- * x86_apple_machine - whether the machine is an x86 Apple Macintosh
- */
-extern bool x86_apple_machine;
-#else
-#define x86_apple_machine false
-#endif
-
-#endif
+#include <linux/platform_data/x86/machine.h>
include/linux/platform_data/x86/machine.h new file +15 -0
new file mode 100644
index 000000000000..b1e7a560a046
@@ -0,0 +1,15 @@
+#ifndef PLATFORM_DATA_X86_MACHINE_H
+#define PLATFORM_DATA_X86_MACHINE_H
+
+#include <linux/types.h>
+
+#ifdef CONFIG_X86
+/**
+ * x86_apple_machine - whether the machine is an x86 Apple Macintosh
+ */
+extern bool x86_apple_machine;
+#else
+#define x86_apple_machine			false
+#endif
+
+#endif	/* PLATFORM_DATA_X86_MACHINE_H */
Signature · 1 line
2.24.1
#2 lore raw

PATCH v2 2/9 x86/quirks: Add missed include to satisfy static checker

In reply to Andy Shevchenko

Static checker is not happy with

.../kernel/quirks.c:666:6: warning: symbol 'x86_apple_machine' was not declared. Should it be static?

This is due to missed inclusion. Add it to satisfy the static checker.

---
 arch/x86/kernel/quirks.c | 1 +
 1 file changed, 1 insertion(+)
arch/x86/kernel/quirks.c +1 -0
index 1daf8f2aa21f..5b96654aacc0 100644
@@ -4,6 +4,7 @@
  */
 #include <linux/dmi.h>
 #include <linux/pci.h>
+#include <linux/platform_data/x86/machine.h>
 #include <linux/irq.h>
 
 #include <asm/hpet.h>
Signature · 1 line
2.24.1
#3 lore raw

PATCH v2 3/9 x86/quirks: Introduce hpet_dev_print_force_hpet_address() helper

In reply to Andy Shevchenko

Introduce hpet_dev_print_force_hpet_address() helper to unify printing forced HPET address. No functional change intended.

---
 arch/x86/kernel/quirks.c | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)
arch/x86/kernel/quirks.c +14 -18
index 5b96654aacc0..ce8fc9bec43b 100644
@@ -68,6 +68,11 @@ static enum {
 	ATI_FORCE_HPET_RESUME,
 } force_hpet_resume_type;
 
+static void hpet_dev_print_force_hpet_address(struct device *dev)
+{
+	dev_printk(KERN_DEBUG, dev, "Force enabled HPET at 0x%lx\n", force_hpet_address);
+}
+
 static void __iomem *rcba_base;
 
 static void ich_force_hpet_resume(void)
@@ -125,8 +130,7 @@ static void ich_force_enable_hpet(struct pci_dev *dev)
 		/* HPET is enabled in HPTC. Just not reported by BIOS */
 		val = val & 0x3;
 		force_hpet_address = 0xFED00000 | (val << 12);
-		dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
-			"0x%lx\n", force_hpet_address);
+		hpet_dev_print_force_hpet_address(&dev->dev);
 		iounmap(rcba_base);
 		return;
 	}
@@ -149,8 +153,7 @@ static void ich_force_enable_hpet(struct pci_dev *dev)
 			"Failed to force enable HPET\n");
 	} else {
 		force_hpet_resume_type = ICH_FORCE_HPET_RESUME;
-		dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
-			"0x%lx\n", force_hpet_address);
+		hpet_dev_print_force_hpet_address(&dev->dev);
 	}
 }
 
@@ -223,8 +226,7 @@ static void old_ich_force_enable_hpet(struct pci_dev *dev)
 	if (val & 0x4) {
 		val &= 0x3;
 		force_hpet_address = 0xFED00000 | (val << 12);
-		dev_printk(KERN_DEBUG, &dev->dev, "HPET at 0x%lx\n",
-			force_hpet_address);
+		hpet_dev_print_force_hpet_address(&dev->dev);
 		return;
 	}
 
@@ -244,8 +246,7 @@ static void old_ich_force_enable_hpet(struct pci_dev *dev)
 		/* HPET is enabled in HPTC. Just not reported by BIOS */
 		val &= 0x3;
 		force_hpet_address = 0xFED00000 | (val << 12);
-		dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
-			"0x%lx\n", force_hpet_address);
+		hpet_dev_print_force_hpet_address(&dev->dev);
 		cached_dev = dev;
 		force_hpet_resume_type = OLD_ICH_FORCE_HPET_RESUME;
 		return;
@@ -316,8 +317,7 @@ static void vt8237_force_enable_hpet(struct pci_dev *dev)
 	 */
 	if (val & 0x80) {
 		force_hpet_address = (val & ~0x3ff);
-		dev_printk(KERN_DEBUG, &dev->dev, "HPET at 0x%lx\n",
-			force_hpet_address);
+		hpet_dev_print_force_hpet_address(&dev->dev);
 		return;
 	}
 
@@ -331,8 +331,7 @@ static void vt8237_force_enable_hpet(struct pci_dev *dev)
 	pci_read_config_dword(dev, 0x68, &val);
 	if (val & 0x80) {
 		force_hpet_address = (val & ~0x3ff);
-		dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
-			"0x%lx\n", force_hpet_address);
+		hpet_dev_print_force_hpet_address(&dev->dev);
 		cached_dev = dev;
 		force_hpet_resume_type = VT8237_FORCE_HPET_RESUME;
 		return;
@@ -412,8 +411,7 @@ static void ati_force_enable_hpet(struct pci_dev *dev)
 
 	force_hpet_address = val;
 	force_hpet_resume_type = ATI_FORCE_HPET_RESUME;
-	dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at 0x%lx\n",
-		   force_hpet_address);
+	hpet_dev_print_force_hpet_address(&dev->dev);
 	cached_dev = dev;
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS,
@@ -444,8 +442,7 @@ static void nvidia_force_enable_hpet(struct pci_dev *dev)
 	pci_read_config_dword(dev, 0x44, &val);
 	force_hpet_address = val & 0xfffffffe;
 	force_hpet_resume_type = NVIDIA_FORCE_HPET_RESUME;
-	dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at 0x%lx\n",
-		force_hpet_address);
+	hpet_dev_print_force_hpet_address(&dev->dev);
 	cached_dev = dev;
 }
 
@@ -509,8 +506,7 @@ static void e6xx_force_enable_hpet(struct pci_dev *dev)
 
 	force_hpet_address = 0xFED00000;
 	force_hpet_resume_type = NONE_FORCE_HPET_RESUME;
-	dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
-		"0x%lx\n", force_hpet_address);
+	hpet_dev_print_force_hpet_address(&dev->dev);
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E6XX_CU,
 			 e6xx_force_enable_hpet);
Signature · 1 line
2.24.1
#4 lore raw

PATCH v2 4/9 x86/quirks: Join string literals back

In reply to Andy Shevchenko

There is no need to split string literals. Moreover, it would be simpler to grep for an actual code line, when debugging, by using almost any part of the string literal in question.

No functional change intended.

---
 arch/x86/kernel/quirks.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
arch/x86/kernel/quirks.c +5 -10
index ce8fc9bec43b..6c122f35508a 100644
@@ -36,8 +36,7 @@ static void quirk_intel_irqbalance(struct pci_dev *dev)
 	pci_bus_read_config_word(dev->bus, PCI_DEVFN(8, 0), 0x4c, &word);
 
 	if (!(word & (1 << 13))) {
-		dev_info(&dev->dev, "Intel E7520/7320/7525 detected; "
-			"disabling irq balancing and affinity\n");
+		dev_info(&dev->dev, "Intel E7520/7320/7525 detected; disabling irq balancing and affinity\n");
 		noirqdebug_setup("");
 #ifdef CONFIG_PROC_FS
 		no_irq_affinity = 1;
@@ -110,16 +109,14 @@ static void ich_force_enable_hpet(struct pci_dev *dev)
 	pci_read_config_dword(dev, 0xF0, &rcba);
 	rcba &= 0xFFFFC000;
 	if (rcba == 0) {
-		dev_printk(KERN_DEBUG, &dev->dev, "RCBA disabled; "
-			"cannot force enable HPET\n");
+		dev_printk(KERN_DEBUG, &dev->dev, "RCBA disabled; cannot force enable HPET\n");
 		return;
 	}
 
 	/* use bits 31:14, 16 kB aligned */
 	rcba_base = ioremap_nocache(rcba, 0x4000);
 	if (rcba_base == NULL) {
-		dev_printk(KERN_DEBUG, &dev->dev, "ioremap failed; "
-			"cannot force enable HPET\n");
+		dev_printk(KERN_DEBUG, &dev->dev, "ioremap failed; cannot force enable HPET\n");
 		return;
 	}
 
@@ -149,8 +146,7 @@ static void ich_force_enable_hpet(struct pci_dev *dev)
 	if (err) {
 		force_hpet_address = 0;
 		iounmap(rcba_base);
-		dev_printk(KERN_DEBUG, &dev->dev,
-			"Failed to force enable HPET\n");
+		dev_printk(KERN_DEBUG, &dev->dev, "Failed to force enable HPET\n");
 	} else {
 		force_hpet_resume_type = ICH_FORCE_HPET_RESUME;
 		hpet_dev_print_force_hpet_address(&dev->dev);
@@ -182,8 +178,7 @@ static struct pci_dev *cached_dev;
 
 static void hpet_print_force_info(void)
 {
-	printk(KERN_INFO "HPET not enabled in BIOS. "
-	       "You might try hpet=force boot option\n");
+	printk(KERN_INFO "HPET not enabled in BIOS. You might try hpet=force boot option\n");
 }
 
 static void old_ich_force_hpet_resume(void)
Signature · 1 line
2.24.1
#5 lore raw

PATCH v2 5/9 x86/quirks: Convert DMI matching to use a table

In reply to Andy Shevchenko

In order to extend the DMI based quirks, convert them to a table.

---
 arch/x86/kernel/quirks.c | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)
arch/x86/kernel/quirks.c +31 -2
index 6c122f35508a..78846a8dc88b 100644
@@ -658,8 +658,37 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras
 bool x86_apple_machine;
 EXPORT_SYMBOL(x86_apple_machine);
 
+static const struct dmi_system_id x86_machine_table[] __initconst = {
+	{
+		.ident = "x86 Apple Macintosh",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+		},
+		.driver_data = &x86_apple_machine,
+	},
+	{
+		.ident = "x86 Apple Macintosh",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."),
+		},
+		.driver_data = &x86_apple_machine,
+	},
+	{}
+};
+
+static void __init early_platfrom_detect_quirk(void)
+{
+	const struct dmi_system_id *id;
+
+	id = dmi_first_match(x86_machine_table);
+	if (!id)
+		return;
+
+	printk(KERN_DEBUG "Detected %s platform\n", id->ident);
+	*((bool *)id->driver_data) = true;
+}
+
 void __init early_platform_quirks(void)
 {
-	x86_apple_machine = dmi_match(DMI_SYS_VENDOR, "Apple Inc.") ||
-			    dmi_match(DMI_SYS_VENDOR, "Apple Computer, Inc.");
+	early_platfrom_detect_quirk();
 }
Signature · 1 line
2.24.1
#6 lore raw

Re: [PATCH v2 5/9] x86/quirks: Convert DMI matching to use a table

Quoted 24 lines · In article <[email protected]> you wrote:

In order to extend the DMI based quirks, convert them to a table.

---
 arch/x86/kernel/quirks.c | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)
arch/x86/kernel/quirks.c +9 -0
index 6c122f35508a..78846a8dc88b 100644
@@ -658,8 +658,37 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras
 bool x86_apple_machine;
 EXPORT_SYMBOL(x86_apple_machine);
 
+static const struct dmi_system_id x86_machine_table[] __initconst = {
+	{
+		.ident = "x86 Apple Macintosh",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
+		},
+		.driver_data = &x86_apple_machine,
+	},
+	{

arch/x86/kernel/quirks.c DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras · line 679

Quoted 10 lines
arch/x86/kernel/quirks.c +10 -0
+		.ident = "x86 Apple Macintosh",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Apple Computer, Inc."),
+		},
+		.driver_data = &x86_apple_machine,
+	},
+	{}
+};
+
+static void __init early_platfrom_detect_quirk(void)

"platform"

Quoted 6 lines
arch/x86/kernel/quirks.c +6 -0
+{
+	const struct dmi_system_id *id;
+
+	id = dmi_first_match(x86_machine_table);
+	if (!id)
+		return;

arch/x86/kernel/quirks.c DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras · line 693

Quoted 10 lines
arch/x86/kernel/quirks.c +6 -2
+
+	printk(KERN_DEBUG "Detected %s platform\n", id->ident);
+	*((bool *)id->driver_data) = true;
+}
+
 void __init early_platform_quirks(void)
 {
-	x86_apple_machine = dmi_match(DMI_SYS_VENDOR, "Apple Inc.") ||
-			    dmi_match(DMI_SYS_VENDOR, "Apple Computer, Inc.");
+	early_platfrom_detect_quirk();

As above.

arch/x86/kernel/quirks.c DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras · line 694

Quoted 1 line
arch/x86/kernel/quirks.c +0 -0
 }

J.

Signature · 3 lines
If I follow you home, will you keep me?
This .sig brought to you by the letter C and the number  9
Product of the Republic of HuggieTag
#7 lore raw

Re: [PATCH v2 5/9] x86/quirks: Convert DMI matching to use a table

Quoted 10 lines · Jonathan McDowell
Quoted 3 lines · In article <[email protected]> you wrote:

In order to extend the DMI based quirks, convert them to a table.

+static void __init early_platfrom_detect_quirk(void)

"platform"

arch/x86/kernel/quirks.c DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras · line 693

Quoted 1 line
arch/x86/kernel/quirks.c +1 -0
+	early_platfrom_detect_quirk();

As above.

Thanks! Will fix in v3.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#8 lore raw

PATCH v2 6/9 x86/quirks: Add a DMI quirk for Microsoft Surface 3

In reply to Andy Shevchenko

Add a DMI quirk for Microsoft Surface 3 which will be utilized by few drivers.

Cc Cezary Rojewski <[email protected]>
Cc Pierre-Louis Bossart <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Jie Yang <[email protected]>
Cc Mark Brown <[email protected]>
---
 arch/x86/kernel/quirks.c                  | 10 ++++++++++
 include/linux/platform_data/x86/machine.h |  5 +++++
 2 files changed, 15 insertions(+)
arch/x86/kernel/quirks.c +10 -0
index 78846a8dc88b..501fbcd16282 100644
@@ -658,6 +658,9 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2083, quirk_intel_purley_xeon_ras
 bool x86_apple_machine;
 EXPORT_SYMBOL(x86_apple_machine);
 
+bool x86_microsoft_surface_3_machine;
+EXPORT_SYMBOL(x86_microsoft_surface_3_machine);
+
 static const struct dmi_system_id x86_machine_table[] __initconst = {
 	{
 		.ident = "x86 Apple Macintosh",
@@ -673,6 +676,13 @@ static const struct dmi_system_id x86_machine_table[] __initconst = {
 		},
 		.driver_data = &x86_apple_machine,
 	},
+	{
+		.ident = "Microsoft Surface 3",
+		.matches = {
+			DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
+		},
+		.driver_data = &x86_microsoft_surface_3_machine,
+	},
 	{}
 };
 
include/linux/platform_data/x86/machine.h +5 -0
index b1e7a560a046..9bdf5a06b490 100644
@@ -8,8 +8,13 @@
  * x86_apple_machine - whether the machine is an x86 Apple Macintosh
  */
 extern bool x86_apple_machine;
+/**
+ * x86_microsoft_surface_3_machine - whether the machine is Microsoft Surface 3
+ */
+extern bool x86_microsoft_surface_3_machine;
 #else
 #define x86_apple_machine			false
+#define x86_microsoft_surface_3_machine		false
 #endif
 
 #endif	/* PLATFORM_DATA_X86_MACHINE_H */
Signature · 1 line
2.24.1
#9 lore raw

PATCH v2 7/9 platform/x86: surface3_wmi: Switch DMI table match to a test of variable

In reply to Andy Shevchenko

Since we have a common x86 quirk that provides an exported variable, use it instead of local DMI table match.

---
 drivers/platform/x86/surface3-wmi.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
drivers/platform/x86/surface3-wmi.c +2 -14
index 130b6f52a600..5eeedc4ddb8a 100644
@@ -11,9 +11,9 @@
 #include <linux/slab.h>
 
 #include <linux/acpi.h>
-#include <linux/dmi.h>
 #include <linux/input.h>
 #include <linux/mutex.h>
+#include <linux/platform_data/x86/machine.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 
@@ -29,18 +29,6 @@ MODULE_LICENSE("GPL");
 
 MODULE_ALIAS("wmi:" SURFACE3_LID_GUID);
 
-static const struct dmi_system_id surface3_dmi_table[] = {
-#if defined(CONFIG_X86)
-	{
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
-		},
-	},
-#endif
-	{ }
-};
-
 struct surface3_wmi {
 	struct acpi_device *touchscreen_adev;
 	struct acpi_device *pnp0c0d_adev;
@@ -201,7 +189,7 @@ static int __init s3_wmi_probe(struct platform_device *pdev)
 {
 	int error;
 
-	if (!dmi_check_system(surface3_dmi_table))
+	if (!x86_microsoft_surface_3_machine)
 		return -ENODEV;
 
 	memset(&s3_wmi, 0, sizeof(s3_wmi));
Signature · 1 line
2.24.1
#10 lore raw

PATCH v2 8/9 ASoC: rt5645: Switch DMI table match to a test of variable

In reply to Andy Shevchenko

Since we have a common x86 quirk that provides an exported variable, use it instead of local DMI table match.

Note, arch/x86/kernel/quirks.c::early_platform_detect_quirk() prints the detected platform.

Cc Cezary Rojewski <[email protected]>
Cc Pierre-Louis Bossart <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Jie Yang <[email protected]>
Cc Mark Brown <[email protected]>
---
 sound/soc/codecs/rt5645.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
sound/soc/codecs/rt5645.c +6 -8
index 92d67010aeed..3ccecb81bc37 100644
@@ -12,6 +12,7 @@
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/i2c.h>
+#include <linux/platform_data/x86/machine.h>
 #include <linux/platform_device.h>
 #include <linux/spi/spi.h>
 #include <linux/gpio.h>
@@ -3674,13 +3675,6 @@ static const struct dmi_system_id dmi_platform_data[] = {
 		},
 		.driver_data = (void *)&intel_braswell_platform_data,
 	},
-	{
-		.ident = "Microsoft Surface 3",
-		.matches = {
-			DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
-		},
-		.driver_data = (void *)&intel_braswell_platform_data,
-	},
 	{
 		/*
 		 * Match for the GPDwin which unfortunately uses somewhat
@@ -3789,7 +3783,7 @@ static int rt5645_parse_dt(struct rt5645_priv *rt5645, struct device *dev)
 static int rt5645_i2c_probe(struct i2c_client *i2c,
 		    const struct i2c_device_id *id)
 {
-	struct rt5645_platform_data *pdata = dev_get_platdata(&i2c->dev);
+	const struct rt5645_platform_data *pdata = dev_get_platdata(&i2c->dev);
 	const struct dmi_system_id *dmi_data;
 	struct rt5645_priv *rt5645;
 	int ret, i;
@@ -3804,6 +3798,10 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
 	rt5645->i2c = i2c;
 	i2c_set_clientdata(i2c, rt5645);
 
+	/* Put it first to allow DMI to override, if needed */
+	if (x86_microsoft_surface_3_machine)
+		pdata = &intel_braswell_platform_data;
+
 	dmi_data = dmi_first_match(dmi_platform_data);
 	if (dmi_data) {
 		dev_info(&i2c->dev, "Detected %s platform\n", dmi_data->ident);
Signature · 1 line
2.24.1
maintainer Acked-by on v2 8/9
#11 lore raw

Re: [PATCH v2 8/9] ASoC: rt5645: Switch DMI table match to a test of variable

Quoted 2 lines · Andy Shevchenko

Since we have a common x86 quirk that provides an exported variable, use it instead of local DMI table match.

#12 lore raw

PATCH v2 9/9 ASoC: Intel: Switch DMI table match to a test of variable

In reply to Andy Shevchenko

Since we have a common x86 quirk that provides an exported variable, use it instead of local DMI table match.

Cc Cezary Rojewski <[email protected]>
Cc Pierre-Louis Bossart <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Jie Yang <[email protected]>
Cc Mark Brown <[email protected]>
---
 .../intel/common/soc-acpi-intel-cht-match.c   | 33 ++-----------------
 1 file changed, 3 insertions(+), 30 deletions(-)
sound/soc/intel/common/soc-acpi-intel-cht-match.c +3 -30
index d0fb43c2b9f6..c35766125d5e 100644
@@ -5,31 +5,11 @@
  * Copyright (c) 2017, Intel Corporation.
  */
 
-#include <linux/dmi.h>
+#include <linux/platform_data/x86/machine.h>
+
 #include <sound/soc-acpi.h>
 #include <sound/soc-acpi-intel-match.h>
 
-static unsigned long cht_machine_id;
-
-#define CHT_SURFACE_MACH 1
-
-static int cht_surface_quirk_cb(const struct dmi_system_id *id)
-{
-	cht_machine_id = CHT_SURFACE_MACH;
-	return 1;
-}
-
-static const struct dmi_system_id cht_table[] = {
-	{
-		.callback = cht_surface_quirk_cb,
-		.matches = {
-			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
-			DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
-		},
-	},
-	{ }
-};
-
 static struct snd_soc_acpi_mach cht_surface_mach = {
 	.id = "10EC5640",
 	.drv_name = "cht-bsw-rt5645",
@@ -41,14 +21,7 @@ static struct snd_soc_acpi_mach cht_surface_mach = {
 
 static struct snd_soc_acpi_mach *cht_quirk(void *arg)
 {
-	struct snd_soc_acpi_mach *mach = arg;
-
-	dmi_check_system(cht_table);
-
-	if (cht_machine_id == CHT_SURFACE_MACH)
-		return &cht_surface_mach;
-	else
-		return mach;
+	return x86_microsoft_surface_3_machine ? &cht_surface_mach : arg;
 }
 
 /* Cherryview-based platforms: CherryTrail and Braswell */
Signature · 1 line
2.24.1
maintainer Acked-by on v2 9/9
#13 lore raw

Re: [PATCH v2 9/9] ASoC: Intel: Switch DMI table match to a test of variable

Quoted 2 lines · Andy Shevchenko

Since we have a common x86 quirk that provides an exported variable, use it instead of local DMI table match.

sound/soc/intel/common/soc-acpi-intel-cht-match.c static struct snd_soc_acpi_mach cht_surface_mach = { · line 24

Quoted 5 lines
sound/soc/intel/common/soc-acpi-intel-cht-match.c +1 -4
-	if (cht_machine_id == CHT_SURFACE_MACH)
-		return &cht_surface_mach;
-	else
-		return mach;
+	return x86_microsoft_surface_3_machine ? &cht_surface_mach : arg;

but if you're respinning this please replace this with a normal conditional statement to improve legibility.

#14 lore raw

Re: [PATCH v2 9/9] ASoC: Intel: Switch DMI table match to a test of variable

Quoted 6 lines · Mark Brown
Quoted 2 lines · Andy Shevchenko

Since we have a common x86 quirk that provides an exported variable, use it instead of local DMI table match.

Quoted 8 lines

sound/soc/intel/common/soc-acpi-intel-cht-match.c static struct snd_soc_acpi_mach cht_surface_mach = { · line 24

Quoted 5 lines
sound/soc/intel/common/soc-acpi-intel-cht-match.c +1 -4
-	if (cht_machine_id == CHT_SURFACE_MACH)
-		return &cht_surface_mach;
-	else
-		return mach;
+	return x86_microsoft_surface_3_machine ? &cht_surface_mach : arg;

but if you're respinning this please replace this with a normal conditional statement to improve legibility.

Okay, will do. Thanks for review!

Signature · 2 lines
With Best Regards,
Andy Shevchenko