diff options
Diffstat (limited to 'lib/smbios-parser.c')
-rw-r--r-- | lib/smbios-parser.c | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/lib/smbios-parser.c b/lib/smbios-parser.c index b578c308408..ac9a367a878 100644 --- a/lib/smbios-parser.c +++ b/lib/smbios-parser.c @@ -5,22 +5,11 @@ #define LOG_CATEGORY LOGC_BOOT +#include <errno.h> #include <smbios.h> - -static inline int verify_checksum(const struct smbios_entry *e) -{ - /* - * Checksums for SMBIOS tables are calculated to have a value, so that - * the sum over all bytes yields zero (using unsigned 8 bit arithmetic). - */ - u8 *byte = (u8 *)e; - u8 sum = 0; - - for (int i = 0; i < e->length; i++) - sum += byte[i]; - - return sum; -} +#include <string.h> +#include <tables_csum.h> +#include <linux/kernel.h> const struct smbios_entry *smbios_entry(u64 address, u32 size) { @@ -32,7 +21,7 @@ const struct smbios_entry *smbios_entry(u64 address, u32 size) if (memcmp(entry->anchor, "_SM_", 4)) return NULL; - if (verify_checksum(entry)) + if (table_compute_checksum(entry, entry->length)) return NULL; return entry; @@ -50,14 +39,7 @@ static u8 *find_next_header(u8 *pos) return pos; } -static struct smbios_header *get_next_header(struct smbios_header *curr) -{ - u8 *pos = ((u8 *)curr) + curr->length; - - return (struct smbios_header *)find_next_header(pos); -} - -static const struct smbios_header *next_header(const struct smbios_header *curr) +static struct smbios_header *get_next_header(const struct smbios_header *curr) { u8 *pos = ((u8 *)curr) + curr->length; @@ -73,7 +55,7 @@ const struct smbios_header *smbios_header(const struct smbios_entry *entry, int if (header->type == type) return header; - header = next_header(header); + header = get_next_header(header); } return NULL; |