Commit 0dad9ee3 authored by Ard Biesheuvel's avatar Ard Biesheuvel

efistub/smbios: Simplify SMBIOS enumeration API

Update the efi_get_smbios_string() macro to take a pointer to the entire
record struct rather than the header. This removes the need to pass the
type explicitly, as it can be inferred from the typed pointer. Also,
drop 'type' from the prototype of __efi_get_smbios_string(), as it is
never referenced.
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent 37aee82c
...@@ -39,8 +39,7 @@ static bool system_needs_vamap(void) ...@@ -39,8 +39,7 @@ static bool system_needs_vamap(void)
static char const emag[] = "eMAG"; static char const emag[] = "eMAG";
default: default:
version = efi_get_smbios_string(&record->header, 4, version = efi_get_smbios_string(record, processor_version);
processor_version);
if (!version || (strncmp(version, altra, sizeof(altra) - 1) && if (!version || (strncmp(version, altra, sizeof(altra) - 1) &&
strncmp(version, emag, sizeof(emag) - 1))) strncmp(version, emag, sizeof(emag) - 1)))
break; break;
......
...@@ -1204,14 +1204,13 @@ struct efi_smbios_type4_record { ...@@ -1204,14 +1204,13 @@ struct efi_smbios_type4_record {
u16 thread_enabled; u16 thread_enabled;
}; };
#define efi_get_smbios_string(__record, __type, __name) ({ \ #define efi_get_smbios_string(__record, __field) ({ \
int off = offsetof(struct efi_smbios_type ## __type ## _record, \ __typeof__(__record) __rec = __record; \
__name); \ __efi_get_smbios_string(&__rec->header, &__rec->__field); \
__efi_get_smbios_string((__record), __type, off); \
}) })
const u8 *__efi_get_smbios_string(const struct efi_smbios_record *record, const u8 *__efi_get_smbios_string(const struct efi_smbios_record *record,
u8 type, int offset); const u8 *offset);
void efi_remap_image(unsigned long image_base, unsigned alloc_size, void efi_remap_image(unsigned long image_base, unsigned alloc_size,
unsigned long code_size); unsigned long code_size);
......
...@@ -38,7 +38,7 @@ const struct efi_smbios_record *efi_get_smbios_record(u8 type) ...@@ -38,7 +38,7 @@ const struct efi_smbios_record *efi_get_smbios_record(u8 type)
} }
const u8 *__efi_get_smbios_string(const struct efi_smbios_record *record, const u8 *__efi_get_smbios_string(const struct efi_smbios_record *record,
u8 type, int offset) const u8 *offset)
{ {
const u8 *strtable; const u8 *strtable;
...@@ -46,7 +46,7 @@ const u8 *__efi_get_smbios_string(const struct efi_smbios_record *record, ...@@ -46,7 +46,7 @@ const u8 *__efi_get_smbios_string(const struct efi_smbios_record *record,
return NULL; return NULL;
strtable = (u8 *)record + record->length; strtable = (u8 *)record + record->length;
for (int i = 1; i < ((u8 *)record)[offset]; i++) { for (int i = 1; i < *offset; i++) {
int len = strlen(strtable); int len = strlen(strtable);
if (!len) if (!len)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment