From patchwork Wed Mar 27 05:02:39 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: 10872523 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 90BB1139A for ; Wed, 27 Mar 2019 05:01:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77DCA28429 for ; Wed, 27 Mar 2019 05:01:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C10228C50; Wed, 27 Mar 2019 05:01: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 8B92228758 for ; Wed, 27 Mar 2019 05:01:51 +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=pi2uc1FUqKqG2bIWH2GaYrpMnHj4llDATf9RqWmoG3o=; b=GFid7XaZbsfmzf C8qZEDgw1yMEwvJT8XAeYlPM2j8C755urJi7Ta9KmHw7qr5gX5RtOrXqfhoqetiNkjCYewIk3dJx3 bDjOLph+Ec0aLls8xd1fp+82CxmnImysTL6JYZDfW+h3XDQlR2Ss5wfiKSxDQfXDbpic/gyB7hyk8 Lm+6rEOY+MEHOv/AN53qpPsRSXTOn9bgJUh31gMNyJV8cCLMDUYK01WV8gM1moamxf5gZAbG9s7Vx 1QrNTbTLDLpJ18c2j0VWR/LIsRsSE3HSryDl2X/zcRMWPlPUhymhTdz7PpkPoXxkRw2IaulFT78O/ toj/BCa0B9BavNAODnBA==; 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 1h90hB-0007Zt-Jq; Wed, 27 Mar 2019 05:01:49 +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 1h90h7-0007YC-Oh for linux-arm-kernel@lists.infradead.org; Wed, 27 Mar 2019 05:01:47 +0000 Received: by mail-pg1-x543.google.com with SMTP id q1so1178928pgv.13 for ; Tue, 26 Mar 2019 22:01:45 -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=0I71euHhTT2+JwpcW5o8Nyy8nGlG1C3w/bjF+uE002A=; b=RxJAI+wrrnLYuf5zN1LqQ0NfP/sRXnHsNkAerPKlXipn3hfibBfpYNyEyXZkV27rvv 1LEtXRdFz0qjzjnTAvIiYMA7TjHI+7o38Xb1wpFPFC4MdzacMWClpF8uQ7jJ1UssfKw1 NB/D4Jyx2Uk4Qdb/dFms8L9Jc3b44ezmBnZYRsKGnCl4WvSJ19dj9zQRdArtaD1+95JK 61n7uZiyp4TctN6ocARJffFWWb41MXz6CajEq9rf19Lzpxi26YPHA5faOg5po3ZiRTJ9 fUW2GoFH5cew28D6mPeJepXDvgqNDmDzbkUeJLo1WUSS7T5dZDPknOzeL37S6/XoDpSM s3qg== 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=0I71euHhTT2+JwpcW5o8Nyy8nGlG1C3w/bjF+uE002A=; b=I5sYbeOJ4X5VUWXfa9W/tIVswXojhpOuXiPBOYXFDchf9B0o/omLm3uOpfXEXNqSY2 Oqs5GRY/RAqdMFeyfgJLW9Ef38LHx7dss76xlVxz74ua3W8DHjDksqVnNSezewbRuX2l OchSVQqhkuOdecLeLdguWVt43BWDWcHRubqRUzJok0nDrptGZiBFf9P0FGCVJy7mish1 W1tLFqEvve/4jlaSqadYTaPWJPEVj3vGkOjoSDjjFKohquEkoemCbrgcne5peaGrsEm4 DApQrMa+2IQakudD177MIjQc+qMfKaNTa5/YoTJeqpaelKagTpwN1b1vHLYlcI3lTFuj pkDg== X-Gm-Message-State: APjAAAUdPLWxixwSdAOHw46I8IHDgnLmbADAFLAox9VdF7a6sVJMAMKf 5Le7mebWk5FSVY133vMPln4= X-Google-Smtp-Source: APXvYqy8zgtoeHpZ4u2hckq1rici1mAiaKRLX+aQROjYLbCJtAExdV6KIq7Rxz2ipsv5r7oqvAD8NA== X-Received: by 2002:aa7:82d9:: with SMTP id f25mr33179072pfn.45.1553662904075; Tue, 26 Mar 2019 22:01:44 -0700 (PDT) Received: from localhost.localdomain ([2001:268:c0a5:6014:c70:4af9:86e2:2]) by smtp.gmail.com with ESMTPSA id 143sm2358172pge.50.2019.03.26.22.01.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 22:01:43 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org, bgolaszewski@baylibre.com Subject: [PATCH v13 10/11] gpio: 74x164: Utilize the for_each_set_clump8 macro Date: Wed, 27 Mar 2019 14:02:39 +0900 Message-Id: <645f16f1d1ad3f215e34a82f457e06725fcf8f56.1553661964.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-20190326_220145_814759_8A3F5379 X-CRM114-Status: GOOD ( 12.27 ) 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 | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c index fb7b620763a2..0bbf1162bb31 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,18 @@ 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 long offset; + unsigned long bankmask; + size_t bank; + unsigned long 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, chip->registers * 8) { + bank = (chip->registers - 1) - (offset / 8); + bitmask = bitmap_get_value8(bits, 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);