Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4952869img; Tue, 26 Mar 2019 22:02:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnYHrbvYTCkbdCRw5/LXgdAh6uMZDwVF19XWsTa45BNkFdftfsUyPBVRDYgdqL9NU1yfUD X-Received: by 2002:a63:6c01:: with SMTP id h1mr32452675pgc.330.1553662937425; Tue, 26 Mar 2019 22:02:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553662937; cv=none; d=google.com; s=arc-20160816; b=s82lIkhGJQec47mq0IAXupwC9gDAoPnwzbYSgEqFTzgVD5hcywPilUulY78gWouHCx isRnEgTiB5O7AqlCL2086p9aPbiJ0MNmM5VGf56B/jzpOcPUhsuBKvGec4v/ik5m/Os7 yy6kj21Hn2i5Uhy/S9xEyc3bQnUFAYpKXI1rcDvfO5KJyOTseVc9cMK7fRRQ/2LqwCaW 7+B+qpgPrgMlGyH5y2WznrFoHkFuVsVbglJo+uspzrr5rc7F41l4tnW1Oo5kde2tklY7 9yXVRWvT+Q7n96ZgWMZ+drs58502zwxD4bd30EwPuQ7BIss1hO5mJ95Pg9hlAl9BeAhA 9tCw== 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=kZSRiSxJh+YYsNmeIydN7WXteuBFfpjUBowwMs4kNhU=; b=eOCrI3A+iWc6e091yQy4eY6Q/9OtAX3Hg1IEYvIxmfCUV1fKgEL8hqzwKS6ZIxa3TB 4sO2k3Ctw8eHXoOXLVipSI2GDB2uZcAdmN9r1dlBmNQXU3IDaR+3PRhbNqtyKWstZ/qT jGqwsdDWJD41G5Mg8BcVrKVajeGK9kpQNosLKwi+pnJWYdej1Foxl5Cd0Uh2pDqp+yOG hLspghv/M34XVPqPAzHHVBiKFjQSK11FpxC6lKe+VUsmGm2jf+7XukDT/UhZWNxs7rkY +wkgRhmBRXNCxuVhStb3jDMukhL6X7EWv/1Iw5Tapd4TCeWnuJGtZCgiQnEtDS3HYyXV svqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uQyk8R0p; 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 j134si18060948pgc.42.2019.03.26.22.02.01; Tue, 26 Mar 2019 22:02:17 -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=uQyk8R0p; 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 S1726321AbfC0FB1 (ORCPT + 99 others); Wed, 27 Mar 2019 01:01:27 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:38580 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725613AbfC0FB0 (ORCPT ); Wed, 27 Mar 2019 01:01:26 -0400 Received: by mail-pf1-f196.google.com with SMTP id 10so9147170pfo.5; Tue, 26 Mar 2019 22:01:26 -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=kZSRiSxJh+YYsNmeIydN7WXteuBFfpjUBowwMs4kNhU=; b=uQyk8R0py7UcGbhlLGdW/9Nv1ykF7ezJedfRqJMZf/2BH3uU9YMwLv2AxpRIQEL0tJ fDXgKX03TyTUWCj6FdlVlx/c6dkOR5uhFbuJhHI4Rj0v+bnjAja5EdqVQV8O7OJYzZNY RzrxlaON7mgw22IlE+Ni4o7/M93Uvmqm0wxO75WjbxSNo9v02/tMYCmyKC/Clu0r1KLj fyPBXTegeWjZzictHs0EG+R+dyS+YT3GH8vNhX7VsYq0bVF4BTEqrTx0S699XB+LmHeB GUdPF1POnQGe2cFxFE36FF/by/CVHbwwC8JTZoDLuhD/U3YBPqMKWxD+7KibfJLUmbfO tOXw== 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=kZSRiSxJh+YYsNmeIydN7WXteuBFfpjUBowwMs4kNhU=; b=BMn7zfNbGh5opcIphf7+eZ8ciaKamd/ui8uqjbNwitLSY6ZQnMGZJ6ecDgg95teIkv 1jk/hjmI4l2ehWawu2R23KZMEOqkyGf6JORLfUcLKj3zt2Sp8Ei9FyiXpRJn9aLylTqb Tef1WPWv34xht/hZXU+J4N7ykRj8op172nAPJEPOZZYUigaEUydiUYa3B9lENj4MVUf5 VV1Qi3ZMO1PdtPD1WFq5iBz69ESjFtatQHbaF2DsNVq1IiL77Z/5WVu20DGUQDBTv7mw ZBhqDGKuRGO1L5HQ6zgxP+Zzn5UrBaxVE4/lo39xmeWOldBbZa/Wei5rig/beXd5Ot+J 7dmA== X-Gm-Message-State: APjAAAV5dRCVMJbXDApkjGA1lmgu5kNLkgf2MTpdkGIEO1DMLDdBtoW2 SlHdrhUo/6Z9PDVhSYatdRM= X-Received: by 2002:aa7:8190:: with SMTP id g16mr6378755pfi.92.1553662885842; Tue, 26 Mar 2019 22:01:25 -0700 (PDT) Received: from localhost.localdomain ([2001:268:c0a5:6014:c70:4af9:86e2:2]) by smtp.gmail.com with ESMTPSA id k10sm31080261pgj.11.2019.03.26.22.01.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 22:01:25 -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 v13 09/11] gpio: uniphier: Utilize for_each_set_clump8 macro Date: Wed, 27 Mar 2019 14:02:20 +0900 Message-Id: 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..d79c34e9b23b 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 long i; + unsigned long bank_mask; + unsigned long bank; + unsigned long 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, i); uniphier_gpio_bank_write(chip, bank, UNIPHIER_GPIO_PORT_DATA, bank_mask, bank_bits); -- 2.21.0