Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging

Pull dmi updates from Jean Delvare.

* 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
firmware: dmi: Add dmi_memdev_handle
firmware: dmi: Remember the memory type

+44 -1
+40 -1
drivers/firmware/dmi_scan.c
··· 35 35 const char *bank; 36 36 u64 size; /* bytes */ 37 37 u16 handle; 38 + u8 type; /* DDR2, DDR3, DDR4 etc */ 38 39 } *dmi_memdev; 39 40 static int dmi_memdev_nr; 40 41 ··· 392 391 u64 bytes; 393 392 u16 size; 394 393 395 - if (dm->type != DMI_ENTRY_MEM_DEVICE || dm->length < 0x12) 394 + if (dm->type != DMI_ENTRY_MEM_DEVICE || dm->length < 0x13) 396 395 return; 397 396 if (nr >= dmi_memdev_nr) { 398 397 pr_warn(FW_BUG "Too many DIMM entries in SMBIOS table\n"); ··· 401 400 dmi_memdev[nr].handle = get_unaligned(&dm->handle); 402 401 dmi_memdev[nr].device = dmi_string(dm, d[0x10]); 403 402 dmi_memdev[nr].bank = dmi_string(dm, d[0x11]); 403 + dmi_memdev[nr].type = d[0x12]; 404 404 405 405 size = get_unaligned((u16 *)&d[0xC]); 406 406 if (size == 0) ··· 1130 1128 return ~0ull; 1131 1129 } 1132 1130 EXPORT_SYMBOL_GPL(dmi_memdev_size); 1131 + 1132 + /** 1133 + * dmi_memdev_type - get the memory type 1134 + * @handle: DMI structure handle 1135 + * 1136 + * Return the DMI memory type of the module in the slot associated with the 1137 + * given DMI handle, or 0x0 if no such DMI handle exists. 1138 + */ 1139 + u8 dmi_memdev_type(u16 handle) 1140 + { 1141 + int n; 1142 + 1143 + if (dmi_memdev) { 1144 + for (n = 0; n < dmi_memdev_nr; n++) { 1145 + if (handle == dmi_memdev[n].handle) 1146 + return dmi_memdev[n].type; 1147 + } 1148 + } 1149 + return 0x0; /* Not a valid value */ 1150 + } 1151 + EXPORT_SYMBOL_GPL(dmi_memdev_type); 1152 + 1153 + /** 1154 + * dmi_memdev_handle - get the DMI handle of a memory slot 1155 + * @slot: slot number 1156 + * 1157 + * Return the DMI handle associated with a given memory slot, or %0xFFFF 1158 + * if there is no such slot. 1159 + */ 1160 + u16 dmi_memdev_handle(int slot) 1161 + { 1162 + if (dmi_memdev && slot >= 0 && slot < dmi_memdev_nr) 1163 + return dmi_memdev[slot].handle; 1164 + 1165 + return 0xffff; /* Not a valid value */ 1166 + } 1167 + EXPORT_SYMBOL_GPL(dmi_memdev_handle);
+4
include/linux/dmi.h
··· 113 113 extern bool dmi_match(enum dmi_field f, const char *str); 114 114 extern void dmi_memdev_name(u16 handle, const char **bank, const char **device); 115 115 extern u64 dmi_memdev_size(u16 handle); 116 + extern u8 dmi_memdev_type(u16 handle); 117 + extern u16 dmi_memdev_handle(int slot); 116 118 117 119 #else 118 120 ··· 144 142 static inline void dmi_memdev_name(u16 handle, const char **bank, 145 143 const char **device) { } 146 144 static inline u64 dmi_memdev_size(u16 handle) { return ~0ul; } 145 + static inline u8 dmi_memdev_type(u16 handle) { return 0x0; } 146 + static inline u16 dmi_memdev_handle(int slot) { return 0xffff; } 147 147 static inline const struct dmi_system_id * 148 148 dmi_first_match(const struct dmi_system_id *list) { return NULL; } 149 149