From patchwork Fri Apr 2 16:36:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Syed Nayyar Waris X-Patchwork-Id: 12181325 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=-12.2 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 BC3E8C433ED for ; Fri, 2 Apr 2021 16:38:43 +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 5CC6961155 for ; Fri, 2 Apr 2021 16:38:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5CC6961155 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NzUwajGbAmDIMMXTcVDQHa9tlOxFWTn1yiuXA+/pc9I=; b=ojm4VVfEnxcbP36IWsokh5G+f TvGAu84cIXvQTRi10weftpWi4VoNbZYqqxrHFPyeLFBoo5HQDN0To2EVel/zPcgRpttrirRMMNH9l 7Mvm+NaqmXbYTQoL42+MrTcAfb7mjV95OZQpv+jAOyfd4XgAN/Ot5kOunFw+LHPL0u/4vtFP6eHRV Y/b+NgCQmF2Dk50Pt3/+j9n6u4Gs7XubYPXYzvUeOT0+833ha8T0XJUDrPFMHbCiUz+KN+e0U2eAK Bg6bU6bpZzsXTLwSS4xX/d5dP25CTf5A0Uq1QHVYzjxnnfq8kavT23DtpXYllAADj0APO8AT+5OT1 YQVLEXI/Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lSMnH-00DOwC-CV; Fri, 02 Apr 2021 16:37:11 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lSMnC-00DOul-Ec for linux-arm-kernel@lists.infradead.org; Fri, 02 Apr 2021 16:37:08 +0000 Received: by mail-pl1-x633.google.com with SMTP id e14so2748475plj.2 for ; Fri, 02 Apr 2021 09:37:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=pjJTs/trNbCfk/Wd5AeG0sctmtT3vopPWM58p/JWi08=; b=rniiW33V+k97vWR8A63gBXFhFoayK+VhrSPyN1QPh9Q05cqI9iknScGDIOHhzW37Q3 E9Yeo9XdchviKP8uebuKKVt6GzcbpKPZ325d3bjBTCpPdvbGtgZPVghMQNxYDEW/wsAr JRtIPcxsd9klpDnHOdoxgmSv2jYQEJaSa1txLdmw3oyj+gLMyJojW8ltMvoKHWB4yjIb WzuZMPiVA6tDbreMXiSoHzko92sLTCW3oKyE3A59LT2zBCBH3dItDq8zS5ZH+kitDXle JYAx/1dLyBGTl0mP/EPhQbsrcx6tl14JBk2PPq636maGraNQ/llDWmpeDKMswZ/xCTqU 5zKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=pjJTs/trNbCfk/Wd5AeG0sctmtT3vopPWM58p/JWi08=; b=SEOhnLnZ9lHmTAcKAPv8NIS4O6FwQORnesefDl3yC+PR8Vtxj/xY710qUDtsZzAVKv WseD/vAXeqjqU8qOZ18zJkYolAdyjiMSz59bpEUcsm2ufkWBfm3HSD3CFgQ48MrZRnKo A1dWy55shvDhqIdA7oH3RAKmJ7Mk8DUDx3j5Hz1X1WZ+RR1Zv8p23AxYIBgeDPzjAR0o ZA94ulA0JsCY6Dy6BUcaALbo9DdvJ4VpH+UY+zdutS6OpaB5Ri+4sHelaeKsaibkkfq0 tCpp+tP03MVN2okn4umIqCzxyJ6uTNbdC9HB0oJAavdMxtcPsbbb+nB2uVNBHeKAlC0O dOuA== X-Gm-Message-State: AOAM533mJSy6n5apWXNtlcyIDBzFQ7qYwDbdCVvuvTuqoCvCf9/IyDa8 Qx2iA6jJMxCTloCPNq2BPvYKFGbOhhvyWA== X-Google-Smtp-Source: ABdhPJz1n7/WaQ0+zG3NLK93leEDb2jZHXIhU7HWtvH1pbg2UjdBAdvabxAjuykg5CqXPqw5r+36CA== X-Received: by 2002:a17:90a:a613:: with SMTP id c19mr14848896pjq.141.1617381425020; Fri, 02 Apr 2021 09:37:05 -0700 (PDT) Received: from syed ([223.225.109.149]) by smtp.gmail.com with ESMTPSA id 23sm8698123pgo.53.2021.04.02.09.36.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Apr 2021 09:37:04 -0700 (PDT) Date: Fri, 2 Apr 2021 22:06:48 +0530 From: Syed Nayyar Waris To: bgolaszewski@baylibre.com Cc: andriy.shevchenko@linux.intel.com, vilhelm.gray@gmail.com, michal.simek@xilinx.com, arnd@arndb.de, rrichter@marvell.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, yamada.masahiro@socionext.com, akpm@linux-foundation.org, rui.zhang@intel.com, daniel.lezcano@linaro.org, amit.kucheria@verdurent.com, linux-arch@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: [RESEND PATCH v4 2/3] gpio: thunderx: Utilize for_each_set_nbits macro Message-ID: <3a9bd0a593798538bec54d8b5ceab20a73d7eaa1.1617380819.git.syednwaris@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210402_173706_706696_91AC37DD X-CRM114-Status: GOOD ( 15.58 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch reimplements the thunderx_gpio_set_multiple function in drivers/gpio/gpio-thunderx.c to use the new for_each_set_nbits macro. Instead of looping for each bank in thunderx_gpio_set_multiple function, now we can skip bank which is not set and save cycles. Cc: Robert Richter Cc: Bartosz Golaszewski Signed-off-by: Syed Nayyar Waris Acked-by: William Breathitt Gray --- drivers/gpio/gpio-thunderx.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c index 9f66deab46ea..4349e7393a1d 100644 --- a/drivers/gpio/gpio-thunderx.c +++ b/drivers/gpio/gpio-thunderx.c @@ -16,7 +16,7 @@ #include #include #include - +#include "gpiolib.h" #define GPIO_RX_DAT 0x0 #define GPIO_TX_SET 0x8 @@ -275,12 +275,15 @@ static void thunderx_gpio_set_multiple(struct gpio_chip *chip, unsigned long *bits) { int bank; - u64 set_bits, clear_bits; + unsigned long set_bits, clear_bits, gpio_mask; + unsigned long offset; + struct thunderx_gpio *txgpio = gpiochip_get_data(chip); - for (bank = 0; bank <= chip->ngpio / 64; bank++) { - set_bits = bits[bank] & mask[bank]; - clear_bits = ~bits[bank] & mask[bank]; + for_each_set_nbits(offset, gpio_mask, mask, chip->ngpio, 64) { + bank = offset / 64; + set_bits = bits[bank] & gpio_mask; + clear_bits = ~bits[bank] & gpio_mask; writeq(set_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_SET); writeq(clear_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_CLR); }