Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1207390ybt; Sat, 27 Jun 2020 01:16:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbGO5jBIsqNDhKUd5osaO1js61whKB0+zKT0gygEpgQ7CrCOhp5H6G+V6J+zWWeiNo0qUC X-Received: by 2002:a17:906:c44c:: with SMTP id ck12mr6058972ejb.145.1593245794705; Sat, 27 Jun 2020 01:16:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593245794; cv=none; d=google.com; s=arc-20160816; b=A0IqryOAV0SLE8QVJmQE/X756/ZHJI7rlSnyVLv/WEtxA7hfI1UZRCAQha+X0si9uT 0rN3phFLpUTh5MFI3nLfwipLDbNiKc2JSQMIFoWBckyg3DU/1x0tI3d914vBIr1fUygU +BZbCQ/4bKwrhZ99BdifLwTEU99EE/Ro0CibvAXKVM/JuGcrHgGY+z1iuFUdbQTYdorL e5Lm2X2nX1L1EL8e8azv1GIDnFuRcscHtV4A0BBOBFfgDbnwU4q4eVf9pL/Dto9RyQ1j tVoluIhEmAb07qvrDNLhBYf6Xi8U9TmQT4/luMLqiYnsyQIxvJtk2kvOp0FGqTa4hSh1 rLGg== 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=PB7a66GEoGRfncWWrnjWJpz8d+zTdRvBjLv3u4bGuzg=; b=LgYJGWEb/HcjRZ2481KOtX+TrKYX4v4lO89fmEBENqO8xhxnhrKNOQL5QyfjviA7oa oneE4cz7IukZBuOaqJS5a/DjUmPyAe81xrGOTiubg4QrJR+Py562XYSjH8Phbb0T5DgE jRLEzaC/0XIzoSCie2viFpqVYWmFMavZIUJBqIZ4vzrpaSBAq+K0m/fyGGEzINmbKdSn +azlyXaNKW5ASvCrxxWJ4WLOkPNLhm5XbkvaVKA/evdUpJKk5Foz7oDyruZ9qeTevyQb 3N2qSW+sWjNfF1aaesI2REufSD5jNrrxx7BmH/nH9qOqGJL4ay4VZ8ML9xh+H0+p+IrW k5Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=odsup12s; 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 ly20si11198815ejb.607.2020.06.27.01.16.10; Sat, 27 Jun 2020 01:16:34 -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=odsup12s; 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 S1726177AbgF0INX (ORCPT + 99 others); Sat, 27 Jun 2020 04:13:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725991AbgF0INW (ORCPT ); Sat, 27 Jun 2020 04:13:22 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FB02C03E979; Sat, 27 Jun 2020 01:13:22 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id l6so2861777pjq.1; Sat, 27 Jun 2020 01:13:22 -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=PB7a66GEoGRfncWWrnjWJpz8d+zTdRvBjLv3u4bGuzg=; b=odsup12sVPFgV+UFVwvPYtj2YibwZyeiqKkpXRzKXuVphnZX4Dw3MPyQEWvx8v9b5H ulPYaRUr8pror09HzsV2wulRZgRaAgquu/6BBAbDfw+ESdFsSvuw636oH0+V3XERAEv4 uaOlLpBT3BxX848RDRCrw2mtBKLZZg3jQSJq604Vj173pufTbqJmuK6G62+ZWsB1MNVf xEIslM0HZ1h24/HMVlTWPneGEuPcIaf6fj6TIWjgkFWD4rLSk29rRnGIM1zKeeDTEB+S gaCskX+k82XtCvNud839ouEPPfzHiTMO6jrERdglvJ+jsk6keC948ZKZdV5cgf42pGZs 9Iyg== 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=PB7a66GEoGRfncWWrnjWJpz8d+zTdRvBjLv3u4bGuzg=; b=AoR5kq6atpvN6zmiRgmgY1BVNykQNzic0lbBBwfBlBnRZqkfh0vk2pMzLJJx2Yjdoe z0uAn9vlYZZSv2SZ+5xeHA40nao8Yn+6VieGK3EJzfYrefnjl+SYgWNRG15bJ4SwdEdI fN0KeVaKhhiml5ZTj907tZK99SM2P0mb6lgLtlWFTJyBhaBQE5bnsu3wr2YEMGr9KSPm Kl5lYgNZj0Af44V+7RyYSlmdynWlHy/cQydwhd3QTkwoq+7iJCpg/cZDje0aCxyDWTQ4 1VoUCkGYEaqro8xjl5ekDTP8gCYuGYVG+q0xktmfTkSb5DuaBZIFR0bJZNfBiRdP5aqq BqAA== X-Gm-Message-State: AOAM532v3seRDXl0c671BHeesVUG5XFJp/KpycZYfoz2ZFiJnci4vzXB 44tu+mrTLXMRFSYHBaxqw7I= X-Received: by 2002:a17:902:bd49:: with SMTP id b9mr5580970plx.22.1593245602137; Sat, 27 Jun 2020 01:13:22 -0700 (PDT) Received: from syed ([106.198.224.34]) by smtp.gmail.com with ESMTPSA id ds11sm13315839pjb.0.2020.06.27.01.13.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Jun 2020 01:13:21 -0700 (PDT) Date: Sat, 27 Jun 2020 13:43:08 +0530 From: Syed Nayyar Waris To: linus.walleij@linaro.org Cc: andriy.shevchenko@linux.intel.com, vilhelm.gray@gmail.com, rrichter@marvell.com, bgolaszewski@baylibre.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 3/4] gpio: thunderx: Utilize for_each_set_clump macro Message-ID: <585554e7f141ddf36c885cebaa98028854b2ebec.1593243081.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: Bartosz Golaszewski Signed-off-by: Syed Nayyar Waris Signed-off-by: William Breathitt Gray --- Changes in v9: - No change. Changes in v8: - No change. Changes in v7: - No change. Changes in v6: - No change. Changes in v5: - No change. Changes in v4: - Minor change: Inline value '64' in code 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