]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg: Fix bug in Generic Watchdog driver
authorAlexeiFedorov <alexei.fedorov@arm.com>
Fri, 27 Apr 2018 13:58:43 +0000 (14:58 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 30 Apr 2018 09:38:54 +0000 (11:38 +0200)
In ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c, the following
functions:

  WatchdogWriteOffsetRegister()
  WatchdogWriteCompareRegister()
  WatchdogEnable()
  WatchdogDisable()

provide write access to ARM Generic Watchdog registers and use the values
returned by MmioWrite32() and MmioWrite64() as EFI_STATUS return codes.

Because MmioWriteXY() return the value passed as its write parameter,
Generic Watchdog access functions can spuriously return error codes which
are different from EFI_SUCCESS, e.g. the following call

    Status = WatchdogWriteOffsetRegister (MAX_UINT32);
    if (EFI_ERROR (Status)) {
      return Status;
    }

will return MAX_UINT32 defined in MdePkg/Include/Base.h as

 #define MAX_UINT32  ((UINT32)0xFFFFFFFF)

This commit declares all the functions listed above as VOID
and removes the code for checking their return values.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Alexei Fedorov <alexei.fedorov@arm.com>
Reviewed-by: Evan Lloyd <evan.lloyd@arm.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.c

index 252ba5bf321e379ef440830cab468af7c55905b3..3180f011253639c408b7151c79c2106a352c7340 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 *\r
-*  Copyright (c) 2013-2017, ARM Limited. All rights reserved.\r
+*  Copyright (c) 2013-2018, ARM Limited. All rights reserved.\r
 *\r
 *  This program and the accompanying materials\r
 *  are licensed and made available under the terms and conditions of the BSD\r
@@ -43,36 +43,36 @@ UINT64 mNumTimerTicks = 0;
 \r
 EFI_HARDWARE_INTERRUPT2_PROTOCOL *mInterruptProtocol;\r
 \r
-EFI_STATUS\r
+VOID\r
 WatchdogWriteOffsetRegister (\r
   UINT32  Value\r
   )\r
 {\r
-  return MmioWrite32 (GENERIC_WDOG_OFFSET_REG, Value);\r
+  MmioWrite32 (GENERIC_WDOG_OFFSET_REG, Value);\r
 }\r
 \r
-EFI_STATUS\r
+VOID\r
 WatchdogWriteCompareRegister (\r
   UINT64  Value\r
   )\r
 {\r
-  return MmioWrite64 (GENERIC_WDOG_COMPARE_VALUE_REG, Value);\r
+  MmioWrite64 (GENERIC_WDOG_COMPARE_VALUE_REG, Value);\r
 }\r
 \r
-EFI_STATUS\r
+VOID\r
 WatchdogEnable (\r
   VOID\r
   )\r
 {\r
-  return MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_ENABLED);\r
+  MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_ENABLED);\r
 }\r
 \r
-EFI_STATUS\r
+VOID\r
 WatchdogDisable (\r
   VOID\r
   )\r
 {\r
-  return MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_DISABLED);\r
+  MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_DISABLED);\r
 }\r
 \r
 /** On exiting boot services we must make sure the Watchdog Timer\r
@@ -163,9 +163,7 @@ WatchdogRegisterHandler (
                            then the watchdog timer is disabled.\r
 \r
   @retval EFI_SUCCESS           The watchdog timer has been programmed to fire\r
-                                in Time  100ns units.\r
-  @retval EFI_DEVICE_ERROR      A watchdog timer could not be programmed due\r
-                                to a device error.\r
+                                in TimerPeriod 100ns units.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -176,12 +174,12 @@ WatchdogSetTimerPeriod (
   )\r
 {\r
   UINTN       SystemCount;\r
-  EFI_STATUS  Status;\r
 \r
   // if TimerPeriod is 0, this is a request to stop the watchdog.\r
   if (TimerPeriod == 0) {\r
     mNumTimerTicks = 0;\r
-    return WatchdogDisable ();\r
+    WatchdogDisable ();\r
+    return EFI_SUCCESS;\r
   }\r
 \r
   // Work out how many timer ticks will equate to TimerPeriod\r
@@ -195,19 +193,16 @@ WatchdogSetTimerPeriod (
        because enabling the watchdog causes an "explicit refresh", which\r
        clobbers the compare register (WCV). In order to make sure this doesn't\r
        trigger an interrupt, set the offset to max. */\r
-    Status = WatchdogWriteOffsetRegister (MAX_UINT32);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
+    WatchdogWriteOffsetRegister (MAX_UINT32);\r
     WatchdogEnable ();\r
     SystemCount = ArmGenericTimerGetSystemCount ();\r
-    Status      = WatchdogWriteCompareRegister (SystemCount + mNumTimerTicks);\r
+    WatchdogWriteCompareRegister (SystemCount + mNumTimerTicks);\r
   } else {\r
-    Status = WatchdogWriteOffsetRegister ((UINT32)mNumTimerTicks);\r
+    WatchdogWriteOffsetRegister ((UINT32)mNumTimerTicks);\r
     WatchdogEnable ();\r
   }\r
 \r
-  return Status;\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r