2020-01-20 16:09:33

by Andy Shevchenko

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

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

Signed-off-by: Andy Shevchenko <[email protected]>
---
arch/x86/kernel/quirks.c | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index 6c122f35508a..78846a8dc88b 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -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();
}
--
2.24.1


2020-01-21 11:52:38

by Jonathan McDowell

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

In article <[email protected]> you wrote:
> In order to extend the DMI based quirks, convert them to a table.

> Signed-off-by: Andy Shevchenko <[email protected]>
> ---
> arch/x86/kernel/quirks.c | 33 +++++++++++++++++++++++++++++++--
> 1 file changed, 31 insertions(+), 2 deletions(-)

> diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
> index 6c122f35508a..78846a8dc88b 100644
> --- a/arch/x86/kernel/quirks.c
> +++ b/arch/x86/kernel/quirks.c
> @@ -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)

"platform"

> +{
> + 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();

As above.

> }

J.

--
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

2020-01-21 15:23:30

by Andy Shevchenko

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

On Tue, Jan 21, 2020 at 11:51:25AM +0000, Jonathan McDowell wrote:
> 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"

> > + early_platfrom_detect_quirk();
>
> As above.

Thanks! Will fix in v3.

--
With Best Regards,
Andy Shevchenko