On 27.03.24 09:19, Tobias Schaffner wrote:
> 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/watchdog/w83627hf_wdt.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/w83627hf_wdt.c b/drivers/watchdog/w83627hf_wdt.c
> index 68cb42a..c0c35d2 100644
> --- a/drivers/watchdog/w83627hf_wdt.c
> +++ b/drivers/watchdog/w83627hf_wdt.c
> @@ -39,6 +39,7 @@
>  #include <efi.h>
>  #include <efilib.h>
>  #include <pci/header.h>
> +#include <stdbool.h>

Not needed when you properly pair UEFI BOOLEAN with TRUE and FALSE.

>  #include <sys/io.h>
>  #include <mmio.h>
>  #include "simatic.h"
> @@ -69,6 +70,8 @@ static int cr_wdt_control;  /* WDT control register */
>  static int cr_wdt_csr;               /* WDT control & status register */
>  static int wdt_cfg_enter = 0x87;/* key to unlock configuration space */
>  static int wdt_cfg_leave = 0xAA;/* key to lock configuration space */
> +static UINT32 station_id = 0;

This is redundant: First, static variables are zero-initialized. Second,
station_id is only used when station_id_cached is true.

> +static BOOLEAN station_id_cached = false;

This initialization is also redundant.

>  
>  static void superio_outb(int reg, int val)
>  {
> @@ -192,6 +195,15 @@ static int wdt_set_time(unsigned int timeout)
>       return 0;
>  }
>  
> +static UINT32 cached_simatic_station_id(VOID)
> +{
> +     if (station_id_cached) return station_id;

Please unfold into two line.

> +
> +     station_id = simatic_station_id();
> +     station_id_cached = true;
> +     return station_id;
> +}
> +
>  static EFI_STATUS init(EFI_PCI_IO *pci_io, UINT16 pci_vendor_id,
>                      UINT16 __attribute__((unused)) pci_device_id,
>                      UINTN timeout)
> @@ -202,7 +214,7 @@ static EFI_STATUS init(EFI_PCI_IO *pci_io, UINT16 
> pci_vendor_id,
>               return EFI_UNSUPPORTED;
>       }
>  
> -     switch (simatic_station_id()) {
> +     switch (cached_simatic_station_id()) {

Please make the official interface caching by default. That would avoid
this change and make every user benefit.

>       case SIMATIC_IPCBX_56A:
>       case SIMATIC_IPCBX_59A:
>               chip = wdt_find(0x2e);

Jan

-- 
Siemens AG, Technology
Linux Expert Center

-- 
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/fe2e95d7-99ee-418b-a80f-3ea6b95a24b1%40siemens.com.

Reply via email to