Skip to contentSkip to conversation

arm: mvebu: Cleanup get_boot_device() code

PATCH Superseded Pali Rohár 2 participants 7 messages Mar 4, 2023 – Mar 30, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: mvebu: Cleanup get_boot_device() code

Show correct information in debug() output and use correct names for variables.

No functional change.

---
 arch/arm/mach-mvebu/cpu.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
arch/arm/mach-mvebu/cpu.c +8 -5
index 97154aaa2a7e..018a3614d4dd 100644
@@ -67,6 +67,8 @@ u32 get_boot_device(void)
 {
 	u32 val;
 	u32 boot_device;
+	u32 boot_err_mode;
+	u32 boot_err_code;
 
 	/*
 	 * First check, if UART boot-mode is active. This can only
@@ -74,9 +76,9 @@ u32 get_boot_device(void)
 	 * MSB marks if the UART mode is active.
 	 */
 	val = readl(BOOTROM_ERR_REG);
-	boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
-	debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
-	if (boot_device == BOOTROM_ERR_MODE_UART)
+	boot_err_mode = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
+	debug("BOOTROM_ERR_REG=0x%08x boot_err_mode=0x%x\n", val, boot_err_mode);
+	if (boot_err_mode == BOOTROM_ERR_MODE_UART)
 		return BOOT_DEVICE_UART;
 
 #ifdef CONFIG_ARMADA_38X
@@ -84,8 +86,9 @@ u32 get_boot_device(void)
 	 * If the bootrom error code contains any other than zeros it's an
 	 * error condition and the bootROM has fallen back to UART boot
 	 */
-	boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
-	if (boot_device)
+	boot_err_code = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
+	debug("boot_err_code=0x%x\n", boot_err_code);
+	if (boot_err_code)
 		return BOOT_DEVICE_UART;
 #endif
 
Signature · 1 line
2.20.1
#1 lore raw

Hi Pali,

Quoted 37 lines · Pali Rohár

Show correct information in debug() output and use correct names for variables.

No functional change.

---
  arch/arm/mach-mvebu/cpu.c | 13 ++++++++-----
  1 file changed, 8 insertions(+), 5 deletions(-)
arch/arm/mach-mvebu/cpu.c +5 -3
index 97154aaa2a7e..018a3614d4dd 100644
@@ -67,6 +67,8 @@ u32 get_boot_device(void)
  {
  	u32 val;
  	u32 boot_device;
+	u32 boot_err_mode;
+	u32 boot_err_code;
 
  	/*
  	 * First check, if UART boot-mode is active. This can only
@@ -74,9 +76,9 @@ u32 get_boot_device(void)
  	 * MSB marks if the UART mode is active.
  	 */
  	val = readl(BOOTROM_ERR_REG);
-	boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
-	debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
-	if (boot_device == BOOTROM_ERR_MODE_UART)
+	boot_err_mode = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
+	debug("BOOTROM_ERR_REG=0x%08x boot_err_mode=0x%x\n", val, boot_err_mode);
+	if (boot_err_mode == BOOTROM_ERR_MODE_UART)
  		return BOOT_DEVICE_UART;
 
  #ifdef CONFIG_ARMADA_38X
@@ -84,8 +86,9 @@ u32 get_boot_device(void)
  	 * If the bootrom error code contains any other than zeros it's an

arch/arm/mach-mvebu/cpu.c u32 get_boot_device(void) · line 94

Quoted 10 lines
arch/arm/mach-mvebu/cpu.c +3 -2
  	 * error condition and the bootROM has fallen back to UART boot
  	 */
-	boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
-	if (boot_device)
+	boot_err_code = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
+	debug("boot_err_code=0x%x\n", boot_err_code);
+	if (boot_err_code)
  		return BOOT_DEVICE_UART;
  #endif
 

This leads to the following compile warnings, e.g. for maxbcm_defconfig:

[stefan@zen4 u-boot-marvell (next)]$ make -sj
arch/arm/mach-mvebu/cpu.c: In function 'get_boot_device':
arch/arm/mach-mvebu/cpu.c:71:13: warning: unused variable 'boot_err_code' [-Wunused-variable]

   71 |         u32 boot_err_code;
      |             ^~~~~~~~~~~~~
arch/arm/mach-mvebu/cpu.c: In function 'get_boot_device':
arch/arm/mach-mvebu/cpu.c:71:13: warning: unused variable 'boot_err_code' [-Wunused-variable]
   71 |         u32 boot_err_code;
      |             ^~~~~~~~~~~~~

Could you please take a look?

Thanks,
Stefan

#2 lore raw
Quoted 62 lines · On Friday 24 March 2023 11:24:07 Stefan Roese wrote:

Hi Pali,

Quoted 34 lines · Pali Rohár

Show correct information in debug() output and use correct names for variables.

No functional change.

---
  arch/arm/mach-mvebu/cpu.c | 13 ++++++++-----
  1 file changed, 8 insertions(+), 5 deletions(-)
arch/arm/mach-mvebu/cpu.c +5 -3
index 97154aaa2a7e..018a3614d4dd 100644
@@ -67,6 +67,8 @@ u32 get_boot_device(void)
  {
  	u32 val;
  	u32 boot_device;
+	u32 boot_err_mode;
+	u32 boot_err_code;
  	/*
  	 * First check, if UART boot-mode is active. This can only
@@ -74,9 +76,9 @@ u32 get_boot_device(void)
  	 * MSB marks if the UART mode is active.
  	 */
  	val = readl(BOOTROM_ERR_REG);
-	boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
-	debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
-	if (boot_device == BOOTROM_ERR_MODE_UART)
+	boot_err_mode = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
+	debug("BOOTROM_ERR_REG=0x%08x boot_err_mode=0x%x\n", val, boot_err_mode);
+	if (boot_err_mode == BOOTROM_ERR_MODE_UART)
  		return BOOT_DEVICE_UART;
  #ifdef CONFIG_ARMADA_38X

arch/arm/mach-mvebu/cpu.c u32 get_boot_device(void) · line 93

Quoted 10 lines
arch/arm/mach-mvebu/cpu.c +3 -2
@@ -84,8 +86,9 @@ u32 get_boot_device(void)
  	 * If the bootrom error code contains any other than zeros it's an
  	 * error condition and the bootROM has fallen back to UART boot
  	 */
-	boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
-	if (boot_device)
+	boot_err_code = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
+	debug("boot_err_code=0x%x\n", boot_err_code);
+	if (boot_err_code)
  		return BOOT_DEVICE_UART;
  #endif

This leads to the following compile warnings, e.g. for maxbcm_defconfig:

[stefan@zen4 u-boot-marvell (next)]$ make -sj arch/arm/mach-mvebu/cpu.c: In function 'get_boot_device':
arch/arm/mach-mvebu/cpu.c:71:13: warning: unused variable 'boot_err_code' [-Wunused-variable]

   71 |         u32 boot_err_code;
      |             ^~~~~~~~~~~~~
arch/arm/mach-mvebu/cpu.c: In function 'get_boot_device':
arch/arm/mach-mvebu/cpu.c:71:13: warning: unused variable 'boot_err_code'
[-Wunused-variable]
   71 |         u32 boot_err_code;
      |             ^~~~~~~~~~~~~
Quoted 4 lines

Could you please take a look?

Thanks,
Stefan

It looks like you need to add #ifdef CONFIG_ARMADA_38X guard around declaration of boot_err_code variable (at the beginning the function) because this variable is unused on non-a38x platforms.

#3 lore raw

Hi Pali,

Quoted 63 lines · Pali Rohár
Quoted 62 lines · On Friday 24 March 2023 11:24:07 Stefan Roese wrote:

Hi Pali,

Quoted 34 lines · Pali Rohár

Show correct information in debug() output and use correct names for variables.

No functional change.

---
   arch/arm/mach-mvebu/cpu.c | 13 ++++++++-----
   1 file changed, 8 insertions(+), 5 deletions(-)
arch/arm/mach-mvebu/cpu.c +5 -3
index 97154aaa2a7e..018a3614d4dd 100644
@@ -67,6 +67,8 @@ u32 get_boot_device(void)
   {
   	u32 val;
   	u32 boot_device;
+	u32 boot_err_mode;
+	u32 boot_err_code;
   	/*
   	 * First check, if UART boot-mode is active. This can only
@@ -74,9 +76,9 @@ u32 get_boot_device(void)
   	 * MSB marks if the UART mode is active.
   	 */
   	val = readl(BOOTROM_ERR_REG);
-	boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
-	debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
-	if (boot_device == BOOTROM_ERR_MODE_UART)
+	boot_err_mode = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
+	debug("BOOTROM_ERR_REG=0x%08x boot_err_mode=0x%x\n", val, boot_err_mode);
+	if (boot_err_mode == BOOTROM_ERR_MODE_UART)
   		return BOOT_DEVICE_UART;
   #ifdef CONFIG_ARMADA_38X

arch/arm/mach-mvebu/cpu.c u32 get_boot_device(void) · line 93

Quoted 10 lines
arch/arm/mach-mvebu/cpu.c +3 -2
@@ -84,8 +86,9 @@ u32 get_boot_device(void)
   	 * If the bootrom error code contains any other than zeros it's an
   	 * error condition and the bootROM has fallen back to UART boot
   	 */
-	boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
-	if (boot_device)
+	boot_err_code = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
+	debug("boot_err_code=0x%x\n", boot_err_code);
+	if (boot_err_code)
   		return BOOT_DEVICE_UART;
   #endif

This leads to the following compile warnings, e.g. for maxbcm_defconfig:

[stefan@zen4 u-boot-marvell (next)]$ make -sj arch/arm/mach-mvebu/cpu.c: In function 'get_boot_device':
arch/arm/mach-mvebu/cpu.c:71:13: warning: unused variable 'boot_err_code' [-Wunused-variable]

    71 |         u32 boot_err_code;
       |             ^~~~~~~~~~~~~
arch/arm/mach-mvebu/cpu.c: In function 'get_boot_device':
arch/arm/mach-mvebu/cpu.c:71:13: warning: unused variable 'boot_err_code'
[-Wunused-variable]
    71 |         u32 boot_err_code;
       |             ^~~~~~~~~~~~~
Quoted 8 lines
Quoted 4 lines

Could you please take a look?

Thanks,
Stefan

It looks like you need to add #ifdef CONFIG_ARMADA_38X guard around declaration of boot_err_code variable (at the beginning the function) because this variable is unused on non-a38x platforms.

Yes, I'm sure I could fix this myself. But could you please send a v2 (based on latest next) so that I can apply it easier?

Thanks,
Stefan

#4 lore raw

PATCH v2 1/1 arm: mvebu: Cleanup get_boot_device() code

In reply to Pali Rohár

Show correct information in debug() output and use correct names for variables.

No functional change.

---
 arch/arm/mach-mvebu/cpu.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
arch/arm/mach-mvebu/cpu.c +10 -5
index 56999f608a38..8b91e174c4c1 100644
@@ -67,6 +67,10 @@ u32 get_boot_device(void)
 {
 	u32 val;
 	u32 boot_device;
+	u32 boot_err_mode;
+#ifdef CONFIG_ARMADA_38X
+	u32 boot_err_code;
+#endif
 
 	/*
 	 * First check, if UART boot-mode is active. This can only
@@ -74,9 +78,9 @@ u32 get_boot_device(void)
 	 * MSB marks if the UART mode is active.
 	 */
 	val = readl(BOOTROM_ERR_REG);
-	boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
-	debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
-	if (boot_device == BOOTROM_ERR_MODE_UART)
+	boot_err_mode = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
+	debug("BOOTROM_ERR_REG=0x%08x boot_err_mode=0x%x\n", val, boot_err_mode);
+	if (boot_err_mode == BOOTROM_ERR_MODE_UART)
 		return BOOT_DEVICE_UART;
 
 #ifdef CONFIG_ARMADA_38X
@@ -84,8 +88,9 @@ u32 get_boot_device(void)
 	 * If the bootrom error code contains any other than zeros it's an
 	 * error condition and the bootROM has fallen back to UART boot
 	 */
-	boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
-	if (boot_device)
+	boot_err_code = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
+	debug("boot_err_code=0x%x\n", boot_err_code);
+	if (boot_err_code)
 		return BOOT_DEVICE_UART;
 #endif
 
Signature · 1 line
2.20.1
Reviewed-by on v2 1/1
#5 lore raw
Quoted 5 lines · Pali Rohár

Show correct information in debug() output and use correct names for variables.

No functional change.

Thanks,
Stefan

Quoted 34 lines
---
  arch/arm/mach-mvebu/cpu.c | 15 ++++++++++-----
  1 file changed, 10 insertions(+), 5 deletions(-)
arch/arm/mach-mvebu/cpu.c +7 -3
index 56999f608a38..8b91e174c4c1 100644
@@ -67,6 +67,10 @@ u32 get_boot_device(void)
  {
  	u32 val;
  	u32 boot_device;
+	u32 boot_err_mode;
+#ifdef CONFIG_ARMADA_38X
+	u32 boot_err_code;
+#endif
 
  	/*
  	 * First check, if UART boot-mode is active. This can only
@@ -74,9 +78,9 @@ u32 get_boot_device(void)
  	 * MSB marks if the UART mode is active.
  	 */
  	val = readl(BOOTROM_ERR_REG);
-	boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
-	debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
-	if (boot_device == BOOTROM_ERR_MODE_UART)
+	boot_err_mode = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
+	debug("BOOTROM_ERR_REG=0x%08x boot_err_mode=0x%x\n", val, boot_err_mode);
+	if (boot_err_mode == BOOTROM_ERR_MODE_UART)
  		return BOOT_DEVICE_UART;
 
  #ifdef CONFIG_ARMADA_38X
@@ -84,8 +88,9 @@ u32 get_boot_device(void)
  	 * If the bootrom error code contains any other than zeros it's an

arch/arm/mach-mvebu/cpu.c u32 get_boot_device(void) · line 96

Quoted 10 lines
arch/arm/mach-mvebu/cpu.c +3 -2
  	 * error condition and the bootROM has fallen back to UART boot
  	 */
-	boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
-	if (boot_device)
+	boot_err_code = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
+	debug("boot_err_code=0x%x\n", boot_err_code);
+	if (boot_err_code)
  		return BOOT_DEVICE_UART;
  #endif
 

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
#6 lore raw
In reply to Pali Rohár
Quoted 5 lines · Pali Rohár

Show correct information in debug() output and use correct names for variables.

No functional change.

Applied to u-boot-marvell/next

Thanks,
Stefan

Quoted 34 lines
---
  arch/arm/mach-mvebu/cpu.c | 15 ++++++++++-----
  1 file changed, 10 insertions(+), 5 deletions(-)
arch/arm/mach-mvebu/cpu.c +7 -3
index 56999f608a38..8b91e174c4c1 100644
@@ -67,6 +67,10 @@ u32 get_boot_device(void)
  {
  	u32 val;
  	u32 boot_device;
+	u32 boot_err_mode;
+#ifdef CONFIG_ARMADA_38X
+	u32 boot_err_code;
+#endif
 
  	/*
  	 * First check, if UART boot-mode is active. This can only
@@ -74,9 +78,9 @@ u32 get_boot_device(void)
  	 * MSB marks if the UART mode is active.
  	 */
  	val = readl(BOOTROM_ERR_REG);
-	boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
-	debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
-	if (boot_device == BOOTROM_ERR_MODE_UART)
+	boot_err_mode = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
+	debug("BOOTROM_ERR_REG=0x%08x boot_err_mode=0x%x\n", val, boot_err_mode);
+	if (boot_err_mode == BOOTROM_ERR_MODE_UART)
  		return BOOT_DEVICE_UART;
 
  #ifdef CONFIG_ARMADA_38X
@@ -84,8 +88,9 @@ u32 get_boot_device(void)
  	 * If the bootrom error code contains any other than zeros it's an

arch/arm/mach-mvebu/cpu.c u32 get_boot_device(void) · line 96

Quoted 10 lines
arch/arm/mach-mvebu/cpu.c +3 -2
  	 * error condition and the bootROM has fallen back to UART boot
  	 */
-	boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
-	if (boot_device)
+	boot_err_code = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
+	debug("boot_err_code=0x%x\n", boot_err_code);
+	if (boot_err_code)
  		return BOOT_DEVICE_UART;
  #endif
 

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]