Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1406234pxf; Fri, 2 Apr 2021 09:38:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRhIJw5VAa/6cUVLCZaGFZn6Xv+5y7lTKQj25/m9QnH6cVbJt8KsLvBRPLft5Jh1IcSa3d X-Received: by 2002:a17:906:b846:: with SMTP id ga6mr14689550ejb.542.1617381504828; Fri, 02 Apr 2021 09:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617381504; cv=none; d=google.com; s=arc-20160816; b=NylJapENP0ObQjWAe0s8qqBHQN8j7e5JOnh+m//pllZ609ZsmPekrVhbX4zsabSCY1 7kCDwsiRfGTHn+0MkjZKcRrhRjOgGk++aiKNA63XMof60hIZkeHE9gEU7+htjfBc/0Ds SGKDNV6kb1eUxRyXjqGu5+ULOViLgpqJWAbL2P0V4EsTcB1m+xbwgr800597QoyZbG9x FYIpF3lfdS3CZYYWaV4lnAj1qQA8djPmqYUA3OgsI1DtVZ9WodfpDjMQz5+iI6UbDyXC qkCI8BqhfBchUfL0BjzdswPSohdGC6kwZOqRe9CGrpPUqmyTJfO3MSM73jw8KizT+PYy TOnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=pjJTs/trNbCfk/Wd5AeG0sctmtT3vopPWM58p/JWi08=; b=F8sYsp6qYJCQ64TMawjrAolJRjW9bHnEFRxkdwosij1p4MugNnn5cG4ZghYAbVhFW5 FRvvQ9qoBzTZOw7+LEjX3iAAlUF7VsJSrG0OXtrkj1ERUrn4RBNvcpumfw9HewI6GmpN Xo8MM6RDr4yTlgVPi6GSkYo5bAuL+UkB1/J6qvA1JwXpY4Dggtiz1iKCZkgyIenTiAnN aSaT4ADOvzcSeC0u/YzgcuqgsGuJW1EEET235P/rsOTLETQU8rF46N3SqZMlHyh9fvLj 34InzE5Ye3uC+gas29ZPkcsZhG3OSur9Jp0LzNA96ljdV0WQ+Xf2rpfFmGNyyrjm/C4K Mh9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rniiW33V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c18si6787771ejr.332.2021.04.02.09.38.01; Fri, 02 Apr 2021 09:38:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rniiW33V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235122AbhDBQhI (ORCPT + 99 others); Fri, 2 Apr 2021 12:37:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235243AbhDBQhH (ORCPT ); Fri, 2 Apr 2021 12:37:07 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CDA5C061788; Fri, 2 Apr 2021 09:37:05 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id t20so2717605plr.13; Fri, 02 Apr 2021 09:37:05 -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=Zr7vwEDEHwzXzhIKErWlNt5RWJGqv7DpHyWQMgyob6FnsNPDxwB1IUGYRxtzZLjhuc x7LCh6h4R/WhvgKq8fvSA7R+dE3FkNhl0wuu1VFCWu+9mDdX8opS6R6O2ekFamN38/Dp B5LLFkZktLRPdjlhBCVG2AsuV0Vn9sT9cATc7wuN4Jl/U5ncHvBVA9bk5WNRfiUj9wCS 709x3IrxIY5N/ebLoY71kVftp74Zmh1kbLBRvXcoaqQaJpacF94K5w+7uZbwGNQ3lss3 0wrXxUYedowwDJQYL2dUlSakb7PEuTWP33HUdbAXp15IPTPoFahUiitf4DFd8tXt5a5i 5I/w== X-Gm-Message-State: AOAM5313Ap7+gyHr+8EaY4oiLLIkHjlkbAot7drvW2EMV6vqQacsKRXX TuxXD+52mz6JutB5oT1Z6xk= 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); } -- 2.29.0