Skip to content

Commit

Permalink
Cache simatic station id
Browse files Browse the repository at this point in the history
The simatic station id may be retreived 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 <[email protected]>
Signed-off-by: Jan Kiszka <[email protected]>
  • Loading branch information
TobiasSchaffner authored and jan-kiszka committed May 17, 2024
1 parent 7dee866 commit b0ec245
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion drivers/utils/simatic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}

0 comments on commit b0ec245

Please sign in to comment.