Skip to content

Commit 7c23788

Browse files
committed
firmware: dmi: Add dmi_memdev_handle
Add a utility function dmi_memdev_handle() which returns the DMI handle associated with a given memory slot. This will allow kernel drivers to iterate over the memory slots. Signed-off-by: Jean Delvare <[email protected]>
1 parent 9e0afe3 commit 7c23788

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

drivers/firmware/dmi_scan.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,3 +1151,19 @@ u8 dmi_memdev_type(u16 handle)
11511151
return 0x0; /* Not a valid value */
11521152
}
11531153
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ 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);
116116
extern u8 dmi_memdev_type(u16 handle);
117+
extern u16 dmi_memdev_handle(int slot);
117118

118119
#else
119120

@@ -144,6 +145,7 @@ static inline void dmi_memdev_name(u16 handle, const char **bank,
144145
const char **device) { }
145146
static inline u64 dmi_memdev_size(u16 handle) { return ~0ul; }
146147
static inline u8 dmi_memdev_type(u16 handle) { return 0x0; }
148+
static inline u16 dmi_memdev_handle(int slot) { return 0xffff; }
147149
static inline const struct dmi_system_id *
148150
dmi_first_match(const struct dmi_system_id *list) { return NULL; }
149151

0 commit comments

Comments
 (0)