Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp2924499img; Sun, 24 Mar 2019 23:26:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGnRNm4ygERUVF5WClISnFcK0sP+lmQB707rMumobbZqEHmpHWGQi0PPh8D/I0dzagFrxV X-Received: by 2002:a17:902:27a8:: with SMTP id d37mr23874550plb.164.1553495178711; Sun, 24 Mar 2019 23:26:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553495178; cv=none; d=google.com; s=arc-20160816; b=QWfnXj6lsqsJbwvJvUTA10AB0LntxMW83UvIWmXmdrHEsHkPen8eKR3sgeU45oTLTH 2dafbnzyBQQBWjSI7+cVQbdc4p9ojx2tGuQ0XWWGp5gANd76CAZ4/1ommDoIy0dKlEVQ zjbfM3NPSNSa/hj8c8Fex9DUTvx6SH5f9ac2rQhE2T+C1o6QYk7+JBXNsXrhWipyA75u tKNj9mpUhwhppZ64yvNyfIy+Hr6TIzfVT55hpi9RtrUJ2YcJP0lNZYdFOhqajT3VURGg 7krHaqasnNmZmaKz2fQ53BhB4hS5iNXeVJGclv3sp4774EKeU1XN3u+ey1e0cplPOJtb Y2fg== 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=Bz4WHAdy6dyi1gc1U3zHBRi6sibQY2cKrVBwA6LZMy7CkORsuTGsWjFoYAqSox/n/M RN8SAzlywpcGvdDPeMiT6Q3IRaxLsd5P9uP3ZpayJtvLg3EpSx0xKI73A5aIkQfC1iKB /MbiBj1TWWx7YC2W6O6zRxH7OFUyMIzN1lMoDslfyf9LXPmDnb6ZHkBJ0MJQaFi+bB4Z SkPBhtNoPmYMQNJh6vqnZak57Jyi77tDRAaV6d77w1FlPk71cEPAvnQ7ELTxfL+Wus/0 259jrv7l4JhTudZ3UDTHIA/u+HI+uisAV69Py7xB79UgDYuyKX+x3aNSPRPyVyzuBji3 LTPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="YjdEB03/"; 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 w2si12493528pgr.270.2019.03.24.23.26.03; Sun, 24 Mar 2019 23:26:18 -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="YjdEB03/"; 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 S1729830AbfCYGYr (ORCPT + 99 others); Mon, 25 Mar 2019 02:24:47 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42037 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729604AbfCYGYr (ORCPT ); Mon, 25 Mar 2019 02:24:47 -0400 Received: by mail-pf1-f196.google.com with SMTP id r15so5627642pfn.9; Sun, 24 Mar 2019 23:24:46 -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=YjdEB03/bL1qKLf54ZWZ8Cx8OaY4qHeFXqQC7ahjJw8t+9gRJWPkqjZQmVg68+HOxl InLiArYk1FQUAaK5yZ15U+19TSrApltw0szFgOZp951dNfdKInl3WRNaODE9rwS9TPeI 2EVc4ci3AjiI57FtJI8zX/Ltxw+tSNMiuTDebpgwgiZkuct/tK42MzJoMqYSd5e6eh3Q nazprjUW2izeF4aU7CwO2Ql3NU0ltrjN940DzpNeLQsYfRqggxUKQaVRvDbw2JWdtiBC HYdljrEbZyvLJwOgg4kAHslQfgVr9fKAlgU51RG72WR+UL/pls6UnDcLZuTwHosZsyUJ wLUQ== 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=C9ektOF/hewTN/QGFoGUptoela2y6jV5mf4klr3eh7St7yVVEcc9bIYfCV+WX04fAl UNne5NAEE8MoDK1RqJ6Xxs1u77k0ZU4mbVUhcP2DPG5TNYOfnGQlHQgMvKHa2j6hdQYV vxwgb+5DFnVKegfuknCnM6BPaxYmbe+SEm9/5usEGGFrIpJRCRLoG1wMGS/bkMrmHL5n cFFwLjsL6u0TI7W6Kb/TfzqptbR9LajEbAb5gfdWFMyKCPdjnWEABcYxALUPz/oTx6lJ 28zICmkv0KuyGi/FWxpSgTS/y8GkaDg+lejj5dCzeb7SDheApvVZ4r37oHmiqoDFiZtM ZXlQ== X-Gm-Message-State: APjAAAVOtaGphgV9ojV8WcrVCz9dl2dBTxQJ8QWyjfzZ4ix8pWsWAi4J ezhymolrcRZSbl6+WkTVJE8= X-Received: by 2002:a63:234c:: with SMTP id u12mr22229188pgm.282.1553495086111; Sun, 24 Mar 2019 23:24:46 -0700 (PDT) Received: from localhost.localdomain ([2001:268:c0a5:e068:c70:4af9:86e2:2]) by smtp.gmail.com with ESMTPSA id p88sm24194193pfa.80.2019.03.24.23.24.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 23:24:45 -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 v12 09/11] gpio: uniphier: Utilize for_each_set_clump8 macro Date: Mon, 25 Mar 2019 15:25:41 +0900 Message-Id: <4d45bc472fabd5f5339a182782b27bd25f82cd49.1553494625.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