Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1154258ybz; Sat, 25 Apr 2020 12:10:39 -0700 (PDT) X-Google-Smtp-Source: APiQypImCFdhYt0z71RYrtgzo2Cr0AGONThKnPzz+Y2ed8o4As5W39fQH8u2VivHRRuNhotthvaq X-Received: by 2002:a50:d942:: with SMTP id u2mr12818162edj.116.1587841839078; Sat, 25 Apr 2020 12:10:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587841839; cv=none; d=google.com; s=arc-20160816; b=dJ/Gm79PZyu1hOdSp3ti4cLT29GMw4iM6slm1ESDS0LOnlTgM4YxDoz9+qqGTRH6cT l8JjNceO/pEteGtl7h0/A96nUl6uiITIg/zqA7fHIPQ60emN32I+dVpwMStI8BWGES0x dtajMIvqkkyFemMmtzAgm19cN3bkvw5YCT6HakpMAfW07hfE1BFnVid0EkGAy7CiuiqK PPiI+xwmXW/sNR+2utwEWzvDf3XCEogWSH8YUdMRPxKeWDtqq3A5eJuFPydDI2nAz5Ad vHMah5VBkfoIIXlUT5/Yp8xLrHpNrBUErt4SKzXpa005YMGXieutPIyF98uvZxmMIBPD BvRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=mYq1a4v7y77AQ9tmnkT5t//UsJP+CbO9qCNT3hZp18k=; b=ofS3dYHd2lm9TacM1vL+EDg4/bgMJ+qtGvzmG1s+iiAtSAADyxQTJwSA76t1/0bYBW PpYqSUA7y71XliRCUXnuWoqNNcBPNYnmK4/5INnldKuL2WUOypv1cv5ohaEJeiSjFi5/ oov6LnaaMOVRc3jppiLOs0Nv3UXCsXC1jH69Xdm6WqoJPwbV5nLPEDqzeWgPAA0h6NI5 t9eS7+VQ8c2yzloW9BfQUJWTqzCmOtnemlr4VpRSsZbx6oLMp2TDjr5dQS702Sz+OhVq nTGY02edFJv7rSldOLJyfenfv2l6IxjqNQUhQiqPhjyTJGHjhmRyIxdJRmPtn0udvYMS FqIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Aa/FIfSq"; 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 p1si5429766ejw.313.2020.04.25.12.10.15; Sat, 25 Apr 2020 12:10:39 -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="Aa/FIfSq"; 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 S1726398AbgDYTGb (ORCPT + 99 others); Sat, 25 Apr 2020 15:06:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726192AbgDYTGb (ORCPT ); Sat, 25 Apr 2020 15:06:31 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 330C5C09B04D; Sat, 25 Apr 2020 12:06:31 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id n16so6348868pgb.7; Sat, 25 Apr 2020 12:06:31 -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=mYq1a4v7y77AQ9tmnkT5t//UsJP+CbO9qCNT3hZp18k=; b=Aa/FIfSqjGH+gUHaFd/hbJ6DRqi6NYSRUbYh/SDyvKyP0lwa6JfjAIJc9xCmdw4KXe 6q/MHL5cFhXg5j8Do7SoXVitpMpfWz+o4RkS6OAwakrxa2tUf/dZ8lrgo6eglPj8RzaY ohS4lx2/tJ+NmGHMOFaTsaSFbQfghLpwYa7Sma2KhRX3iq8tIxb3x5OmWewv48cdNkNt ZBLLN3S9flUeifjqjicpymmOOVqIjkjVaSU2MhzsllXi+LjtZCLJLOENSQ0cY9aXI9L5 +9KEJZp5xV0jIipFm2mo4NdqdPxQrewg/KmuXsCXRnp0hiw4UonYoNbD5w8a4AM7g7WZ gukg== 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=mYq1a4v7y77AQ9tmnkT5t//UsJP+CbO9qCNT3hZp18k=; b=HSX0zCzu2D2ManIBXUIjU0rYMsjYw4y/MTiywpFx4ajfgw3cTJGfnSjT1X45MdWpnJ HUDv7XFnotWRmqI6jNGfOmV5N+apGT79X8lNTIVpMXxVBRlwyHYHARklpgadGUdspehe 2Vhkn1SCIfWCtrzW5fCKqT2L5LW6Cwjgy51ecNnMUWgIFSq1ni+JYXTyDkuIeMY4Wt3v Nk3/KXBoXmkOS+/gPoNKN6EAxLpIY3EDUPG2Zi+8pgAamJJ93QAK6npllemGXp4HmJ5S bUM3P3gZGhYebaJhvk3A0ZOg3Hz54tjjbowjusCfLZoM3bp61B7UWSUToHiWNBzDdoJ5 nx0w== X-Gm-Message-State: AGi0PuYP3U2/KBI07aEYXONVX8jZztMPUbaBRJBdqOJoBC21xfV5CzqD WpsoeN12yP+LxPSUfXuCOys= X-Received: by 2002:a63:1806:: with SMTP id y6mr14753725pgl.407.1587841590766; Sat, 25 Apr 2020 12:06:30 -0700 (PDT) Received: from syed ([106.223.101.50]) by smtp.gmail.com with ESMTPSA id b1sm8491327pfa.202.2020.04.25.12.06.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Apr 2020 12:06:30 -0700 (PDT) Date: Sun, 26 Apr 2020 00:36:24 +0530 From: Syed Nayyar Waris To: akpm@linux-foundation.org Cc: andriy.shevchenko@linux.intel.com, vilhelm.gray@gmail.com, rrichter@marvell.com, linus.walleij@linaro.org, bgolaszewski@baylibre.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/6] gpio: thunderx: Utilize for_each_set_clump macro Message-ID: <9c5e25b982728467c5c681876d0e60e49dedb5fb.1587840670.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) Sender: linux-kernel-owner@vger.kernel.org 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: Robert Richter Cc: Linus Walleij Cc: Bartosz Golaszewski Signed-off-by: Syed Nayyar Waris Signed-off-by: William Breathitt Gray --- Changes in v2: - No change. 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 9f66dea..74aea25 100644 --- a/drivers/gpio/gpio-thunderx.c +++ b/drivers/gpio/gpio-thunderx.c @@ -275,12 +275,16 @@ static void thunderx_gpio_set_multiple(struct gpio_chip *chip, unsigned long *bits) { int bank; - u64 set_bits, clear_bits; + u64 set_bits, clear_bits, gpio_mask; + const unsigned long bank_size = 64; + 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, bank_size) { + bank = offset / bank_size; + 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.7.4