From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 57781C433B4 for ; Fri, 23 Apr 2021 08:30:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13F3E61458 for ; Fri, 23 Apr 2021 08:30:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241448AbhDWIbM (ORCPT ); Fri, 23 Apr 2021 04:31:12 -0400 Received: from mail-m118208.qiye.163.com ([115.236.118.208]:31558 "EHLO mail-m118208.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229917AbhDWIbK (ORCPT ); Fri, 23 Apr 2021 04:31:10 -0400 Received: from ubuntu.localdomain (unknown [36.152.145.182]) by mail-m118208.qiye.163.com (Hmail) with ESMTPA id 26CBCE040D; Fri, 23 Apr 2021 16:30:31 +0800 (CST) From: zhouchuangao To: Thomas Bogendoerfer , Florian Fainelli , bcm-kernel-feedback-list@broadcom.com, zhouchuangao , linux-mips@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] mips/bcm63xx: Use BUG_ON instead of if condition followed by BUG Date: Fri, 23 Apr 2021 01:30:21 -0700 Message-Id: <1619166623-70445-1-git-send-email-zhouchuangao@vivo.com> X-Mailer: git-send-email 2.7.4 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZQ0pKT1YeTEIZQxkaSxlLTU9VEwETFhoSFyQUDg9ZV1kWGg8SFR0UWUFZT0tIVUpKS0 hKTFVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MDo6HSo4GT8KAgxKDCscAjAN Nj0aChlVSlVKTUpCSk1NTUhKTUNJVTMWGhIXVQETFA4YEw4aFRwaFDsNEg0UVRgUFkVZV1kSC1lB WUhNVUpOSVVKT05VSkNJWVdZCAFZQUlJTUo3Bg++ X-HM-Tid: 0a78fdda159d2c17kusn26cbce040d Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4454C433ED for ; Fri, 23 Apr 2021 08:33:15 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 48716613C3 for ; Fri, 23 Apr 2021 08:33:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48716613C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=vivo.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=7bl96+PFCYmGepK3gfoTFB1ELRk/ZvOu7BZQk7pYxtU=; b=hlM8q7pQALth6jv9WI2H4SeLpH JRz/OZIpAgMPDTDU9UVCxVNr1otv4pOSxam9/GthrWE1+PtGPgVhS4QuVcgVqPlpVunj8Irnvaw2a TxeDOQve4w+sR9cSgsJLZfXOuqI6d+4t5CzCsO2QGltaUjdqt9GAnL72ExEgiqmnQ8Uem9lyxlQlA zOJbm7B3nXZJtzLimiNoqwGoq353BgL7nmKza8wAJQRUbltSd4HJOEEjnLPy4kYFRrrwhk/Cl6MRd yF/7tsPjjH2j5d+rmef1igQZ9KQmEjZWkkRSFRZdOrIBoQO+gJQuSPrBJWCQli7sdOhUxMSrdKwhJ nhreyp6A==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZrDS-0013jw-Ks; Fri, 23 Apr 2021 08:31:10 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZrCx-0013gp-5U for linux-arm-kernel@desiato.infradead.org; Fri, 23 Apr 2021 08:30:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Message-Id:Date:Subject:To:From: Sender:Reply-To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To:References; bh=BsDrlD6UyMfVKktYtGnIvExz7HVESSZguHJRXitZzJ0=; b=Ewt2ZYnGgHP3p5rdFkOqiCZJGq 1cKJtrZvmjXIPORphTRglQYgbXXKCbwLkaKir7ecrpSnq2cMXLrNe7K2+CsffttCKFsoLzczgeJhR OPbQFG8XlSOsX8C/RRWCYweKUGLH92TLduKaAsgneiiih7QTcHJD5u+YH1Nguk+nOMwqTrGaaj9Mn kfWDVjwAUCxNxuzRVHfF/bqTAZmIokOp+3EDEgA0UaFTdb4GCSbPhwI4BNcLNTW9AaSkwth7xFq8D kLIwc+kw8eU9c81Fkp5Q15hle0UixwjSHxyqp5LJr8aVyEHVbOVTt+kqrg/1Yk8j9P0wLIUmuAfXw ns7vNqug==; Received: from mail-m118208.qiye.163.com ([115.236.118.208]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZrCs-00EFyh-AW for linux-arm-kernel@lists.infradead.org; Fri, 23 Apr 2021 08:30:36 +0000 Received: from ubuntu.localdomain (unknown [36.152.145.182]) by mail-m118208.qiye.163.com (Hmail) with ESMTPA id 26CBCE040D; Fri, 23 Apr 2021 16:30:31 +0800 (CST) From: zhouchuangao To: Thomas Bogendoerfer , Florian Fainelli , bcm-kernel-feedback-list@broadcom.com, zhouchuangao , linux-mips@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] mips/bcm63xx: Use BUG_ON instead of if condition followed by BUG Date: Fri, 23 Apr 2021 01:30:21 -0700 Message-Id: <1619166623-70445-1-git-send-email-zhouchuangao@vivo.com> X-Mailer: git-send-email 2.7.4 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZQ0pKT1YeTEIZQxkaSxlLTU9VEwETFhoSFyQUDg9ZV1kWGg8SFR0UWUFZT0tIVUpKS0 hKTFVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MDo6HSo4GT8KAgxKDCscAjAN Nj0aChlVSlVKTUpCSk1NTUhKTUNJVTMWGhIXVQETFA4YEw4aFRwaFDsNEg0UVRgUFkVZV1kSC1lB WUhNVUpOSVVKT05VSkNJWVdZCAFZQUlJTUo3Bg++ X-HM-Tid: 0a78fdda159d2c17kusn26cbce040d X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210423_013034_528557_5C8C0BD1 X-CRM114-Status: UNSURE ( 8.28 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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