Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3468960pxu; Mon, 19 Oct 2020 12:54:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1oCcbYgyGHqNJ1Hz2cJF9DR+HQ1xSSHCp2eUmKcAsCDtwZaZImHTPPSRCtjau4eqi+GfP X-Received: by 2002:a17:906:6004:: with SMTP id o4mr1470292ejj.309.1603137297242; Mon, 19 Oct 2020 12:54:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603137297; cv=none; d=google.com; s=arc-20160816; b=ZrM06pHcmwhE1R5xoRcpVtxQxhvb2P7yA8wBWQNJb+zmBgc9ODBpYmfDlkJImoAl6C jDWdVnTkGpE7gnakrOlCh7YIM7EjSdStjuKKtOmmu30EEXQJMGB2rrOl8njiwvwXiwhA DU+NHUYq03MqErZF2Vm3X2J7kpFv4Cvk8rk4X/e1xD6MRc/LJgzG2xfiW+WgB9wdVk4e j0CZ4DJNRpBxHcRyiPLvTaOcW6WhWAYn+kwhGBoVn2zskhPP7+uJZjIbf+qRT20ou+O2 7T3HleIRABe6Ra1WVlAWVn8UfBdIhDYmihT4QJnEltLtPhq+3N98dAEkuDHtXOS2q/Yd H4GA== 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=r+CqUbH/pMf/6TjojKzCkT9ZN5spOtGX6tIuObsC6wg=; b=uOnOJNJLbqV38LDR+6BiMSth9vTSeGW8nlpZhxnLrv2W9KeTwgDGdiyjk1CpA+7Y69 JWEX06/5Tyxh/Vn8OwsSwXBB0fOrcyDtwWrrITs2N8fXbjrYYXJPpxukGa4UhfVLDmKW gkyA//PQ001Eou1xK9hcXLd4OtRSX6I0HZPEla9Ynxpd+ODikwV4YNgrrdq+nvCvY+Q1 lH85e1/0Rj37Qy1a3fMuRzKW6+A4uWbEEexcHvnwAsiXcwcw97q0J5PnRkWCXFD4XrVi 1umOpRvsh1RttPkcWk8O3Riap87Sqgm6d/npMF6QI6jV0FIdvZ99O+zxbjhOdFgkqf4S fIIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MrqUSIDd; 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 ah1si646602ejc.606.2020.10.19.12.54.34; Mon, 19 Oct 2020 12:54:57 -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=MrqUSIDd; 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 S1728433AbgJRVlO (ORCPT + 99 others); Sun, 18 Oct 2020 17:41:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726249AbgJRVlN (ORCPT ); Sun, 18 Oct 2020 17:41:13 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88C63C061755; Sun, 18 Oct 2020 14:41:12 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id q21so4808812pgi.13; Sun, 18 Oct 2020 14:41:12 -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=r+CqUbH/pMf/6TjojKzCkT9ZN5spOtGX6tIuObsC6wg=; b=MrqUSIDdlaDMT5JF1V0bfMdsdil/IrDWE0R94qC3DpJOtqzNwuZGb6wA4sTzbtfWIB Pg+4epHCacvHN/P7xJP2KziUbQCdxNaJRLrNR0dCU6g3hPL9jEsZypjH+CRfFMDjz5NX t9V1IAc2DF63TY2wTVBCeQ3CYfuZp1XBm0klSzY4zkwfomKdbDwpBPyPbNCdeEu1JPqU o0RCRUBBxyUZ6x41yA2wbgIqmeM83RqBVs9pfKJ9dbxxHTuUthNxsHkOOLPPDnFPGfNw +sOMZCigEQTlr/bgBQzukzOOW66ij/Gw+KpI5pkZxPODq2wC5QVAotwXDuUeA9XCJK7Y lebg== 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=r+CqUbH/pMf/6TjojKzCkT9ZN5spOtGX6tIuObsC6wg=; b=QOV+L+PNf2sj1UroHFhtONfu6DVYaIxu0rwwhgoX+4he3tN6qgkISF/rt4u2lhgucF NoRdCgG5E+GNZXFq6eZBU1JmsHGDsHenqL5G2PVCMQp+V2k4014d5P2KyLMRqtFy7mBl CvjX6vZxqZqK7N/yGMm3IZSU7Kiu6d5jJa7CxbHCJIrraOYmawkh1QOwhJw+1SAXFecK xY0iKUVHfklWFF+SzhL+GWx48rG4vUhLCwOToXPYHXFiT8ycadcEDl6SOeivuYct9CaH 0s/855aZCgSDl+ZBWb5TxIamew9DgLIWqeqNDXJP5SgxBVWTTc0tmUlvHYyzvue8c7UQ Q6pw== X-Gm-Message-State: AOAM532ilNMTly46j1UNE4j3FaWqcYZRYRXgA8bfanCGDkDBcRGPOLK6 lvxtp7M7SMdkqNXNu19OvZ0= X-Received: by 2002:a63:3d8:: with SMTP id 207mr12159275pgd.238.1603057272184; Sun, 18 Oct 2020 14:41:12 -0700 (PDT) Received: from syed ([2401:4900:47f3:e624:90f9:25c2:806b:19c8]) by smtp.gmail.com with ESMTPSA id b15sm9757052pju.16.2020.10.18.14.41.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Oct 2020 14:41:11 -0700 (PDT) Date: Mon, 19 Oct 2020 03:10:54 +0530 From: Syed Nayyar Waris To: linus.walleij@linaro.org, akpm@linux-foundation.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 v12 3/4] gpio: thunderx: Utilize for_each_set_clump macro Message-ID: <5e94ad3c156b98d2ed28617b2ca25bacadc189d5.1603055402.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: Robert Richter Cc: Bartosz Golaszewski Signed-off-by: Syed Nayyar Waris Signed-off-by: William Breathitt Gray --- Changes in v12: - No change. Changes in v11: - No change. Changes in v10: - No change. 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