Skip to contentSkip to conversation

pinctrl: bcm2835: Replace BUG with WARN_ON

PATCH In review Jason Wang 3 participants 3 messages Jun 24, 2021 – Jun 25, 2021

Subsystems (4)
lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH v2 1/1 pinctrl: bcm2835: Replace BUG with WARN_ON

The if condition followed by BUG can be replaced to WARN_ON which is more compact and formal in linux source.

---

Changes in v2:
Accept Florian's advice to replace the BUG_ON() with a WARN_ON().

 drivers/pinctrl/bcm/pinctrl-bcm2835.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +1 -2
index 2c87af1180c4..8440c722f6f8 100644
@@ -416,8 +416,7 @@ static void bcm2835_gpio_irq_handler(struct irq_desc *desc)
 		}
 	}
 	/* This should not happen, every IRQ has a bank */
-	if (i == BCM2835_NUM_IRQS)
-		BUG();
+	WARN_ON(i == BCM2835_NUM_IRQS);
 
 	chained_irq_enter(host_chip, desc);
 
Signature · 7 lines
2.31.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#2 lore raw
In reply to Jason Wang

Hi,

Am 25.06.21 um 01:51 schrieb Jason Wang:

Quoted 17 lines

The if condition followed by BUG can be replaced to WARN_ON which is more compact and formal in linux source.

---

Changes in v2:
Accept Florian's advice to replace the BUG_ON() with a WARN_ON().

 drivers/pinctrl/bcm/pinctrl-bcm2835.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pinctrl/bcm/pinctrl-bcm2835.c +0 -0
index 2c87af1180c4..8440c722f6f8 100644

drivers/pinctrl/bcm/pinctrl-bcm2835.c static void bcm2835_gpio_irq_handler(struct irq_desc *desc) · line 419

Quoted 6 lines
drivers/pinctrl/bcm/pinctrl-bcm2835.c +1 -2
@@ -416,8 +416,7 @@ static void bcm2835_gpio_irq_handler(struct irq_desc *desc)
 		}
 	}
 	/* This should not happen, every IRQ has a bank */
-	if (i == BCM2835_NUM_IRQS)
-		BUG();
+	WARN_ON(i == BCM2835_NUM_IRQS);

whenever this should happen, the source of this interrupt cannot be determined and acked. So it's very likely that we end up in some kind of interrupt storm. So i suggest to use at least WARN_ON_ONCE().

Even worse the value of variable "group" is uninitialized in this case, so maybe we better return immediately after that.

Regards

Quoted 3 lines
drivers/pinctrl/bcm/pinctrl-bcm2835.c +0 -0
 	chained_irq_enter(host_chip, desc);