From patchwork Thu Mar 14 12:32:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 10852725 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5170139A for ; Thu, 14 Mar 2019 12:31:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A9CC2A3E6 for ; Thu, 14 Mar 2019 12:31:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 888B42A3FB; Thu, 14 Mar 2019 12:31:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 251722A411 for ; Thu, 14 Mar 2019 12:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gZ3NYMrQ1q/us7gBx3qTXKTVVtPVjOQLX1dn8tMYBNg=; b=PMmQPUP4jD0oPC RAz7MLCecmwjpC+/UDLsF190MDXJsPPFayhBhOkotoTlDLIq5utwPg2jgC/ZcBAwfnpTYcHu3LGuM Hk0BE5Ufa0y84K5T66ZVvQlwK/cZZ1aCWcNy65zV5N5ZaxsE43IY43xp+Uyl4eHFGH4mNHJEK2YN1 WOQNj3KCT7Ws3BaVvnddkmCK8E+N4iotyrEXMefFxQo0dihkLhjChV83v2ZYOFzvMlssL0Sep/s/i G/KmmJtGSS7siPuwir1x4lHn61D95ar7G7bpl2dTXETEcdLP1+9iL+647oxJnAeyHZlXiznKeWRcZ cXlEm/itCfpYXQEZ2ywA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4PWZ-0001QW-5O; Thu, 14 Mar 2019 12:31:51 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4PWV-0001JS-2u for linux-arm-kernel@lists.infradead.org; Thu, 14 Mar 2019 12:31:48 +0000 Received: by mail-pg1-x544.google.com with SMTP id u9so3870902pgo.7 for ; Thu, 14 Mar 2019 05:31:47 -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=sS0MVDMDyFcESOfK3Nol8/Q9B+4Nq7OBizGym/jfhkZlhXLU9qaRP6cu4TLyqsxpdP T+67ww1K+a5bDz9/uvJhZpx6XAt7LqHkiY/4jGQ2K/Uv9ycyFEHqD6MpWTX5D+/C8LZz nWCrs2WKQJv3X+k+icsJNiOYtS5hdrVOS1OUExDpeDyHGC+b/pxVo7yVviZDGh9EnES9 U5QXzA5y4Yp9wgoTr9uinS/Bdy73Ls7b0q2iQ+LuKofZKwy/AnpKnF8xTIZfs0IL98hf fds9yWMwj/yd22EWN6ACH+4PQv9V7c8xm2pQ4BQ1E1sUQ3f+ezVaXEXRZpiw0m6bEMhN vquw== 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=FW9CEMhOXhd87thPtzdP27HcVz/4bkibI2Xi2XG2RxgcxIWIF8/dN4c+3QxLICO0DA OYhfeec2j23kt3x9MuO4gxzp92BxE+uiNcrujwsh87ODDtwi0gGR7ug7aiCkA+50jiJ6 VZEvRF3MsopXFfSIzL8DJJycMlM/aoITPrm5Rm370Pcv1RiKfw9h715KcvF90ttvsQOQ tsXIVdaCRXibUENd8KbKqJA1e9Jv67q8I/QOAR/7panV8WSwfHulJKWD8tXC1Qpal/t4 vP4qZE7gPDe0yuIJoIw6PZXUXjOCIWEuuEYYR5isR5mMQFG7S0lyTiV4N7ZNa0hAsCLH TPiQ== X-Gm-Message-State: APjAAAX48n+AS4x1lVpXiE5g0uj39EhTxKytB6mW1pDu7mlddmpCuFWI CXA5Xapbc+8tsndS3EI39MHaX4gq X-Google-Smtp-Source: APXvYqxRMyrpEmHYR/ILhPTW1Bg/IeYMXzo2jTUTJ/0icyFY2AGGTdVBvD1DUJFo/IuPL0FXmtdrZQ== X-Received: by 2002:a65:4547:: with SMTP id x7mr36531973pgr.350.1552566706556; Thu, 14 Mar 2019 05:31:46 -0700 (PDT) Received: from localhost.localdomain ([2001:268:c0a4:3974:c70:4af9:86e2:2]) by smtp.gmail.com with ESMTPSA id l184sm23077547pfc.41.2019.03.14.05.31.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Mar 2019 05:31:46 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org Subject: [PATCH v10 09/10] gpio: uniphier: Utilize for_each_set_clump8 macro Date: Thu, 14 Mar 2019 21:32:37 +0900 Message-Id: <9487b6bd8f9c2242448729f5f8fc9534f724b221.1552566114.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190314_053147_260525_77D6BEC7 X-CRM114-Status: GOOD ( 11.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, yamada.masahiro@socionext.com, linux@rasmusvillemoes.dk, linux-kernel@vger.kernel.org, William Breathitt Gray , linux-gpio@vger.kernel.org, bgolaszewski@baylibre.com, akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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);