Skip to contentSkip to conversation

MIPS: bcm63xx: cpu: Replace BUG() with panic()

PATCH In review Markos Chandras 3 participants 3 messages Sep 30, 2013 – Dec 21, 2013 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: bcm63xx: cpu: Replace BUG() with panic()

BUG() can be a noop if CONFIG_BUG is not selected, leading to the following build problem on a randconfig:

arch/mips/bcm63xx/cpu.c: In function 'detect_cpu_clock':
arch/mips/bcm63xx/cpu.c:254:1: error: control reaches end of non-void function [-Werror=return-type]

We fix this problem by replacing BUG() with panic() since it's best to handle the case of an unknown board instead of silently returning a random clock frequency.

---
This patch is for the upstream-sfr/mips-for-linux-next tree

---
 arch/mips/bcm63xx/cpu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/mips/bcm63xx/cpu.c +4 -2
index b713cd6..88c57cc 100644
@@ -123,7 +123,9 @@ unsigned int bcm63xx_get_memory_size(void)
 
 static unsigned int detect_cpu_clock(void)
 {
-	switch (bcm63xx_get_cpu_id()) {
+	u16 cpu_id = bcm63xx_get_cpu_id();
+
+	switch (cpu_id) {
 	case BCM3368_CPU_ID:
 		return 300000000;
 
@@ -249,7 +251,7 @@ static unsigned int detect_cpu_clock(void)
 	}
 
 	default:
-		BUG();
+		panic("Failed to detect clock for CPU with id=%04d\n", cpu_id);
 	}
 }
 
Signature · 1 line
1.8.3.2
Acked-by on v1 1/1
#1 lore raw

Hi,

Quoted 7 lines · Markos Chandras

BUG() can be a noop if CONFIG_BUG is not selected, leading to the following build problem on a randconfig:

arch/mips/bcm63xx/cpu.c: In function 'detect_cpu_clock':
arch/mips/bcm63xx/cpu.c:254:1: error: control reaches end of non-void function [-Werror=return-type]

Quoted 6 lines

We fix this problem by replacing BUG() with panic() since it's best to handle the case of an unknown board instead of silently returning a random clock frequency.

The patch seems mostly okay, although there tend to be quite a few places treating BUG() as unreachable() - for my part BUG() not being unreachable for BUG=n is a bug, but that's a different story ;) One nitpick though ...

Quoted 22 lines

---
This patch is for the upstream-sfr/mips-for-linux-next tree

---
 arch/mips/bcm63xx/cpu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
arch/mips/bcm63xx/cpu.c +3 -1
index b713cd6..88c57cc 100644
@@ -123,7 +123,9 @@ unsigned int bcm63xx_get_memory_size(void)
 
 static unsigned int detect_cpu_clock(void)
 {
-       switch (bcm63xx_get_cpu_id()) {
+       u16 cpu_id = bcm63xx_get_cpu_id();
+
+       switch (cpu_id) {
        case BCM3368_CPU_ID:
                return 300000000;
 

arch/mips/bcm63xx/cpu.c static unsigned int detect_cpu_clock(void) · line 254

Quoted 5 lines
arch/mips/bcm63xx/cpu.c +1 -1
@@ -249,7 +251,7 @@ static unsigned int detect_cpu_clock(void)
        }
 
        default:
-               BUG();
+               panic("Failed to detect clock for CPU with id=%04d\n", cpu_id);

The cpu_id is in hex, so it needs to be %04x - not that it matters much since early printk won't work yet at this stage anyway IIRC.

with this fixed (maybe John is nice enough to replace the one character ;),

#2 lore raw
Quoted 6 lines · Jonas Gorski

The cpu_id is in hex, so it needs to be %04x - not that it matters much since early printk won't work yet at this stage anyway IIRC.

with this fixed (maybe John is nice enough to replace the one character;),

i'll fold the nitpick while merging

John