Skip to content

Commit 2dff2a1

Browse files
committed
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
2 parents 2352923 + 7c23788 commit 2dff2a1

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

drivers/firmware/dmi_scan.c

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ static struct dmi_memdev_info {
3535
const char *bank;
3636
u64 size; /* bytes */
3737
u16 handle;
38+
u8 type; /* DDR2, DDR3, DDR4 etc */
3839
} *dmi_memdev;
3940
static int dmi_memdev_nr;
4041

@@ -391,7 +392,7 @@ static void __init save_mem_devices(const struct dmi_header *dm, void *v)
391392
u64 bytes;
392393
u16 size;
393394

394-
if (dm->type != DMI_ENTRY_MEM_DEVICE || dm->length < 0x12)
395+
if (dm->type != DMI_ENTRY_MEM_DEVICE || dm->length < 0x13)
395396
return;
396397
if (nr >= dmi_memdev_nr) {
397398
pr_warn(FW_BUG "Too many DIMM entries in SMBIOS table\n");
@@ -400,6 +401,7 @@ static void __init save_mem_devices(const struct dmi_header *dm, void *v)
400401
dmi_memdev[nr].handle = get_unaligned(&dm->handle);
401402
dmi_memdev[nr].device = dmi_string(dm, d[0x10]);
402403
dmi_memdev[nr].bank = dmi_string(dm, d[0x11]);
404+
dmi_memdev[nr].type = d[0x12];
403405

404406
size = get_unaligned((u16 *)&d[0xC]);
405407
if (size == 0)
@@ -1128,3 +1130,40 @@ u64 dmi_memdev_size(u16 handle)
11281130
return ~0ull;
11291131
}
11301132
EXPORT_SYMBOL_GPL(dmi_memdev_size);
1133+
1134+
/**
1135+
* dmi_memdev_type - get the memory type
1136+
* @handle: DMI structure handle
1137+
*
1138+
* Return the DMI memory type of the module in the slot associated with the
1139+
* given DMI handle, or 0x0 if no such DMI handle exists.
1140+
*/
1141+
u8 dmi_memdev_type(u16 handle)
1142+
{
1143+
int n;
1144+
1145+
if (dmi_memdev) {
1146+
for (n = 0; n < dmi_memdev_nr; n++) {
1147+
if (handle == dmi_memdev[n].handle)
1148+
return dmi_memdev[n].type;
1149+
}
1150+
}
1151+
return 0x0; /* Not a valid value */
1152+
}
1153+
EXPORT_SYMBOL_GPL(dmi_memdev_type);
1154+
1155+
/**
1156+
* dmi_memdev_handle - get the DMI handle of a memory slot
1157+
* @slot: slot number
1158+
*
1159+
* Return the DMI handle associated with a given memory slot, or %0xFFFF
1160+
* if there is no such slot.
1161+
*/
1162+
u16 dmi_memdev_handle(int slot)
1163+
{
1164+
if (dmi_memdev && slot >= 0 && slot < dmi_memdev_nr)
1165+
return dmi_memdev[slot].handle;
1166+
1167+
return 0xffff; /* Not a valid value */
1168+
}
1169+
EXPORT_SYMBOL_GPL(dmi_memdev_handle);

include/linux/dmi.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ extern int dmi_walk(void (*decode)(const struct dmi_header *, void *),
113113
extern bool dmi_match(enum dmi_field f, const char *str);
114114
extern void dmi_memdev_name(u16 handle, const char **bank, const char **device);
115115
extern u64 dmi_memdev_size(u16 handle);
116+
extern u8 dmi_memdev_type(u16 handle);
117+
extern u16 dmi_memdev_handle(int slot);
116118

117119
#else
118120

@@ -142,6 +144,8 @@ static inline bool dmi_match(enum dmi_field f, const char *str)
142144
static inline void dmi_memdev_name(u16 handle, const char **bank,
143145
const char **device) { }
144146
static inline u64 dmi_memdev_size(u16 handle) { return ~0ul; }
147+
static inline u8 dmi_memdev_type(u16 handle) { return 0x0; }
148+
static inline u16 dmi_memdev_handle(int slot) { return 0xffff; }
145149
static inline const struct dmi_system_id *
146150
dmi_first_match(const struct dmi_system_id *list) { return NULL; }
147151

0 commit comments

Comments
 (0)