From patchwork Mon Mar 25 06:06:47 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: 10867955 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 C61B61390 for ; Mon, 25 Mar 2019 06:06:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AECEF28567 for ; Mon, 25 Mar 2019 06:06:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2700291D4; Mon, 25 Mar 2019 06:06:31 +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 3DFDE28567 for ; Mon, 25 Mar 2019 06:06:31 +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=axzlx/Ik2uzhXbcP42ilqfckjYdzlE9ebOg0xAU2kbQ=; b=cpo/CBQrGreKZx RSDDuAgKjZ+l/ZmDWqbPb501JQJeC8Wg1n8z8mmnnB65J5VYTznrTD9LHvUD3PbbVIxneBcCs0DLd +ZtS0d9Cz82pPCvZutS9hJppeCem9w9vrDQN3tvy5FElAhUWVQZXZ7MRMOcq+N3FxTSAXnf3JSgxk y/UzqmrMtdcz+YjxoSWELLMt+kbtI262pS7n+/jUfxqS0uljyz9AWgqbx1eDrnffrjc1+TQlCpsh0 yF+pV8DawxIPgT7TOf3ajRXv4yZqfSTSL85S8/T2W8nrCQCjfrRE958qh97r/UTYgRMFSbpvuuXCG TjH/YtCkHjHC8a8yIeeg==; 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 1h8IkY-0007cC-RJ; Mon, 25 Mar 2019 06:06:22 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8Ik8-0007BU-C9 for linux-arm-kernel@lists.infradead.org; Mon, 25 Mar 2019 06:06:20 +0000 Received: by mail-pf1-x441.google.com with SMTP id c8so5595788pfd.10 for ; Sun, 24 Mar 2019 23:05:56 -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=p6jZFM4uKZmmd8N/chkful+ZD8FsiAd/9uwJICIJ0zk=; b=jqumGuL+igo/SkIi2aID93fjdQzDHtjSSvtucpTKc92SzXwZT4k5G+kymX27UTh541 d0B+WYVS4FKTQFfwoolGxbR8dwqIp+3BE/22l0q2wEDoOxsBxqqae8QyqJycRidrZWI0 ACclu19uKMz4gcTlU873cG9+xs1K+5DGzeLcxzYRRwbxkiXAnZ1Lq/KZMdGvRkG4cNJN hwGvJWSx6fTXA39+0VSWWwTmjUnRT4s/NU3g4i/tfiLCQiOb99NVKOA1mvnwRHS+PjyG C0I1Kg8eizZA/SJrgWlrKs68LwenOWrg7n1bS87ydxx0jrwZZnNZmYX1YwHxV6xwzLp1 75tQ== 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=p6jZFM4uKZmmd8N/chkful+ZD8FsiAd/9uwJICIJ0zk=; b=unf+JVYvL0aAXkHDh8wYvK7nA2wFBS/CYCkfwPdSs30bTKBA+qR/o7WXbNDti9YcSG 0UAubUqj+fv5G6K7L8d7Awe/niL3KNK2EXVHvGBbHHU8TC9FPI2hT8PBr9a7Nh3723aO h1Tenm03TnITJcCKin+KRfVQzETaRVB/P6lO2k7IQMJkSHqeSoPXoOLrTdSvKhAddtin K1EmvwiSWP2+NDkwLwqVQrokazJqgWU3tTxpBzukZYAGI4Eye5/aAkK3IBlwA0ReqeWS xmlCI87D07+D+sqOP9I/rE8A9WmQYM6SyA1tQ5M4tswrF+Fu3SKe9NQzwu+yS6y2R1Nq 4CAg== X-Gm-Message-State: APjAAAXPKPjg8v2d6MrfrdqmmY8/lr35yrjCBfMmPpnIQPKhQinfPNFd 6o8SHAmVb6aOiZScGvo75oA= X-Google-Smtp-Source: APXvYqwDxykQkjuOKa1oZBlXM1NHkyoBvXV+7ZgKvU3Rmy/U4UOsNXSh3i4l6XjRsDUy5ImRcJfMow== X-Received: by 2002:a17:902:282b:: with SMTP id e40mr23266401plb.111.1553493953557; Sun, 24 Mar 2019 23:05:53 -0700 (PDT) Received: from localhost.localdomain ([2001:268:c0a5:e068:c70:4af9:86e2:2]) by smtp.gmail.com with ESMTPSA id k22sm20299064pfi.90.2019.03.24.23.05.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Mar 2019 23:05:53 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org, bgolaszewski@baylibre.com Subject: [PATCH v11 11/11] gpio: 74x164: Utilize the for_each_set_clump8 macro Date: Mon, 25 Mar 2019 15:06:47 +0900 Message-Id: <8a2e010aa62e00e1fd56802d6c842ae972d2f283.1553492741.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-20190324_230556_732779_02871D96 X-CRM114-Status: GOOD ( 13.08 ) 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, Geert Uytterhoeven , 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, 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. Suggested-by: Andy Shevchenko Cc: Geert Uytterhoeven Cc: Phil Reid Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-74x164.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index fb7b620763a2..e43a6de3b6eb 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -9,6 +9,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include @@ -75,20 +76,19 @@ static void gen_74x164_set_multiple(struct gpio_chip *gc, unsigned long *mask, unsigned long *bits) { struct gen_74x164_chip *chip = gpiochip_get_data(gc); - unsigned int i, idx, shift; - u8 bank, bankmask; + unsigned int offset; + unsigned long bankmask; + const unsigned int ngpio = chip->registers * 8; + size_t bank; + unsigned int bitmask; mutex_lock(&chip->lock); - for (i = 0, bank = chip->registers - 1; i < chip->registers; - i++, bank--) { - idx = i / sizeof(*mask); - shift = i % sizeof(*mask) * BITS_PER_BYTE; - bankmask = mask[idx] >> shift; - if (!bankmask) - continue; + for_each_set_clump8(offset, bankmask, mask, ngpio) { + bank = (chip->registers - 1) - (offset / 8); + bitmask = bitmap_get_value8(bits, ngpio, offset) & bankmask; chip->buffer[bank] &= ~bankmask; - chip->buffer[bank] |= bankmask & (bits[idx] >> shift); + chip->buffer[bank] |= bitmask; } __gen_74x164_write_config(chip); mutex_unlock(&chip->lock);