Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1968447ybz; Sat, 2 May 2020 11:54:45 -0700 (PDT) X-Google-Smtp-Source: APiQypJCNU0Qs1TGWznD8nvtC3ckm40wqFnxsftbNkhzSPB1WrhMJ/mGvirdq+8b6JActkbtmW10 X-Received: by 2002:a50:9b0f:: with SMTP id o15mr8605723edi.325.1588445685003; Sat, 02 May 2020 11:54:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588445684; cv=none; d=google.com; s=arc-20160816; b=Tr4/ppgpralmle+ivNftIsYUG6mI3WZVfUXVizsNYjv0PY2l07KPcuyObm9AlRr3LZ LcI2K9tvPXJOtooIa3c3Slv6jWlUy4ajWdF8UYYf5jKaBY7ziD4zWd11ykfA23gJu4o6 ehQ3nAxuaaopz/ZPlYbrSs3kmyh8SW0zAKQ/RUB2qeJZmy9EEW8QiQzF3iLFe7B0rgtI LEWyt1G3ip/tIK7a9/CF0RFmk55KTlgGad+Jx3sKWtTaOShF4Fm1gycuGIu/6VAhcfZ/ HQfJAr6gf4IsJrxOl1yMrSLcJo2Qr2GYbb48AMGOjN5g1dLX3K4bShAiz12YhdW0cMiZ GzfA== 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=0Bb7PtBYoHDbA/mpUbo2nXY/JQvmpzOFkDnjMfbrWXA=; b=vXJcHr8EA531bAZQH6C/2TspsBmMX4fCzQucwOLETTR14v0OPP2mWgsRNejw/dWrHm qPFxWnZHsuDAmJB9KnwsQECNOTL6rD6/uvWb+J+FcK4uMMe9pfvHEcJtSQ9EMJECjTKx 091PbhvgoEgl6LPYLYApYs8oydxiN436gSJaa6txrzECWNkHWKpjgbS41g3i+Ci35UJH 4IAGWHfLclhGACFOf7tj8yehco+sXKOo1gma18RhmT5miXzl6PK/THhSTMsd6eNQnP4V TNbgjU95ZbF9CgzbQXk19HMmaDq5H6Rdp02U92tvhMaUFFspldwtxZG6MZzOvR2tUBit pkKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qtbYHy9M; 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 g12si4056322ejw.314.2020.05.02.11.54.22; Sat, 02 May 2020 11:54:44 -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=qtbYHy9M; 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 S1728464AbgEBSvB (ORCPT + 99 others); Sat, 2 May 2020 14:51:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726306AbgEBSvB (ORCPT ); Sat, 2 May 2020 14:51:01 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30348C061A0C; Sat, 2 May 2020 11:51:01 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id e6so1646408pjt.4; Sat, 02 May 2020 11:51:01 -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=0Bb7PtBYoHDbA/mpUbo2nXY/JQvmpzOFkDnjMfbrWXA=; b=qtbYHy9M2JJj41Q6gHOMrFwz53q6qmySLPbrFhZlK4cSWDA2UJrFPpudPGmWRC3V+o 7HY6SNSWriVjT1G4tLna6aPPeL3NL2acZKiHWAoI/oQMblftgjwG/TPYZ2jab9Mlglk6 8ah2CUCjzJUIp+aHyVCtN7XDLwdVx9JBGSUNqCYMcTv1OLJnHWRkwrb+OP1wCv6IdUjO HKuQuPL7Psn7vbbZw5YJbC0xogFsF4Ovvb/scFrTUeQECCkRF/R9n9IktR9JZZggtToj Sur/QMeqmNXmWRTw1KsKM7pBgZuABZOyDGi+k2Ud7azI/jVRN9fTsv/1bzPnAWvr8ogD LHXw== 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=0Bb7PtBYoHDbA/mpUbo2nXY/JQvmpzOFkDnjMfbrWXA=; b=OjUqEvckq5K9Pe4tlzQkA1CuGf/JkjJ/DOB6usU8FytjxPDLaMYvUfM1n9SXYHsADA FvBF2lsmt0jeOAxgmkoPjBsTY+uGIZqwS0bcWumISLybj2kKGyr5Au82FZ2EZmWshWIE pAikx4IJO4nr6V64dSk20b8dSmIXPuyHFwtzyXg7g3OMo7O2NXbkQCqWvV+ueuuQTq3Y DsOv9AaNFEqeAKRQi/5c778iHzEwEM+dYv3JVQDlsFwXF1l3oa7Cuo2lD65x1BxlWd+2 No1wJPzqbR26tkRo8RsrJ+3Xf7Hun/tiAzOOexMM5Mw9XzbFmquRophBro7dkJCsKssz Ov/g== X-Gm-Message-State: AGi0PuYtFtkylQ6NnDsgWqV8t9VC9PdiWxgHZRzcmFzUc1XxowKCwL/q ZmIEe0qAtGvx4BSGnllsrj4= X-Received: by 2002:a17:90b:128d:: with SMTP id fw13mr7554273pjb.23.1588445460798; Sat, 02 May 2020 11:51:00 -0700 (PDT) Received: from syed ([106.210.101.167]) by smtp.gmail.com with ESMTPSA id d12sm2758907pjx.1.2020.05.02.11.50.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 May 2020 11:51:00 -0700 (PDT) Date: Sun, 3 May 2020 00:20:38 +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 v4 3/4] gpio: thunderx: Utilize for_each_set_clump macro Message-ID: <652dcbc32326bc0dce095863f51d8adaad960e09.1588443578.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 v4: - Minor change: Hardcode value for better code readability. Changes in v3: - Change datatype of some variables from u64 to unsigned long in function thunderx_gpio_set_multiple. CHanges in v2: - No change. drivers/gpio/gpio-thunderx.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c index 9f66deab46ea..58c9bb25a377 100644 --- a/drivers/gpio/gpio-thunderx.c +++ b/drivers/gpio/gpio-thunderx.c @@ -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.26.2