Now that we solely depend on the vendor pci id the station id will be
compared for a large number of pci device ids. Cache the station id to
avoid retreiving it from SMBIOSTable every time.

Signed-off-by: Tobias Schaffner <tobias.schaff...@siemens.com>
---
 drivers/utils/simatic.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/utils/simatic.c b/drivers/utils/simatic.c
index a1c63cb..376dc42 100644
--- a/drivers/utils/simatic.c
+++ b/drivers/utils/simatic.c
@@ -20,6 +20,9 @@
 #include "smbios.h"
 #include "utils.h"
 
+static UINT32 station_id;
+static BOOLEAN station_id_cached;
+
 static UINT32 get_station_id(SMBIOS_STRUCTURE_POINTER oem_strct)
 {
        SIMATIC_OEM_ENTRY *entry;
@@ -45,6 +48,9 @@ static UINT32 get_station_id(SMBIOS_STRUCTURE_POINTER 
oem_strct)
 
 UINT32 simatic_station_id(VOID)
 {
+       if (station_id_cached)
+               return station_id;
+
        SMBIOS_STRUCTURE_TABLE *smbios_table;
        SMBIOS_STRUCTURE_POINTER smbios_struct;
        EFI_STATUS status;
@@ -60,5 +66,8 @@ UINT32 simatic_station_id(VOID)
                return 0;
        }
 
-       return get_station_id(smbios_struct);
+       station_id = get_station_id(smbios_struct);
+       station_id_cached = TRUE;
+
+       return station_id;
 }
-- 
2.40.1

-- 
You received this message because you are subscribed to the Google Groups "EFI 
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to efibootguard-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/20240516091812.579599-4-tobias.schaffner%40siemens.com.

Reply via email to