From patchwork Fri Mar 29 03:06:49 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: 10876273 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 99DB21669 for ; Fri, 29 Mar 2019 03:06:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81AB22906E for ; Fri, 29 Mar 2019 03:06:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75EC1290A6; Fri, 29 Mar 2019 03:06:10 +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 0FB462906E for ; Fri, 29 Mar 2019 03:06:10 +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=aYK1v5ZuK8n3jHA7j/nmZTuC9frj5JQdQzi4h+4cS1I=; b=GoWe4qZtO8VcKQ O98GAHU+Gk4Vb4vtFdrybgsLMQxJsurXDpHj0FjCM9YpwIbvKP0PknhTqBJkH3CARAFy82Fq0Oz89 PXlGoANEH4lMfAE3m864dGUPh+/BjLTilyrpnb5dGEV5I3Lj2K9DQ3iKB1/JPmrSBW1eo/GRJNJOA 7uCBLHPufr4mdynUvXbm/N6r9zo8fpm8F1Rk7XD63kiGcjMqB/UDt//oLFOlg7722pmdhSmEPGMya tpS0Zd7J2bqwrXa7yZyyHFT0hV2CpZEFAIeNF3LbdYsXEheMkNCO7bTMoYw3NaImR7OgwACkJO99t L1g4+2pCtZqUEvxvMoNA==; 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 1h9hqD-0005Pg-1K; Fri, 29 Mar 2019 03:06:01 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9hq4-0005HG-Ul for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2019 03:05:54 +0000 Received: by mail-pl1-x644.google.com with SMTP id g37so311854plb.5 for ; Thu, 28 Mar 2019 20:05:52 -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=KWnGgzBWLTCozh/KEfa65tk/St87oTo2wJuOL8E3BE/4C/OrqxarUzYbKBOoU92/gT YfusM2bZaX6obDHs5GmmuXS4odkAhdmnuBrUz/beSE9jdxS1Ctbvk+nvHdfMm3ox3iT+ gKgoQcVto1yN86P3yQe0QbCdDEx4A+QuQ8l4WRVQoL8xoVfv1PdmzsGgooQ4QbTK/4fc RPHibIoV+U9gApNGjB8Grlnx67InMK/tSLNJJSepysfjqJGcm33oiVjwyze5UHeysmpQ 6vCAE+hUNF+OTmfHN7g4e/zQOM5phBt6mOyH2u4+I8sF5pOEOtA1kk2AArCruucLQpcf N7/g== 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=ps6/DUsFgi/zcSKJtefNcnaTCPT7s6mUv0f1cSEnsn14IggwTHrEg4x3K4kwIzXKUJ EHvGTgV9nOvOuh93uprQWBf30rTIltmsosXeEIoFTtPIk7xeJ1aN7odRNx8uBMqTwa67 8/GPsBj4toy80JRj5/BJag0DLsRR04YUiYzCIm/igqNiPDtQgb50KRu/VBntB7s6vTiX Ffm69oQhyR+yUiA1uS+Ohf39uiglreYSS7a4Brw2OCB9XmNutSqZmgoFvYayJQJUrGVE zF+1yIUV/lnRhNGf5UwgKhXCcri0ROAcjeYmBT88fDS0dInCAOA4XUzTIJQ/bXupBKyo dUnw== X-Gm-Message-State: APjAAAUMYnS9BIybwWzEwqiXLn2ZadNLRSf7XMzuIwVBd3CGyR9spB3a 6y7EAeFpcRsNyqtJMTX1xiE= X-Google-Smtp-Source: APXvYqzjdiuEQzvKUGIzvn81X4Wqs4VOKQtF5LYTH98WcXqThbgwMjoEZHdlwlbGWk40c4f8F8ThSg== X-Received: by 2002:a17:902:b418:: with SMTP id x24mr39789647plr.323.1553828752410; Thu, 28 Mar 2019 20:05:52 -0700 (PDT) Received: from localhost.localdomain ([2001:268:c0a5:ba2:c70:4af9:86e2:2]) by smtp.gmail.com with ESMTPSA id 4sm697551pfo.110.2019.03.28.20.05.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Mar 2019 20:05:51 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org, bgolaszewski@baylibre.com Subject: [PATCH v14 09/11] gpio: uniphier: Utilize for_each_set_clump8 macro Date: Fri, 29 Mar 2019 12:06:49 +0900 Message-Id: <9758aea685bbc9b6b148977880b971920e7b97b6.1553828158.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-20190328_200553_225845_3C3166D3 X-CRM114-Status: GOOD ( 11.44 ) 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, preid@electromag.com.au, yamada.masahiro@socionext.com, linux-pm@vger.kernel.org, linux@rasmusvillemoes.dk, linux-kernel@vger.kernel.org, William Breathitt Gray , linux-gpio@vger.kernel.org, lukas@wunner.de, geert@linux-m68k.org, 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..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);