From patchwork Sun Mar 3 07:51:43 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: 10836999 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 3A9B21575 for ; Sun, 3 Mar 2019 07:51:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27D182A530 for ; Sun, 3 Mar 2019 07:51:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19EF52A53C; Sun, 3 Mar 2019 07:51:05 +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 BB7782A530 for ; Sun, 3 Mar 2019 07:51:04 +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=j9ZX9hoZgc0UNC dR9828VlrWV7JH/6gwPYFJe/YBArCGeFJGe4HzF9W86WH2UaVOKiB8oCb4so5QqpWt2YiUQKtjt9o 3TrPF23RrApIVkI6Gu4FoqkOq0RQNXIPGL5UhQj3CZ3O72shJIEWmfnXZnLUSBWkFydykgNgSpEHr p30tsBefdeQbL5q12/ddv4GQCqGRx5XYudeWycRGOfiRdOvMqM2v3NDhiYv89dKgQw0glzA7ClPkm 4aTM7FmkSMIBHIq8CQaUGISHQBRnrkv8NFq/y3E49vX5x1w3uBZ01r8oaS0ipwY++fhe4hT8DKolo Jimg4f24erV7KrFtNjiQ==; 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 1h0Ltk-0003I7-6Q; Sun, 03 Mar 2019 07:51:00 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0Ltg-0003HB-5z for linux-arm-kernel@lists.infradead.org; Sun, 03 Mar 2019 07:50:57 +0000 Received: by mail-pg1-x543.google.com with SMTP id e17so1033082pgd.2 for ; Sat, 02 Mar 2019 23:50:56 -0800 (PST) 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=ojfxmGFwRLFyuJDYOF9Bd8zYmbOX5hRQmO1fjeBXHYEdxDNCk6flfMYPtIFbF/Sosu QjwqzgGRRzUR/gH75F37vldJ64FXGmkznZTBs/I8bp7wJi+x6UTMG5/Uq3nl79IMn2HJ VRogi8HkGoEN2YeXoVDyWsCBHU+6x3Wv0ETXILjP7Jea3MPDNcl1LiVEel0zJR/QS5FM xlFADQCDFaLDH4BPluMBDDnyxXr2SEFY2i424dUS8hQE+ClDNnYTrltlMfApDQOmqTvz bw8Eb8gsTf8s32czH9FAQdATV0ueUid+zPCUt1o3lcs7tbuTUAt1jxHsgLoGa8BxD2A0 7L8A== 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=M2+TAUNRRiTp3uq3sBTKLYhziB0X8smo3GWPyrEXkQ1VQ/jLH5uNs3nicnN+VImN/j ca4jP80iksQPg3XK9v7FRdHO+gGyHgXtIoWvvTzbsRnys9712jSJiasbgy1ogYTiiJlg cnFVMpQFhZOspL1svOXgS8KbQmUMbUGwnpKFDmy+xJmBjQmdAg40V6LIn5IY3ZGXkmro JH47tP4bboURsUYDz8mqxDdUcRGEKC7pVFitRnNiX9cdWBGVUtO+4ycZIsSRrMDhZYMe McWML1t+1z0Nr+kap4phjObsaQQ/kibBR/SF1nXqgPaQB+ZLC8Vfz/3EQj5mYlOL1Kr8 HxPg== X-Gm-Message-State: APjAAAWLAEGUBHOw6/WGhsfhvEU+ttbH1COm64AP7kFs5U89YT9Wd6yL 1QCSxhNT02NLfXljadNidz4= X-Google-Smtp-Source: AHgI3IaRcnUNGGrMNo351mYUWL3BWUGU+5ZHcEvSSM8aSjLkbPbmGgKncncfSHeoBVILcIaVCq+gbA== X-Received: by 2002:aa7:8299:: with SMTP id s25mr14222435pfm.56.1551599455604; Sat, 02 Mar 2019 23:50:55 -0800 (PST) Received: from localhost.localdomain ([2001:268:c0a5:3b5c:c70:4af9:86e2:2]) by smtp.gmail.com with ESMTPSA id y6sm4735357pfy.87.2019.03.02.23.50.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Mar 2019 23:50:55 -0800 (PST) From: William Breathitt Gray To: linus.walleij@linaro.org Subject: [PATCH v9 9/9] gpio: uniphier: Utilize for_each_set_clump8 macro Date: Sun, 3 Mar 2019 16:51:43 +0900 Message-Id: <0840d55707dacd1121659723246fa9f55737f426.1551598603.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-20190302_235056_220944_3BC0CE25 X-CRM114-Status: GOOD ( 12.09 ) 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);