Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp7624199pxu; Fri, 25 Dec 2020 22:46:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzLyhCT7QpEhoRvzkB3cr4c12dd9wZZGJBhtmi8yyjQcWbOCjGKmWYQ+t3LQUUVCjR4b7WM X-Received: by 2002:a17:906:2b1a:: with SMTP id a26mr15438129ejg.23.1608965209301; Fri, 25 Dec 2020 22:46:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608965209; cv=none; d=google.com; s=arc-20160816; b=eNNUkdaSovvKv4eV1fq3x8FaapvbOy3F/NY5RZbqUp1WrTP49EJZvabybunncioPTN b+y8EC/OEfbWg3wJF/ORl1/0nRtPxYIo96XgNmV90jU9VuX2IknEIa5EHb4haS8dMghX 34j8GYe3du8fAqnK8uQslugJWjvp2lUNNUIhiX70UhYPOYjXvnGf6tXA0BynaMIvXWFp mEeRsbK9Q3pUBSWM47+l2KbTMiRAN4T5FuE7Uuk7KblVPWR+IKcydk8kGvvFWkMOXpeQ 7+PPSdVWHcq+xq460MdYUZmZ6EedQhZ9sR+USfxK+Jqt1O7osesAEuQhHcinafedvmKU fYfQ== 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=iXNqUNlDxA192iSDhXK8T34CWCe+lAvUgPxne7auzLU=; b=B7smp64i7OhOMPjzgUtwbG8uU7ZhbkigUQ+UZeHmm1B7JN9k6JvnaztD77RuZHn3Az nBucQHCjVgYlKxKj8R1igFy4L9kiAWVQrsa4mShQMrJ8hwemQBOWGG59gwFw6cDswbs9 pFPaouwUpvrnDN+TQgNLdZVsItvI3BMeeXNplO5Z4NEpiARIoqte9f2+i7nABwbFsYmi SnJ/ogwukzFFWWqo+jWw+C83CIxwDm5hJ6XlI7Uqm7qmo2uW9yBulaPvrJt6pjVw6aVC UvkQokYYAhPRzcAtaS9y5s98LcgQTEmNA3NGjbd90dcH5s5FiX50S6ZcD0WV2lgPaWli rVKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X3VqkGTt; 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 hs8si15864265ejc.113.2020.12.25.22.46.25; Fri, 25 Dec 2020 22:46:49 -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=X3VqkGTt; 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 S1729304AbgLZGo5 (ORCPT + 99 others); Sat, 26 Dec 2020 01:44:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbgLZGo5 (ORCPT ); Sat, 26 Dec 2020 01:44:57 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9ECCC061757; Fri, 25 Dec 2020 22:44:16 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id f14so3324967pju.4; Fri, 25 Dec 2020 22:44:16 -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=iXNqUNlDxA192iSDhXK8T34CWCe+lAvUgPxne7auzLU=; b=X3VqkGTtPHgY1bRWcNfIIEzEkd4CnRBVwL6y4V5NGTcXyshWxpSPWcwaHQU8OKHq6B yBpnK5X5s/GS0m91eQwyqhsBGtP3KFY5xpHkasoNxDOsGuajYXohFFWto5HX2wHOfyz6 W8YvxplDXEFPL3eb5vXxsoD7GZ8hUqYo7ClG/2qpwlTFEzayzUR9sNvZlyckR2Z2S59r 7FQO44kuK+Y/v/K0F6Rqei6vBf+rVPeMM3rCOUzxlS5eHYGQ/lVOcrm4y32oxnzB9D3H UmtXExLbDEPjcAVKVEGRSYCfj3yJwOkw/ODwlHCoEcawrRfmC3TUQIl2D6kI8gU4kCba sLIw== 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=iXNqUNlDxA192iSDhXK8T34CWCe+lAvUgPxne7auzLU=; b=rIMeG6kcMrJJV37Tf2Ex1iEMgGbwKQhDeFW/8QNgkqbHf6x/vu8/8sbDnZNEzgZC85 vLQXt0bEwcvMBpDacQI9vA5rJzTYpxwmpv6+Lb/uZSC2L2JIkhWIZw6h523vis+P+31c 87Oh44+IhmAeNT6hPCeDt6MyXYcZHXXAuMgGwu5ct+WMyCpC/r+O+1d3JcAqdpulELOx zY65+YcE3uxqx3QbnZ+1VmHb5226jg9AvYFcFeGBCv3bCtJJJ9l0nwJ42A5U3PPX2SSt c2oAssOZxxsaFKlY6RI+T2UqpsYh2S2v1by97UzINFZ+PjT/S5jhsYi7z+hdeG5RxFbn feeQ== X-Gm-Message-State: AOAM532qlsvo2i5pkUt9snj09/0+WEO+CXHCzzZ1UcCfyYnD8xiEdn3Y vkvL9jVq9cIzYh+ty1VUQys= X-Received: by 2002:a17:90b:128a:: with SMTP id fw10mr11311388pjb.113.1608965056485; Fri, 25 Dec 2020 22:44:16 -0800 (PST) Received: from syed.domain.name ([103.201.127.53]) by smtp.gmail.com with ESMTPSA id r185sm30254706pfc.53.2020.12.25.22.44.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Dec 2020 22:44:16 -0800 (PST) Date: Sat, 26 Dec 2020 12:13:58 +0530 From: Syed Nayyar Waris To: linus.walleij@linaro.org 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 3/5] gpio: thunderx: Utilize for_each_set_clump 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_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 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c index 9f66deab46ea..716b75ba7df6 100644 --- a/drivers/gpio/gpio-thunderx.c +++ b/drivers/gpio/gpio-thunderx.c @@ -16,6 +16,7 @@ #include #include #include +#include <../drivers/gpio/clump_bits.h> #define GPIO_RX_DAT 0x0 @@ -275,12 +276,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