aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/kernel/dmi_scan.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/i386/kernel/dmi_scan.c')
-rw-r--r--arch/i386/kernel/dmi_scan.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/arch/i386/kernel/dmi_scan.c b/arch/i386/kernel/dmi_scan.c
index 6a93d75db431..ebc8dc116c43 100644
--- a/arch/i386/kernel/dmi_scan.c
+++ b/arch/i386/kernel/dmi_scan.c
@@ -5,6 +5,7 @@
#include <linux/dmi.h>
#include <linux/bootmem.h>
#include <linux/slab.h>
+#include <asm/dmi.h>
static char * __init dmi_string(struct dmi_header *dm, u8 s)
{
@@ -106,7 +107,7 @@ static void __init dmi_save_devices(struct dmi_header *dm)
struct dmi_device *dev;
for (i = 0; i < count; i++) {
- char *d = ((char *) dm) + (i * 2);
+ char *d = (char *)(dm + 1) + (i * 2);
/* Skip disabled device */
if ((*d & 0x80) == 0)
@@ -299,3 +300,33 @@ struct dmi_device * dmi_find_device(int type, const char *name,
return NULL;
}
EXPORT_SYMBOL(dmi_find_device);
+
+/**
+ * dmi_get_year - Return year of a DMI date
+ * @field: data index (like dmi_get_system_info)
+ *
+ * Returns -1 when the field doesn't exist. 0 when it is broken.
+ */
+int dmi_get_year(int field)
+{
+ int year;
+ char *s = dmi_get_system_info(field);
+
+ if (!s)
+ return -1;
+ if (*s == '\0')
+ return 0;
+ s = strrchr(s, '/');
+ if (!s)
+ return 0;
+
+ s += 1;
+ year = simple_strtoul(s, NULL, 0);
+ if (year && year < 100) { /* 2-digit year */
+ year += 1900;
+ if (year < 1996) /* no dates < spec 1.0 */
+ year += 100;
+ }
+
+ return year;
+}