]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
lib: smbios: verify_checksum() is duplicate
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Tue, 26 Dec 2023 10:22:28 +0000 (11:22 +0100)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Tue, 9 Jan 2024 09:09:09 +0000 (10:09 +0100)
The function verify_checksum() duplicates what table_compute_checksum()
does. Replace it. table_compute_checksum() is always compiled.

Fixes: 415eab0655a8 ("smbios: add parsing API")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
lib/smbios-parser.c

index b578c3084081380face3a519070c879d2531bc27..4a3732bcf2edd7df1c6b0a5af1e2448ba5708510 100644 (file)
@@ -6,21 +6,7 @@
 #define LOG_CATEGORY   LOGC_BOOT
 
 #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 <tables_csum.h>
 
 const struct smbios_entry *smbios_entry(u64 address, u32 size)
 {
@@ -32,7 +18,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;