Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp2913227img; Sun, 24 Mar 2019 23:07:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyA2aNtykhSzu7wMFUk9xQi2w/VGcy18zg+1kLF+zO/22ayTQOb3MKrxI3cwVxQ2Zx0SAOz X-Received: by 2002:a17:902:b40a:: with SMTP id x10mr15224727plr.231.1553494076787; Sun, 24 Mar 2019 23:07:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553494076; cv=none; d=google.com; s=arc-20160816; b=XjMhm3mOOTLdSMrnH+9xQsmva96bdD5GTIdnMlGGosZlR1fflDMEP5m/AwKrpIExYt OGUfzt+m5ewKYSq7c8J2715/Yv2HcwVb8JqEQGaHngNCBxtELmfFMLtWJ8BON1JZhCfz 35li1fzEJpQj1U7lLOwxQh4bwcrQokYtHU2Ls7SJ5rSQ5Z7/EyyZ0pmWobgb+6HmCLkX lmBY0nfGw0q8TsefppiezHgHqORkvQFxMAeDz4T7xaJXyu1jCSvSxhWu8Cs9pODaL2kW hx+HG3kaOSdlXrKbE0plJzidZhngMbqacJLjG8vjBbMtxR3comJIvHXLGmkKQANeEzBQ 2JCg== 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=p6jZFM4uKZmmd8N/chkful+ZD8FsiAd/9uwJICIJ0zk=; b=fa+VYX3+MpqiqeR+1i/aqNW8e8Ao1okzmc0WNHhXPv6fcbk2GOTm/wNQ2qdSkMvdLg 7v+PK0Ez6BOq++NQ9scpmweNUBQCXISuM6hSu7PRujhdeYlIZLuH5KRYyz42LDvyTQCU edigEMxT9OGHNUwLnkFFQaXRvGgiQlsxhMr3si5Xk4p2HGLLwyqvUJfMYmzmum/c7/qI +neLYOC1Uv6pqP0H2hABayLdm3yh5mo7QsmnzepTvJq4vAjcP3gWLmnUMzt/MlNGzubm 2KLWom+IFK6ogNVBRMiADvWho5mKsNgvMv90Y5czJhjg+ASjOO+mcqo/lWtSi/rXNGk7 ZA7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jqumGuL+; 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 d6si12850181pfg.66.2019.03.24.23.07.41; Sun, 24 Mar 2019 23:07:56 -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=jqumGuL+; 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 S1729631AbfCYGFy (ORCPT + 99 others); Mon, 25 Mar 2019 02:05:54 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:44248 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729373AbfCYGFy (ORCPT ); Mon, 25 Mar 2019 02:05:54 -0400 Received: by mail-pf1-f193.google.com with SMTP id a3so5587351pff.11; Sun, 24 Mar 2019 23:05:53 -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=KK2A27C79S+o6plLBXlSYhLmoyNWcZnJEXCSEclWQe4J28AYetjfNZBBjjO+aGT88v dmjK6Vd3zYX2R5HzMaxSFHOgcNnbTkEsutg3RHUN/7/jR0W5PUG1gwseltEpD9xzGKSA qzg+cI/U0iT17ULnwNzi1DmOecEUJTH7qX4Hdc6VeHlIZxmKf8uW1g3fJ0Nh/n2MbzxO k0nu54hKZ6pMhQD5Ga2WuuqX3Tia04gjFd++7f9FpunYqGOjz9nrtYdRv2ka2BlHkD7j OABmhSqhqG8coaSzHSLws3yXukF0UBWzQGVRkHUYQc5SSvO5adnklDVGB76tgJjdaeZz DZMw== X-Gm-Message-State: APjAAAU8uoMPHc/m36M2uSRwAoUgS0RLOWY1QYSNkJRp0Pp5flsDMopK 73WazdJAyBZEJjafG9IFFn8= 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 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, William Breathitt Gray , Geert Uytterhoeven 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 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 | 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); -- 2.21.0