drm/linux: Add dmi_match()
authorFrançois Tigeot <ftigeot@wolfpond.org>
Fri, 5 Jul 2019 16:05:48 +0000 (18:05 +0200)
committerFrançois Tigeot <ftigeot@wolfpond.org>
Fri, 5 Jul 2019 16:05:48 +0000 (18:05 +0200)
sys/conf/files
sys/dev/drm/drm/Makefile
sys/dev/drm/include/linux/dmi.h
sys/dev/drm/linux_dmi.c [copied from sys/dev/drm/include/linux/dmi.h with 59% similarity]

index bb2a62f..720865c 100644 (file)
@@ -2281,6 +2281,7 @@ dev/drm/linux_async.c                     optional drm compile-with "${NORMAL_C} -include $S/dev/d
 dev/drm/linux_compat.c                 optional drm compile-with "${NORMAL_C} -include $S/dev/drm/kconfig.h ${WERROR}"
 dev/drm/linux_dma.c                    optional drm compile-with "${NORMAL_C} -include $S/dev/drm/kconfig.h ${WERROR}"
 dev/drm/linux_dma-buf.c                        optional drm compile-with "${NORMAL_C} -include $S/dev/drm/kconfig.h ${WERROR}"
+dev/drm/linux_dmi.c                    optional drm compile-with "${NORMAL_C} -include $S/dev/drm/kconfig.h ${WERROR}"
 dev/drm/linux_fence.c                  optional drm compile-with "${NORMAL_C} -include $S/dev/drm/kconfig.h ${WERROR}"
 dev/drm/linux_hdmi.c                   optional drm compile-with "${NORMAL_C} -include $S/dev/drm/kconfig.h ${WERROR}"
 dev/drm/linux_hrtimer.c                        optional drm compile-with "${NORMAL_C} -include $S/dev/drm/kconfig.h ${WERROR}"
index f215439..e73693e 100644 (file)
@@ -50,6 +50,7 @@ SRCS  = \
        linux_compat.c \
        linux_dma.c \
        linux_dma-buf.c \
+       linux_dmi.c \
        linux_fence.c \
        linux_hdmi.c \
        linux_i2c.c \
index 9f914ec..74565e7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2017 François Tigeot
+ * Copyright (c) 2015-2019 François Tigeot <ftigeot@wolfpond.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -54,4 +54,6 @@ enum dmi_field {
         DMI_STRING_MAX,
 };
 
+extern bool dmi_match(enum dmi_field f, const char *str);
+
 #endif /* _LINUX_DMI_H_ */
similarity index 59%
copy from sys/dev/drm/include/linux/dmi.h
copy to sys/dev/drm/linux_dmi.c
index 9f914ec..4f3b4e9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2017 François Tigeot
+ * Copyright (c) 2019 François Tigeot <ftigeot@wolfpond.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef _LINUX_DMI_H_
-#define _LINUX_DMI_H_
+#include <linux/types.h>
+#include <linux/string.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/ctype.h>
+#include <linux/dmi.h>
+#include <asm/unaligned.h>
 
-#include <linux/list.h>
-#include <linux/kobject.h>
-#include <linux/mod_devicetable.h>
+bool
+dmi_match(enum dmi_field f, const char *str)
+{
+       const char *s = NULL;
 
-enum dmi_field {
-        DMI_NONE,
-        DMI_BIOS_VENDOR,
-        DMI_BIOS_VERSION,
-        DMI_BIOS_DATE,
-        DMI_SYS_VENDOR,
-        DMI_PRODUCT_NAME,
-        DMI_PRODUCT_VERSION,
-        DMI_PRODUCT_SERIAL,
-        DMI_PRODUCT_UUID,
-        DMI_BOARD_VENDOR,
-        DMI_BOARD_NAME,
-        DMI_BOARD_VERSION,
-        DMI_BOARD_SERIAL,
-        DMI_BOARD_ASSET_TAG,
-        DMI_CHASSIS_VENDOR,
-        DMI_CHASSIS_TYPE,
-        DMI_CHASSIS_VERSION,
-        DMI_CHASSIS_SERIAL,
-        DMI_CHASSIS_ASSET_TAG,
-        DMI_STRING_MAX,
-};
+       switch (f) {
+       case DMI_NONE:
+               break;
+       case DMI_SYS_VENDOR:
+               s = kgetenv("smbios.system.maker");
+               if (s != NULL && !strcmp(s, str))
+                       return true;
+               break;
+       case DMI_BOARD_VENDOR:
+               s = kgetenv("smbios.planar.maker");
+               if (s != NULL && !strcmp(s, str))
+                       return true;
+               break;
+       case DMI_PRODUCT_NAME:
+               s = kgetenv("smbios.system.product");
+               if (s != NULL && !strcmp(s, str))
+                       return true;
+               break;
+       case DMI_BOARD_NAME:
+               s = kgetenv("smbios.planar.product");
+               if (s != NULL && !strcmp(s, str))
+                       return true;
+               break;
+       default:
+               return false;
+       }
 
-#endif /* _LINUX_DMI_H_ */
+       return false;
+}