Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp2912157img; Sun, 24 Mar 2019 23:06:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqNrf7ouIFrXu5Qo02E1cZpDbh8vZVnqC3wYXgP8ExY+w/bj1thYc3lEwBqcPt26O4dFpf X-Received: by 2002:a17:902:1aa:: with SMTP id b39mr23914047plb.317.1553493971923; Sun, 24 Mar 2019 23:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553493971; cv=none; d=google.com; s=arc-20160816; b=m+OA6y+T1r4GbI6lxazuGbSFk/jqRIO9zKkJgCM6Om/ZljXl1z3b48u+zI4OVk15BN vGVbJzd8iLdQw8zhrU6VWQWS4wnLjviNZM8QdGhQbkMWZWrymYdKuRKcjLF+V6RFDr3p SzCPdKPAq9P1tomrw7RwF+i8LpSDhKbfEqohV1A8B1Dv5TdMRFA1XAM20Jb5DcBkA3ww 39KCYP1z09g5ZPPm2CEqDe9dvikB3zRhyX7L2U6FdkvHPUkqOSUtUOr3zMoebUcR3p8S DEj4uMDuDFC66232FSiH1fwOudnsmRamgnbIpeklA36vhyQa1oAqkZvVMR7TuxuUyuUx u2iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UifkzEkFRqXu3yixaaw6yvTChu7M21y6ZQxvlg1zFMs=; b=OPSuY/L0FBcdZyx33cn3Ly6yYQNlngbQKdc5K5zZfS65qzQGwRvRtj2pO/Dd07MyPT ZhNj1Ak4Z4zCe9JNXmVdepgrI2qdXkcyWZJnJfamFeZiU85jIMe2o0DKwm3vzslGNknX NrZVYf3n7Zcn2d+kHhVfO5zIs3KJpVSOmbbcYl6OSA97dsQVDo+DRCzN+rHe6nAoPyqM Ex9xjseewcWmVDfkvxyyoA5k1QvavI++0JMsUvLsaNAL6Y/SqbB390EWIsUSBEHVI64C v8temWyu0c+hZVeGxRXCMC7qPG1r1RnqKB4MJyZhqH/xMMZyycjN3qKo97/LNR8qjdno E31w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cUZivDN2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id h35si14233880plb.180.2019.03.24.23.05.57; Sun, 24 Mar 2019 23:06:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cUZivDN2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1729738AbfCYGFO (ORCPT + 99 others); Mon, 25 Mar 2019 02:05:14 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34617 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729519AbfCYGFN (ORCPT ); Mon, 25 Mar 2019 02:05:13 -0400 Received: by mail-pf1-f196.google.com with SMTP id b3so4229275pfd.1; Sun, 24 Mar 2019 23:05:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UifkzEkFRqXu3yixaaw6yvTChu7M21y6ZQxvlg1zFMs=; b=cUZivDN2YWWNLkTIYSS6FpIHofsi9nxbjKjplH5GCWNdwnLqzZLYIHVzd0DMyNb/0F JfvRjZ39ub+vB+JlNnJEulAXTcC7kJCoZXroxbm64jTDrNDOr/ZgrG98g6gkXJeJ7dkF n8ZCBvTgQUvXlBy7f2DZvi3loBxuDWodB8DoWyK2LWYGThL5u6qi8s1mFYVG75RKASyQ +VmBfU5mpq0ZYbg76cUhEA3lB5K2OxKme606WKXH2PdIjwEOFJtgY1Pe07L3eicxIHYT OpZqL7ktiWVKWd21K2HYs/5QGn0TPruxFiaY2p2PiFcALREQNBY91tY39orS71lN5eku w27Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UifkzEkFRqXu3yixaaw6yvTChu7M21y6ZQxvlg1zFMs=; b=YkLR2muv5Z9psikLRjMBrOaJqmgFsL+N+yjMWl6fHxLiX/k/4Cd2ZJDrJBvUVVG204 +l24/6m0+ir1q7TwThSzzVAUBIgxa0endMEZDOhv9HFJQjYXup6ERENFs19gTB0dk/D6 bHa22Mg1j88UqrA4loNS6uOD7wrPp0JBesCaIpglNsrxh8Vk6TJEykAmC2OUXrxNzIiL XJsaXpzhXaAMRlwcHVaPXSLG62ssCKMn3brQycT1+cBeLfnffmP82G/sB6w3rM2Pg7hg l42Fr7Ggwim6Ki2SGGQI+P4DT/aXKoYAkWE0s0i23ZZHQWcPvtZPGr7mTNhAAC7q6Nlw Z0qg== X-Gm-Message-State: APjAAAWQwM5PH4HzKB6nhuSDwExWse4u5+TsnRagifeWHSu7aAdYv9Rl 1fAM9eXngc+2x5f03OX2zXQ= X-Received: by 2002:a17:902:121:: with SMTP id 30mr23719883plb.315.1553493913056; Sun, 24 Mar 2019 23:05:13 -0700 (PDT) Received: from localhost.localdomain ([2001:268:c0a5:e068:c70:4af9:86e2:2]) by smtp.gmail.com with ESMTPSA id w123sm21668681pfw.72.2019.03.24.23.05.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 23:05:12 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org, bgolaszewski@baylibre.com Cc: akpm@linux-foundation.org, linux-gpio@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, yamada.masahiro@socionext.com, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, geert@linux-m68k.org, preid@electromag.com.au, William Breathitt Gray Subject: [PATCH v11 09/11] gpio: uniphier: Utilize for_each_set_clump8 macro Date: Mon, 25 Mar 2019 15:06:09 +0900 Message-Id: <82b21a3c4f84bad98487c450a8b3072ecf1c44c3.1553492741.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace verbose implementation in set_multiple callback with for_each_set_clump8 macro to simplify code and improve clarity. An improvement in this case is that banks that are not masked will now be skipped. Cc: Masahiro Yamada Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-uniphier.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c index 0f662b297a95..df640cb29b9c 100644 --- a/drivers/gpio/gpio-uniphier.c +++ b/drivers/gpio/gpio-uniphier.c @@ -15,9 +15,6 @@ #include #include -#define UNIPHIER_GPIO_BANK_MASK \ - GENMASK((UNIPHIER_GPIO_LINES_PER_BANK) - 1, 0) - #define UNIPHIER_GPIO_IRQ_MAX_NUM 24 #define UNIPHIER_GPIO_PORT_DATA 0x0 /* data */ @@ -147,15 +144,14 @@ static void uniphier_gpio_set(struct gpio_chip *chip, static void uniphier_gpio_set_multiple(struct gpio_chip *chip, unsigned long *mask, unsigned long *bits) { - unsigned int bank, shift, bank_mask, bank_bits; - int i; + unsigned int i; + unsigned long bank_mask; + unsigned int bank; + unsigned int bank_bits; - for (i = 0; i < chip->ngpio; i += UNIPHIER_GPIO_LINES_PER_BANK) { + for_each_set_clump8(i, bank_mask, mask, chip->ngpio) { bank = i / UNIPHIER_GPIO_LINES_PER_BANK; - shift = i % BITS_PER_LONG; - bank_mask = (mask[BIT_WORD(i)] >> shift) & - UNIPHIER_GPIO_BANK_MASK; - bank_bits = bits[BIT_WORD(i)] >> shift; + bank_bits = bitmap_get_value8(bits, chip->ngpio, i); uniphier_gpio_bank_write(chip, bank, UNIPHIER_GPIO_PORT_DATA, bank_mask, bank_bits); -- 2.21.0