From patchwork Fri Mar 29 03:07:07 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: 10876279 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 0583E1669 for ; Fri, 29 Mar 2019 03:06:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E12DF28A3B for ; Fri, 29 Mar 2019 03:06:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4E5A290A5; Fri, 29 Mar 2019 03:06:30 +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 739DC28A3B for ; Fri, 29 Mar 2019 03:06:30 +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=e1pUdTfZB+sfPH1E0XqjjU8jKhPmtvvxsdhTkhdW0Ek=; b=I7e92i1R5KrbJB kGLfqAYIa8w3DVveelz1PrzkedmLVhwohpUPAWdGCkE5JCxEokyYuKaVw2locO9nevXfLvm5ahF9e Yph4BdlXf7d9k+K/T5MO59+4GJpwUYPlxuJ5bjs+c6j/Bmku68ts9FDhju/GiWaIwL+Vh8bBcarmD VErsY/ZOPRYRXIAaspbAwdOhCSrQ9HSw0z96FZJ5Ul0NM6lT5qKaMXY7bwNgMW0/vZYqXEieVnlOX azZ1A03jrLy6SnqwzwzjEoCGoAEDCTPyhGXdfmbvcPWM+9x7qZSymX4FgAtsS/CtAhSK9iZ1noIAZ peY1pv4dkLvqf8roIQXQ==; 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 1h9hqa-0005oh-6N; Fri, 29 Mar 2019 03:06:24 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h9hqP-0005he-QH for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2019 03:06:22 +0000 Received: by mail-pg1-x541.google.com with SMTP id q1so462953pgv.13 for ; Thu, 28 Mar 2019 20:06: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=dQT+4k892SeDr0jEBp9yKTp//A73nSq2Dh+saIUctZQ=; b=Kv2gkFD/LfDZMH1yUpLLoQDeqknfoK2lmKmZINCPIJux3BnDlSkBr6LPLIf87oGC3b Ei8zGBJkWMjQ0scq5CY73vpbcAOHrmOABVjLkqQySEIBEG/aQZsqZLweiLkeNvF3Sekd dJClA+LYa5pkxaXsO3xK0p8NcfUr/36Ulkn81DQrZMrw6x3Ak/2kWaWrqa66vijrNFbE //jN8YUXaQ9cO8S+hsNa/3si9t0kDXW55ilykTX1CJI40OiIoNOa0wMnn6Gv9gODcNvZ ydBObKmbQ8tsbP8gSuRLqhYjuFQokdKmoY9nw+L4t4aMn09FJi4qxkYfdjqP9jjZKTPc V+Ig== 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=dQT+4k892SeDr0jEBp9yKTp//A73nSq2Dh+saIUctZQ=; b=JxLJvsibFVk+uYrZ/RYOUDAGFJGQWjybZl7j7+pLuNwEU99RJ+FuuM5AlbGTkQ5uHc H8qRe/0JCdOx2I2vcVHqf35/R4aFkCsOPY0qbQwIFDc+7ENWLodjvyzHGw8Om7TmldQs L4hxsyZqAYXPQLH5XBEFpjcKnYL5Sj30J1d+QNEL57EN0he0jXaovHtgwSbkljTKlgrc BFU56Uz4r69TEAwBY1fomdeDswQxca48N+F/fndDOvqHt/O6EOpWuHvBb6FCfyspO66p UHTEQXbjIwOfb6ViGVFfSuTcc9U5yEC+0t42pzjpN8sz7eM/nMyn7N14v5rhQ0sGcDf2 L3Yg== X-Gm-Message-State: APjAAAWK/XPYWb46fZEhuV0LIPDaAjkhhNdTEkGydVE5+VOka2PE4pMJ ANRGwHk1KaQr0QAWBSbyMnQ= X-Google-Smtp-Source: APXvYqwvCTl69l0VdR73TwLG64piqZSCIotkCo4f2C8z4dMSswzCr5Ql2nYhiK/1MXIBZ8JY4tYZCw== X-Received: by 2002:a65:4689:: with SMTP id h9mr17001919pgr.295.1553828771474; Thu, 28 Mar 2019 20:06:11 -0700 (PDT) Received: from localhost.localdomain ([2001:268:c0a5:ba2:c70:4af9:86e2:2]) by smtp.gmail.com with ESMTPSA id w68sm724917pfb.176.2019.03.28.20.06.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Mar 2019 20:06:10 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org, bgolaszewski@baylibre.com Subject: [PATCH v14 10/11] gpio: 74x164: Utilize the for_each_set_clump8 macro Date: Fri, 29 Mar 2019 12:07:07 +0900 Message-Id: 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_200614_144697_0A6139A6 X-CRM114-Status: GOOD ( 12.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, 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, 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. 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..de1e8b37e102 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);