git: 99902b1c5221 - main - linuxkpi/dmi: don't match exactly on DMI_MATCH
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 03 Jun 2022 14:22:24 UTC
The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=99902b1c52219bae4b9f3684e3ebd83152a1add4 commit 99902b1c52219bae4b9f3684e3ebd83152a1add4 Author: Corvin Köhne <CorvinK@beckhoff.com> AuthorDate: 2022-06-03 14:20:45 +0000 Commit: Emmanuel Vadot <manu@FreeBSD.org> CommitDate: 2022-06-03 14:20:45 +0000 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 --- sys/compat/linuxkpi/common/include/linux/mod_devicetable.h | 5 +++-- 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);