diff options
author | Corvin Köhne <CorvinK@beckhoff.com> | 2022-06-03 14:20:45 +0000 |
---|---|---|
committer | Emmanuel Vadot <manu@FreeBSD.org> | 2022-06-03 14:20:45 +0000 |
commit | 99902b1c52219bae4b9f3684e3ebd83152a1add4 (patch) | |
tree | 25cec79d3b890ee3f850f43ad19aff9c4971a509 | |
parent | 9d28e15e7bbee7a809eb4ccab558d114d4343312 (diff) | |
download | src-99902b1c52219bae4b9f3684e3ebd83152a1add4.tar.gz src-99902b1c52219bae4b9f3684e3ebd83152a1add4.zip |
linuxkpi/dmi: don't match exactly on DMI_MATCH
Linux has two defines to check dmi data. DMI_MATCH checks if the dmi
string includes substr. DMI_EXACT_MATCH checks if the dmi string exactly
matches substr. Compat layer should have the same behaviour.
The new definition of dmi_strmatch shouldn't break any driver. A driver
would break if it uses the highest bit of the slot field. Nevertheless,
linux uses the same definition and FreeBSD uses dmi_field values as slot
which are lower than 128.
Sponsored by: Beckhoff Automation GmbH & Co. KG
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D35395
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/mod_devicetable.h | 5 | ||||
-rw-r--r-- | sys/compat/linuxkpi/common/src/linux_dmi.c | 10 |
2 files changed, 10 insertions, 5 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/mod_devicetable.h b/sys/compat/linuxkpi/common/include/linux/mod_devicetable.h index 5609c6f775e9..441faab6df81 100644 --- a/sys/compat/linuxkpi/common/include/linux/mod_devicetable.h +++ b/sys/compat/linuxkpi/common/include/linux/mod_devicetable.h @@ -55,7 +55,8 @@ enum dmi_field { }; struct dmi_strmatch { - unsigned char slot; + unsigned char slot : 7; + unsigned char exact_match : 1; char substr[79]; }; @@ -67,6 +68,6 @@ struct dmi_system_id { }; #define DMI_MATCH(a, b) { .slot = a, .substr = b } -#define DMI_EXACT_MATCH(a, b) { .slot = a, .substr = b, } +#define DMI_EXACT_MATCH(a, b) { .slot = a, .substr = b, .exact_match = 1 } #endif /* __LINUXKPI_LINUX_MOD_DEVICETABLE_H__ */ diff --git a/sys/compat/linuxkpi/common/src/linux_dmi.c b/sys/compat/linuxkpi/common/src/linux_dmi.c index c0bb9a9f50d6..f5350751a496 100644 --- a/sys/compat/linuxkpi/common/src/linux_dmi.c +++ b/sys/compat/linuxkpi/common/src/linux_dmi.c @@ -82,9 +82,13 @@ linux_dmi_matches(const struct dmi_system_id *dsi) for (i = 0; i < nitems(dsi->matches); i++) { if (dsi->matches[i].slot == DMI_NONE) break; - if (dmi_match(dsi->matches[i].slot, - dsi->matches[i].substr) == false) - return (false); + if (dsi->matches[i].exact_match) { + return (dmi_match(dsi->matches[i].slot, + dsi->matches[i].substr)); + } else { + return (strstr(dmi_data[dsi->matches[i].slot], + dsi->matches[i].substr) != NULL); + } } return (true); |