Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp479082pxb; Sat, 6 Mar 2021 06:08:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKvjkmUkXs1nGWgWBZTnqvwQeTC7zN0XszvQUZULJt69broB5htb2J8C86b28D6IuMDrwi X-Received: by 2002:a17:906:d9d1:: with SMTP id qk17mr7086600ejb.52.1615039689521; Sat, 06 Mar 2021 06:08:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615039689; cv=none; d=google.com; s=arc-20160816; b=mYQvIXAEsPcC9Nyup95bGLmE4L0zvZ3n3a2fxeLkresW1WBhVG2otdxVamCw2UudaC zIgnohlZtCGDnLU/3yPBz/ONrlIQ/oIT5GEEtJTiDFKyEUzHrWvYVYv2cSmkUKKjoGDz f/45bGDEPrhDhjTCQx2DulPXhyNruf0iOguJccXurcGCOXPAmhM7HUAPGhQO0xQWJ5Ky 9l4+grXn6zb/aIQpL+NUR62uqk+tIV0s/63FpHt4R3sqWWkcRIMmpnLqr4xdzjSDoR/3 tN6x/0j8g+U37KhbepQuWEkZnBkWIzUfh+qlBEn5/hqdMsUKXp4mEHHDBnwKzY8TgR8Z 1jhA== 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=CyhLW/AJRQDK2QV7oXEwpTSnAecym6sEON/7BVWarzBJ+OqaAs/qjhXrSDgGzmJcpe K+eNvIZzyCq5tNNttlrHz4sO3AKX0WG2yVArzjiF+gYRb84tQErNpZZmpirV0P2rIRbx ESBldL+xkb5gUecUYa2QynRceZb7TTdevqRe5a7f0EtPZqTkpNSZSywa9dxf6rif9IfE G9gijnsqxVdreIklzBfqaBrXIEdGz9Yj9NySFuJT6VUEVWbNurn78sjFvP858I/0xzLe vxtMH2oDCB41DeG6b/oA68EYe/zGepF2+b9K3Cag2eWrj/cPp+je7C4eHONCh7DU/sg4 ai9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=U2dKt8r1; 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 j7si3330942ejx.732.2021.03.06.06.07.47; Sat, 06 Mar 2021 06:08:09 -0800 (PST) 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=U2dKt8r1; 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 S230322AbhCFOGS (ORCPT + 99 others); Sat, 6 Mar 2021 09:06:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230523AbhCFOGI (ORCPT ); Sat, 6 Mar 2021 09:06:08 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91051C06174A; Sat, 6 Mar 2021 06:06:08 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id a4so3321514pgc.11; Sat, 06 Mar 2021 06:06:08 -0800 (PST) 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=U2dKt8r15x6xUAhghcKyWldESLJ+JznFIoFYGd07CPrypf+p0aU5j0naQ92c7rEnSz gOI6IkxzWLAd0SDJVUKfcRQ4U2QjHyIkbRRhgJyZZtu9b5OTri115mV1W/ZH60C/e0l7 fPDhbAsJxfnRsLJ7Hcg8+QW5lriKOQuzP3iUKDjOAe/MM00ydVMRq9PzkFFdnvAWTTb8 WuTp9s6FIOTYhmv8DsQMUgE0+X1Xckm4RKIqgWdo22rZc2BM3Ek9pOKWgxzgCMGi6FTu xjRU3IN8LRbwASa/3jB7UKZOHRHtIbYP4ZIdYYkNd1OUfQ1SaZc5iwRmX9hS/bSCo8Tq HdAA== 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=makuOH23BNVsCWReO6TSc0jUCnAmgcxVKgMy6ni76YRdHRMFTKp5oF6Q9IMv+iSrQq Iq2ksUcBaVc0H/a0pvUiUw7EAO/sC7ZDkV5b/wBIAYN1+0dDLGvdFTxADxs4shsS1FM2 VFpv03lTQ3CkSv6M1KtfQa0/fofCQg961/MjPoUgpjcRN5xgTIfqTldYPppckaDd6d+O J83dPWpTIeP3nLrxvNJr78fFFGiKGpyvGPJ2IKCys20ao01sUNehlKbpxS+4vY7GvOXf xyeFgA382tEdW+FkPdwnlSOeU31AL+S44kSwmcv8Cd/PGxyZTJSgzkNdYGMb6RAnGZzP 0LXQ== X-Gm-Message-State: AOAM532eLMu7dH478YsZif2wBCZ40aUTJDCGw4pafDVn9GWvr1kAfg8w 2W+cDqFQAGLTIErtlQctv0k= X-Received: by 2002:a62:3c4:0:b029:1ee:9771:2621 with SMTP id 187-20020a6203c40000b02901ee97712621mr13166864pfd.47.1615039568194; Sat, 06 Mar 2021 06:06:08 -0800 (PST) Received: from syed.domain.name ([103.201.127.38]) by smtp.gmail.com with ESMTPSA id w4sm5688111pjk.55.2021.03.06.06.06.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 Mar 2021 06:06:07 -0800 (PST) Date: Sat, 6 Mar 2021 19:35:53 +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: [PATCH v3 2/3] gpio: thunderx: Utilize for_each_set_nbits macro Message-ID: 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