Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2933836pxb; Fri, 12 Feb 2021 05:25:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXTiPgrKJgThRuf/eFyNk+WF1F57m51Bo4sLVdJeC23eM4K1kXmblDUu9Sq3QvIoSXrBu6 X-Received: by 2002:a17:906:3105:: with SMTP id 5mr3085100ejx.168.1613136301124; Fri, 12 Feb 2021 05:25:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613136301; cv=none; d=google.com; s=arc-20160816; b=caGST+8oZMklV2rPb6Xo+QLkKULx15FCyaf/Ts6bQo7irQmDQblF5lESfqePYupm8/ COhLQPz/W219SxdGu9KZGJLAFAb5iJvyOJaZEKZhZZ9jYamPMYCQQwq9oy7pMiA6VBhE W5zfrLclrJtlE0bzZb8SWas+Swgx+NVpy0TwxfqjMd4YkKPyr9zOsSjr2ngeKZw4Srwu wxoiOBs+Bi2Qc5pqRBuMBByeljNqSJQDo80nNXcTATwKuJYssJiOOeoLlQOludxlOShu 3eKZzZ0OY3YKkOunivQVeg4g2JN2xvjiCfWtyNfTqOu0RoBI97AF1AZWgtuXjwSucrkG 6qcw== 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=O/3BA4PWnT2f4RUSGMom+2MnQBkrppTk3RLQijEPW1A=; b=nNGPqLKUQ+BbH+/2U463xnPXdNRqk0McGdoVZCOYQXxssN8Ns4V1ALfMcgXoJWfB1b AUW6MLpS1P/1wzaJrPsbemqpqrSpYEbKw5ZPW2dowlZ2ZG7M8po7uReAzc5btkwObaHf TZP3jhn7kxdlZbdyespxojM7djgU6Y6Vg/ISB5WyZzU5RxySr0xQVkLuqP+EFVZdwpf2 mvVTuRMSXgcMfY4Kp+TzGuv2Z9smqEcoiekH6DIXCWiK6g1ykzJDCtqePKjFQdY6ldsQ kWGnrcG8hhJ0KNSVriegAAEQ2oYb+qPyDeGDCmzd9fboXyoL33eW2F8GQCupHpF4LJQB lmRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CI5X+Hq+; 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 h24si6856770ejt.89.2021.02.12.05.24.38; Fri, 12 Feb 2021 05:25:01 -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=CI5X+Hq+; 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 S231391AbhBLNXf (ORCPT + 99 others); Fri, 12 Feb 2021 08:23:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231571AbhBLNWH (ORCPT ); Fri, 12 Feb 2021 08:22:07 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C5FAC061574; Fri, 12 Feb 2021 05:21:26 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id gx20so433975pjb.1; Fri, 12 Feb 2021 05:21:26 -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=O/3BA4PWnT2f4RUSGMom+2MnQBkrppTk3RLQijEPW1A=; b=CI5X+Hq+gKpTnweohO4hVWy0QNcS0e/Z1p6h3GGl3SDgUIcmrH2thRXHitu/3yBVx1 w0zKYSoEBxImHtT4h6U8ZqGw+wpkHluw+jlR2oQOBriYBB+9hWC0qYn7bLqyDrVgFrdW C/JXAg+GSJbInwC+1w1spbqz/5Wkhz1PpLj/qbyk9FpFMT92P4FX+reJHzxbGcTv5Ody sgchSZy9OPkf5000p+X/B0o3dSv26eYoR8gfKDUhazlCpzUd58kTi1xRW/5CVOyixkK5 XI1jr+a0XSySYLcHyRCiBrTJ/fmys0THSFrrzIibUfdMyhgOV5k313KrZQSxjhK4P9+t +EMw== 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=O/3BA4PWnT2f4RUSGMom+2MnQBkrppTk3RLQijEPW1A=; b=Twa9rps8+hFGxSBvoJeI8VRMrruGOGlf+KsReZ3msfbxe0taqJAB6xXYkZBXFGloFe QN85JslS+4fQikxDruy47KfIVPBQQt2zUtEhOILCBN3r37Xic+iS8A813UaJyBp3tw7E aCymSnCxr+XPWCYBAiq3kf5Nzbr6N05+pO+Z2+ujY0SaAnHWLS8/GKAHHmlDh4h86NPw KUyPIzEcu2zuf5ctpHgc33H7/RyLl+rOrn6vWrzPhxg9t+Ls3mpyA3Hcw5uFprPorEvJ DhYdg/Fba76hxRksdaX4oqPLnn6Ph3Mzb4eSJwCwScsOj2cHMW9V1cxNUL4FEmQDRluX sD+w== X-Gm-Message-State: AOAM530OmqsWc27wLrIPEFf7Y3s4314noR4vyu6N7ISy8QlJyG9FKjBc /axf8gGIAoZTP3E3Z+/Ih+g= X-Received: by 2002:a17:90a:8c87:: with SMTP id b7mr2807646pjo.158.1613136086127; Fri, 12 Feb 2021 05:21:26 -0800 (PST) Received: from syed.domain.name ([103.201.127.1]) by smtp.gmail.com with ESMTPSA id 71sm9403499pgh.55.2021.02.12.05.21.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Feb 2021 05:21:25 -0800 (PST) Date: Fri, 12 Feb 2021 18:51:04 +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 v2 2/3] gpio: thunderx: Utilize for_each_set_clump macro Message-ID: <3fc5bd83322c94eb2a4f48677f6d762bf81d0652.1613134924.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_clump 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: William Breathitt Gray Cc: Robert Richter Cc: Bartosz Golaszewski Signed-off-by: Syed Nayyar Waris --- 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..0398b2d2af4b 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_clump(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