summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2018-01-31 03:26:01 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2018-01-31 03:26:01 +0000
commitd429b96fec4dc128a7d2c9ef11e1254659325596 (patch)
tree3c00e17b403709fedfb1d0e83cfe4debc63535da /sys
parente1e027006883e757b079975f510db26a0b71b375 (diff)
add dmi_match() and change dmi_found() to use it
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/drm/drm_linux.c54
-rw-r--r--sys/dev/pci/drm/drm_linux.h3
2 files changed, 36 insertions, 21 deletions
diff --git a/sys/dev/pci/drm/drm_linux.c b/sys/dev/pci/drm/drm_linux.c
index 5a26c246833..918e281e4cf 100644
--- a/sys/dev/pci/drm/drm_linux.c
+++ b/sys/dev/pci/drm/drm_linux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_linux.c,v 1.19 2018/01/30 08:27:17 jsg Exp $ */
+/* $OpenBSD: drm_linux.c,v 1.20 2018/01/31 03:26:00 jsg Exp $ */
/*
* Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org>
* Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org>
@@ -143,7 +143,37 @@ timeval_to_us(const struct timeval *tv)
return ((int64_t)tv->tv_sec * 1000000) + tv->tv_usec;
}
-extern char *hw_vendor, *hw_prod;
+extern char *hw_vendor, *hw_prod, *hw_ver;
+
+bool
+dmi_match(int slot, const char *str)
+{
+ switch (slot) {
+ case DMI_SYS_VENDOR:
+ case DMI_BOARD_VENDOR:
+ if (hw_vendor != NULL &&
+ !strcmp(hw_vendor, str))
+ return true;
+ break;
+ case DMI_PRODUCT_NAME:
+ case DMI_BOARD_NAME:
+ if (hw_prod != NULL &&
+ !strcmp(hw_prod, str))
+ return true;
+ break;
+ case DMI_PRODUCT_VERSION:
+ case DMI_BOARD_VERSION:
+ if (hw_ver != NULL &&
+ !strcmp(hw_ver, str))
+ return true;
+ break;
+ case DMI_NONE:
+ default:
+ return false;
+ }
+
+ return false;
+}
static bool
dmi_found(const struct dmi_system_id *dsi)
@@ -152,26 +182,10 @@ dmi_found(const struct dmi_system_id *dsi)
for (i = 0; i < nitems(dsi->matches); i++) {
slot = dsi->matches[i].slot;
- switch (slot) {
- case DMI_NONE:
+ if (slot == DMI_NONE)
break;
- case DMI_SYS_VENDOR:
- case DMI_BOARD_VENDOR:
- if (hw_vendor != NULL &&
- !strcmp(hw_vendor, dsi->matches[i].substr))
- break;
- else
- return false;
- case DMI_PRODUCT_NAME:
- case DMI_BOARD_NAME:
- if (hw_prod != NULL &&
- !strcmp(hw_prod, dsi->matches[i].substr))
- break;
- else
- return false;
- default:
+ if (!dmi_match(slot, dsi->matches[i].substr))
return false;
- }
}
return true;
diff --git a/sys/dev/pci/drm/drm_linux.h b/sys/dev/pci/drm/drm_linux.h
index 87b11a0abbd..1c7fd9fb16e 100644
--- a/sys/dev/pci/drm/drm_linux.h
+++ b/sys/dev/pci/drm/drm_linux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_linux.h,v 1.80 2018/01/30 09:57:58 jsg Exp $ */
+/* $OpenBSD: drm_linux.h,v 1.81 2018/01/31 03:26:00 jsg Exp $ */
/*
* Copyright (c) 2013, 2014, 2015 Mark Kettenis
* Copyright (c) 2017 Martin Pieuchot
@@ -1425,6 +1425,7 @@ struct dmi_system_id {
#define DMI_MATCH(a, b) {(a), (b)}
#define DMI_EXACT_MATCH(a, b) {(a), (b)}
int dmi_check_system(const struct dmi_system_id *);
+bool dmi_match(int, const char *);
struct resource {
u_long start;