-/* $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>
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)
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;
-/* $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
#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;