linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MIPS: BCM63XX: Use BUG_ON instead of condition followed by BUG.
@ 2021-04-24 15:59 zhouchuangao
  2021-04-25  1:03 ` Florian Fainelli
  2021-04-26 13:00 ` Thomas Bogendoerfer
  0 siblings, 2 replies; 3+ messages in thread
From: zhouchuangao @ 2021-04-24 15:59 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Florian Fainelli, bcm-kernel-feedback-list,
	zhouchuangao, linux-mips, linux-arm-kernel, linux-kernel

BUG_ON uses unlikely in if(), it can be optimized at compile time.

Usually, the condition in if() is not satisfied. In my opinion,
this can improve the efficiency of the multi-stage pipeline.

Signed-off-by: zhouchuangao <zhouchuangao@vivo.com>
---
 arch/mips/bcm63xx/gpio.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/mips/bcm63xx/gpio.c b/arch/mips/bcm63xx/gpio.c
index 16f353a..5c4a233 100644
--- a/arch/mips/bcm63xx/gpio.c
+++ b/arch/mips/bcm63xx/gpio.c
@@ -43,8 +43,7 @@ static void bcm63xx_gpio_set(struct gpio_chip *chip,
 	u32 *v;
 	unsigned long flags;
 
-	if (gpio >= chip->ngpio)
-		BUG();
+	BUG_ON(gpio >= chip->ngpio);
 
 	if (gpio < 32) {
 		reg = gpio_out_low_reg;
@@ -70,8 +69,7 @@ static int bcm63xx_gpio_get(struct gpio_chip *chip, unsigned gpio)
 	u32 reg;
 	u32 mask;
 
-	if (gpio >= chip->ngpio)
-		BUG();
+	BUG_ON(gpio >= chip->ngpio);
 
 	if (gpio < 32) {
 		reg = gpio_out_low_reg;
@@ -92,8 +90,7 @@ static int bcm63xx_gpio_set_direction(struct gpio_chip *chip,
 	u32 tmp;
 	unsigned long flags;
 
-	if (gpio >= chip->ngpio)
-		BUG();
+	BUG_ON(gpio >= chip->ngpio);
 
 	if (gpio < 32) {
 		reg = GPIO_CTL_LO_REG;
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] MIPS: BCM63XX: Use BUG_ON instead of condition followed by BUG.
  2021-04-24 15:59 [PATCH] MIPS: BCM63XX: Use BUG_ON instead of condition followed by BUG zhouchuangao
@ 2021-04-25  1:03 ` Florian Fainelli
  2021-04-26 13:00 ` Thomas Bogendoerfer
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2021-04-25  1:03 UTC (permalink / raw)
  To: zhouchuangao, Thomas Bogendoerfer, Florian Fainelli,
	bcm-kernel-feedback-list, linux-mips, linux-arm-kernel,
	linux-kernel



On 4/24/2021 8:59 AM, zhouchuangao wrote:
> BUG_ON uses unlikely in if(), it can be optimized at compile time.
> 
> Usually, the condition in if() is not satisfied. In my opinion,
> this can improve the efficiency of the multi-stage pipeline.
> 
> Signed-off-by: zhouchuangao <zhouchuangao@vivo.com>

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] MIPS: BCM63XX: Use BUG_ON instead of condition followed by BUG.
  2021-04-24 15:59 [PATCH] MIPS: BCM63XX: Use BUG_ON instead of condition followed by BUG zhouchuangao
  2021-04-25  1:03 ` Florian Fainelli
@ 2021-04-26 13:00 ` Thomas Bogendoerfer
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Bogendoerfer @ 2021-04-26 13:00 UTC (permalink / raw)
  To: zhouchuangao
  Cc: Florian Fainelli, bcm-kernel-feedback-list, linux-mips,
	linux-arm-kernel, linux-kernel

On Sat, Apr 24, 2021 at 08:59:50AM -0700, zhouchuangao wrote:
> BUG_ON uses unlikely in if(), it can be optimized at compile time.
> 
> Usually, the condition in if() is not satisfied. In my opinion,
> this can improve the efficiency of the multi-stage pipeline.
> 
> Signed-off-by: zhouchuangao <zhouchuangao@vivo.com>
> ---
>  arch/mips/bcm63xx/gpio.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-26 13:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-24 15:59 [PATCH] MIPS: BCM63XX: Use BUG_ON instead of condition followed by BUG zhouchuangao
2021-04-25  1:03 ` Florian Fainelli
2021-04-26 13:00 ` Thomas Bogendoerfer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).