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

Sunny Wang posted 3 patches 4 years, 8 months ago
[edk2-devel] [PATCH v4 2/3] Silicon/Broadcom/Bcm283x: Clean up GpioPinSet function
Posted by Sunny Wang 4 years, 8 months ago
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@arm.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jeremy Linton <jeremy.linton@arm.com>
Cc: Pete Batard <pete@akeo.ie>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Mario Bălănică <mariobalanica02@gmail.com>
Signed-off-by: Sunny Wang <sunny.wang@arm.com>
---
 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@gmail.com>
+ *  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@akeo.ie>
  *  Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
+ *  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



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76117): https://edk2.groups.io/g/devel/message/76117
Mute This Topic: https://groups.io/mt/83365132/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH v4 2/3] Silicon/Broadcom/Bcm283x: Clean up GpioPinSet function
Posted by Pete Batard 4 years, 8 months ago
On 2021.06.07 08:53, Sunny Wang wrote:
> 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@arm.com>
> Cc: Sami Mujawar <sami.mujawar@arm.com>
> Cc: Jeremy Linton <jeremy.linton@arm.com>
> Cc: Pete Batard <pete@akeo.ie>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Mario Bălănică <mariobalanica02@gmail.com>
> Signed-off-by: Sunny Wang <sunny.wang@arm.com>
> ---
>   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@gmail.com>
> + *  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@akeo.ie>
>    *  Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
> + *  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);
>   }
> 

Reviewed-by: Pete Batard <pete@akeo.ie>



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76432): https://edk2.groups.io/g/devel/message/76432
Mute This Topic: https://groups.io/mt/83365132/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-