diff mbox series

stm32mp: simplify the STM32MP15x package parsing code

Message ID 20220620094959.1.I4d177d06061a5973e5cd25d2b61e74fdb2861a2a@changeid
State Accepted
Commit 50b2184257c27833eece838dff5a519f07325082
Delegated to: Patrick Delaunay
Headers show
Series stm32mp: simplify the STM32MP15x package parsing code | expand

Commit Message

Patrick Delaunay June 20, 2022, 7:50 a.m. UTC
Simplify the package parsing code for STM32MP15X as package can be
affected with get_cpu_package() result.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
---

 arch/arm/mach-stm32mp/stm32mp15x.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

Comments

Patrice CHOTARD July 7, 2022, 6:49 a.m. UTC | #1
Hi Patrick

On 6/20/22 09:50, Patrick Delaunay wrote:
> Simplify the package parsing code for STM32MP15X as package can be
> affected with get_cpu_package() result.
> 
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
> 
>  arch/arm/mach-stm32mp/stm32mp15x.c | 15 +++------------
>  1 file changed, 3 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/arm/mach-stm32mp/stm32mp15x.c b/arch/arm/mach-stm32mp/stm32mp15x.c
> index a093e6163e6..660c907a6ba 100644
> --- a/arch/arm/mach-stm32mp/stm32mp15x.c
> +++ b/arch/arm/mach-stm32mp/stm32mp15x.c
> @@ -274,7 +274,6 @@ static void get_cpu_string_offsets(unsigned int *type, unsigned int *pkg,
>  	u32 cpu_type = get_cpu_type();
>  	u32 ct = cpu_type & ~(BIT(7) | BIT(0));
>  	u32 cm = ((cpu_type & BIT(7)) >> 6) | (cpu_type & BIT(0));
> -	u32 cp = get_cpu_package();
>  
>  	/* Bits 0 and 7 are the ACDF, 00:C 01:A 10:F 11:D */
>  	switch (ct) {
> @@ -293,17 +292,9 @@ static void get_cpu_string_offsets(unsigned int *type, unsigned int *pkg,
>  	}
>  
>  	/* Package */
> -	switch (cp) {
> -	case STM32MP15_PKG_AA_LBGA448:
> -	case STM32MP15_PKG_AB_LBGA354:
> -	case STM32MP15_PKG_AC_TFBGA361:
> -	case STM32MP15_PKG_AD_TFBGA257:
> -		*pkg = cp;
> -		break;
> -	default:
> -		*pkg = 0;
> -		break;
> -	}
> +	*pkg = get_cpu_package();
> +	if (*pkg > STM32MP15_PKG_AA_LBGA448)
> +		*pkg = STM32MP15_PKG_UNKNOWN;
>  
>  	/* Revision */
>  	switch (get_cpu_rev()) {
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice
Patrick Delaunay Sept. 7, 2022, 1:29 p.m. UTC | #2
Hi,

On 6/20/22 09:50, Patrick Delaunay wrote:
> Simplify the package parsing code for STM32MP15X as package can be
> affected with get_cpu_package() result.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
>
>   arch/arm/mach-stm32mp/stm32mp15x.c | 15 +++------------
>   1 file changed, 3 insertions(+), 12 deletions(-)
>


Applied to u-boot-stm/master, thanks!

Regards
Patrick
diff mbox series

Patch

diff --git a/arch/arm/mach-stm32mp/stm32mp15x.c b/arch/arm/mach-stm32mp/stm32mp15x.c
index a093e6163e6..660c907a6ba 100644
--- a/arch/arm/mach-stm32mp/stm32mp15x.c
+++ b/arch/arm/mach-stm32mp/stm32mp15x.c
@@ -274,7 +274,6 @@  static void get_cpu_string_offsets(unsigned int *type, unsigned int *pkg,
 	u32 cpu_type = get_cpu_type();
 	u32 ct = cpu_type & ~(BIT(7) | BIT(0));
 	u32 cm = ((cpu_type & BIT(7)) >> 6) | (cpu_type & BIT(0));
-	u32 cp = get_cpu_package();
 
 	/* Bits 0 and 7 are the ACDF, 00:C 01:A 10:F 11:D */
 	switch (ct) {
@@ -293,17 +292,9 @@  static void get_cpu_string_offsets(unsigned int *type, unsigned int *pkg,
 	}
 
 	/* Package */
-	switch (cp) {
-	case STM32MP15_PKG_AA_LBGA448:
-	case STM32MP15_PKG_AB_LBGA354:
-	case STM32MP15_PKG_AC_TFBGA361:
-	case STM32MP15_PKG_AD_TFBGA257:
-		*pkg = cp;
-		break;
-	default:
-		*pkg = 0;
-		break;
-	}
+	*pkg = get_cpu_package();
+	if (*pkg > STM32MP15_PKG_AA_LBGA448)
+		*pkg = STM32MP15_PKG_UNKNOWN;
 
 	/* Revision */
 	switch (get_cpu_rev()) {