From patchwork Mon Mar 25 06:06:09 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: 10867945 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 1C0AF139A for ; Mon, 25 Mar 2019 06:05:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07FE229195 for ; Mon, 25 Mar 2019 06:05:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F061629199; Mon, 25 Mar 2019 06:05:19 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88B7B29195 for ; Mon, 25 Mar 2019 06:05:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729608AbfCYGFO (ORCPT ); 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-Google-Smtp-Source: APXvYqwW/zp/Q8To3dpTdoxUCtqXaOHNaAgv7+rJZJtMlrJQoCPCu3MGz2qZUjdACT3vJv1BfuwrqA== 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 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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);