# \[PATCH v2\] pinctrl: bcm2835: Replace BUG with WARN\_ON

- Subsystems: PIN CONTROL SUBSYSTEM, THE REST
- Maintainers: Linus Walleij, Linus Torvalds
- List: linux-arm-kernel
- 3 messages, 3 authors
- Page: https://ratatoskr.run/linux-arm-kernel/2021/06/8808907/t

## \[PATCH v2\] pinctrl: bcm2835: Replace BUG with WARN\_ON

- From: Jason Wang \<hidden\>
- Date: 2021-06-24 23:54:30 
- Message: https://ratatoskr.run/linux-arm-kernel/2021/06/8808907.md

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

Signed-off-by: Jason Wang <redacted>
---

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(-)

diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
index 2c87af1180c4..8440c722f6f8 100644
--- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
+++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
@@ -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);
 
-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
```

## Re: \[PATCH v2\] pinctrl: bcm2835: Replace BUG with WARN\_ON

- From: Florian Fainelli \<f.fainelli@gmail.com\>
- Date: 2021-06-25 02:39:04 
- Message: https://ratatoskr.run/linux-arm-kernel/2021/06/1425512.md

```text


On 6/24/2021 4:51 PM, Jason Wang wrote:
> The if condition followed by BUG can be replaced to WARN_ON which is
> more compact and formal in linux source.
>
> Signed-off-by: Jason Wang <redacted>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
```

## Re: \[PATCH v2\] pinctrl: bcm2835: Replace BUG with WARN\_ON

- From: Stefan Wahren \<hidden\>
- Date: 2021-06-25 10:50:19 
- Message: https://ratatoskr.run/linux-arm-kernel/2021/06/1425902.md

```text
Hi,

Am 25.06.21 um 01:51 schrieb Jason Wang:
> The if condition followed by BUG can be replaced to WARN_ON which is
> more compact and formal in linux source.
>
> Signed-off-by: Jason Wang <redacted>
> ---
>
> 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(-)
>
> diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
> index 2c87af1180c4..8440c722f6f8 100644
> --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
> +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
> @@ -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

>  
>  	chained_irq_enter(host_chip, desc);
>  


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
```
