Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1105737ybb; Thu, 28 Mar 2019 20:07:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmAbkPDErxus80/MTYJH0i4tFJkBv/tTxO/0KZkczJXs8TWbCcefHeMhjjTPdNRVPkrSeo X-Received: by 2002:a65:64c9:: with SMTP id t9mr40525813pgv.221.1553828835850; Thu, 28 Mar 2019 20:07:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553828835; cv=none; d=google.com; s=arc-20160816; b=rU74/iPl4XHq7bYA4DmUIhNB6ZrEtNgYN5vuglLWBgbsWAHMjn3ZN6wJr1X/du3+po GbBOhcBoAy+qwmh6W0vFI8TkyPe+b9wIu4lF07u+VrPLtASzeYIVWnj3nJq+jEZWJT2Q aVBNlXRMQ4AzxpccpIs0dy98KXRQDjPozdaDOBok2rJ2drSbyuR0AQBGMidchNknnS0O yGQ6y2rNhYNvmmooOs4MEBlKe/4p0ZS8B/pCN8/Hv20t+vi0L5ApGHVq+WoHAL2lW6ys Po5jliyPJWL1KbEb8dHN0Bv+SlI3K7NXjojfXebSmCcL/Qc5PYPnMoQ6i0QHdLi8WPpf vFTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dQT+4k892SeDr0jEBp9yKTp//A73nSq2Dh+saIUctZQ=; b=wZmc2J6XroC9BGy8VMAeV5w/O7te8Xfl1G4HCxJplLwQKiFyimLfk+Yr3JiM+ecwCr MwOffAgx/pVQDW17sImi1bmUKdIP86puaba1QXUy/7AwnvhEpz65OAnzk6ZAQYV44FCm ZpGg99JPrZWvVTMBudjmMSRf13ZwNh2CrnvRfF0U6gqgp1U0uRz0vPnhbpW8TsU/u5Zo r3zAa5k8Wwc0QYsVc13EkmHiMb+p+k3z+UDAlZcnAnRlkLS+3BBWqGUkXTFCY9F32DIG rlkBiGQotzurSNK+TNF/c1sTISke9ZLcWoMYbu7++AnpzN7T4WCnvDNrkTLij9KhN+yB /Ggg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Kv2gkFD/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e124si167536pfc.80.2019.03.28.20.07.00; Thu, 28 Mar 2019 20:07:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Kv2gkFD/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728710AbfC2DGM (ORCPT + 99 others); Thu, 28 Mar 2019 23:06:12 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37948 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726879AbfC2DGM (ORCPT ); Thu, 28 Mar 2019 23:06:12 -0400 Received: by mail-pg1-f193.google.com with SMTP id j26so483422pgl.5; Thu, 28 Mar 2019 20:06:11 -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=toIsC1fYyNKK+nJ48IKyqv8FRkNosl51cJo9ZyJ17qMpqelG3Mumk6IhLBAlGBkhWC fHts/CbUM3+F0iU8OJ84/4pZ8aLyjDQ/NgVIAxj0tA2gEHcvRI1wTdUcKv/zuOt0rLSD AvQgd4Ii1tDk4ewpXLCiD+eBk0QDohvErCuRQ0L78EWG3GVKJ9BeQ+8Pyl6K6IvSS+fB T31krbJoqqaF8pbSpZSkswaLpj1Z2aDPEYVXEHRzEy31LEL8561GlBKZRng89DoDQWKG hPotEwnMjeiqfhjkbT92wNxeyPIcqqQLH8C6MH/x3N1iuoUSs8lSObbsLzIgf97lFGRe FJ3g== X-Gm-Message-State: APjAAAUDpqSjzSOGbeRYKqhZ4jH8Vs3M6BxUIUqFAR6JAsD68ntqSpEi F67KfpSgPgc8cnOvrgfyzJk= 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 Cc: akpm@linux-foundation.org, linux-gpio@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk, yamada.masahiro@socionext.com, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, geert@linux-m68k.org, preid@electromag.com.au, lukas@wunner.de, William Breathitt Gray , Geert Uytterhoeven 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.21.0