[PATCH v4 2/3] Silicon/Broadcom/Bcm283x: Clean up GpioPinSet function


Sunny Wang
 

Make the changes below for making it clearer.
- Rename GpioPinSet() to GpioPinConfigure()
- Rename parameter Val to Config and change its type to BOOLEAN

Cc: Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@...>
Cc: Sami Mujawar <sami.mujawar@...>
Cc: Jeremy Linton <jeremy.linton@...>
Cc: Pete Batard <pete@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Mario Bălănică <mariobalanica02@...>
Signed-off-by: Sunny Wang <sunny.wang@...>
---
Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h | 10 +++++++---
Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c | 9 +++++----
2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h b/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h
index 75c2c8be51..1f7d2204e0 100644
--- a/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h
+++ b/Silicon/Broadcom/Bcm283x/Include/Library/GpioLib.h
@@ -3,6 +3,7 @@
* GPIO manipulation.
*
* Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@...>
+ * Copyright (c) 2021, ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*
@@ -13,6 +14,9 @@

#include <IndustryStandard/Bcm2836Gpio.h>

+#define CLEAR_GPIO 0
+#define SET_GPIO 1
+
VOID
GpioPinFuncSet (
IN UINTN Pin,
@@ -25,9 +29,9 @@ GpioPinFuncGet (
);

VOID
-GpioPinSet (
- IN UINTN Pin,
- IN UINTN Val
+GpioPinConfigure (
+ IN UINTN Pin,
+ IN BOOLEAN Config
);

UINTN
diff --git a/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c b/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c
index a4b4af59eb..eaf53e5369 100644
--- a/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c
+++ b/Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.c
@@ -4,6 +4,7 @@
*
* Copyright (c) 2020, Pete Batard <pete@...>
* Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@...>
+ * Copyright (c) 2021, ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*
@@ -85,9 +86,9 @@ GpioPinFuncGet (
}

VOID
-GpioPinSet (
- IN UINTN Pin,
- IN UINTN Val
+GpioPinConfigure (
+ IN UINTN Pin,
+ IN BOOLEAN Config
)
{
EFI_PHYSICAL_ADDRESS Reg;
@@ -102,7 +103,7 @@ GpioPinSet (
//
// Different base addresses are used for clear and set
//
- Reg = (Val == 0) ? GPIO_GPCLR0 : GPIO_GPSET0;
+ Reg = (Config == CLEAR_GPIO) ? GPIO_GPCLR0 : GPIO_GPSET0;
Reg += RegIndex * sizeof (UINT32);
MmioWrite32 (Reg, 1 << SelIndex);
}
--
2.31.0.windows.1

Join devel@edk2.groups.io to automatically receive all group messages.