Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1075436ybp; Wed, 9 Oct 2019 08:29:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxRFLTBF1ZE0R5101rzCebBi47cgNZkwo6c1BbfbPECwC4GR69b9c2JR3dGdnj0hixQV06 X-Received: by 2002:a05:6402:7d7:: with SMTP id u23mr3534008edy.218.1570634960771; Wed, 09 Oct 2019 08:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570634960; cv=none; d=google.com; s=arc-20160816; b=jKZoEqUdlTG+93/a7uGy6SqI78IDUvjvWSWN/eJjelX9nmFoRwbn0lcmhunzO6sbyD qoCfjvx5UEfSkTWekMhqK5oGgbnMJ/WJ1wznw/DGRlK5yR0NKJ3H6CqvmxTidX7iTqb2 foXUiccHXCerIdElGy2pmq9Fq+TDMvNcw4rZpIdRnafBoSeFGg/Hnn2Me5dCe477g5kn h15zcxV5PrrsIElsnBuw1e+XZ7KfKM+h9IgP4HVAizKZOCtQCkgMhcLz86LiaPlxNDT9 dnlo9Qlx+vlt06u+vr03KX+/KcdvwlPOx4iegMRoF3ZGhSYeeBvKyjaETk/pqm3jDt0+ abXw== 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=mBleGApOd9DY5AB30uyK9JEv+41JBB1+F0GtLYOX3MQ=; b=JPB4HBYUnw7DlnSs7PluxpWHj2iDXo112WwwyulpHM8AmmGtb9jBVHbbfRRQdVsgTW f5YRL3frIfpub6zc6/JKK6/HtfoiqXRkWa0N9UG6+pJp9kfts//kvXoeuWgeNKB3StVJ 2cLIsvMYI/unN9/GmWSvmUvRRBlsH+97DmDEXVwfi69Vu9cpiV14zTULaIrN+Jbols8l JvEOUEaFfGGDQwtA23yLrjqOlEejGvveKvtiL+VY0dgxpeviVMqpQKDsrQmMA7GE/0tq tuOO7oPTFerOTYtGwd6RAMAEyPbn/MiGFqOdy1QKmALy/cY6WoYmd5KF68t1am2uhk0G l6fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GAaw4kQJ; 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 x45si1609299edd.388.2019.10.09.08.28.57; Wed, 09 Oct 2019 08:29:20 -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=GAaw4kQJ; 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 S1731307AbfJIP1y (ORCPT + 99 others); Wed, 9 Oct 2019 11:27:54 -0400 Received: from mail-yb1-f193.google.com ([209.85.219.193]:39878 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731773AbfJIP1v (ORCPT ); Wed, 9 Oct 2019 11:27:51 -0400 Received: by mail-yb1-f193.google.com with SMTP id v37so863661ybi.6; Wed, 09 Oct 2019 08:27:50 -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=mBleGApOd9DY5AB30uyK9JEv+41JBB1+F0GtLYOX3MQ=; b=GAaw4kQJZ1t/twSnzYGj1Ye+b2rWZfgSQigTMAkCGXs7faRp9kbxzc+viRchH0iOUw jLQduPFHhg85mw9CZKGs3ZHhhcP9FaLFjY7wCSatMrfXGPdGXT9se2sj+/BL99Q2YvBc eyDG9o7N4Ton97yqY0ikl+XbQCOVNJW1GjnMWMNz+ysIw1dfIuCgoRxG5vWC6TmUuqjA on7aOT8hdds8tMqafPa8Np3qYdKvVkxrARA6ZLjvfnUqUMdn7xzUcrMz8yEoVs6EQA2x SbfDGVkowS8BcodygfJLou5vUSTzh7Ua2TWnGZSWh9VyAFMnVaTfPX2A90XPh5J0yFAF /rpQ== 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=mBleGApOd9DY5AB30uyK9JEv+41JBB1+F0GtLYOX3MQ=; b=lRSqjhgespL/rfvhdM+XW1i3hXXhn0tqub/DkAQh/C3bH0dv/JpOOllfxr+HhVeCOL +xC9GhZCUrzh5vb53/+mKc94P9mTBqP27ul8IYr31kSKnR/xtNbSdC1vuJ9TQtv3k/R+ +zbkh+xvvX/lqhXIzg6WL72/h0n1E7w3iDnqp9WQpcTRitM5t9/o+AhpFtHZqUjh7pZ5 F2WLlXkk1KaXZt1QEk3zyikZQsj5Uz19xxZuX3rdr76siOP/FZpimGiWHkIEXWx6ankL +BoB/wiCF1lDmeOVM2Jw50Esztbo96sVm7lrdxw6rFMPaT4H8bEE0Yrq2CqGewoBWJBJ r3ig== X-Gm-Message-State: APjAAAXMhTs7ckvmSl4vN/RHIPRxLYYEP8gNCJCHlHqMfh32L3SHPdCT vHgg0CzK9Eh0pbnJVtq6Cw8= X-Received: by 2002:a25:ba84:: with SMTP id s4mr2426092ybg.343.1570634870310; Wed, 09 Oct 2019 08:27:50 -0700 (PDT) Received: from localhost.localdomain (072-189-084-142.res.spectrum.com. [72.189.84.142]) by smtp.gmail.com with ESMTPSA id g40sm611863ywk.14.2019.10.09.08.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2019 08:27:49 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org, bgolaszewski@baylibre.com, akpm@linux-foundation.org Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@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, sean.nyekjaer@prevas.dk, morten.tiljeset@prevas.dk, William Breathitt Gray , Geert Uytterhoeven Subject: [PATCH v17 10/14] gpio: 74x164: Utilize the for_each_set_clump8 macro Date: Wed, 9 Oct 2019 11:27:08 -0400 Message-Id: X-Mailer: git-send-email 2.23.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 e81307f9754e..05637d585152 100644 --- a/drivers/gpio/gpio-74x164.c +++ b/drivers/gpio/gpio-74x164.c @@ -6,6 +6,7 @@ * Copyright (C) 2010 Miguel Gaio */ +#include #include #include #include @@ -72,20 +73,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.23.0