Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1202617ybp; Wed, 9 Oct 2019 10:17:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqylD4uJfLiuiUFUP1lj0pClalWUBJump0isvVGYSzjl3K/+Idq6PyomYT1CKXdUJJ4bKi6t X-Received: by 2002:a50:8e53:: with SMTP id 19mr4011099edx.134.1570641436739; Wed, 09 Oct 2019 10:17:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570641436; cv=none; d=google.com; s=arc-20160816; b=n3QpfqgE4YPC9mlM9dwur1e+eOvuJVb+1li4Dr41L4F6pqudPSo6JjCNFe3/z5KDQo xtvxcg0336uqoqw18bzL3mDjDNqfOA7kzywg0+OcDo3dKVPFH6KfH212cn4jNxQaZD8B 98kqL0s871EJMmmQu/oNgL0zNoB/yJSl9cXXYiHfWMEWNcH0SsuPeQQbR3tJgDFK8jY7 y5L0Ij/qELqms7Oqh0LbQ99QsiAM9ReCP9lM8QydkPx1uHGeHnP/hiVUHOybrKYoNaCh 3JgZH9jHEItv9igfAmntt6mWtaQ4eoDZ0CB+TDhAhv8rML6vwgoyfQzruc0qPBGDkYiA nIzw== 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=r0WhI3ZnSrMduOxmiWXGoPuwFcsr3ovVUfm8TWIk7kKN2gfWy2+hba4DL74FDeuVop YJkfo9q2/ZTZ3PMDMyQenc0R+9PdtoKDWoXkcksCKfxu+Ww7UzGa5yTGSmEaPyQmSHfl Hz+/PdO1Wt5DlvGQviCCw7VTkuSwSoP5TCNfDkiYv3FB/8JwZqY9YRNBgyfEjMWuZOEk caM/WDrmCeF8jPVB0cgEopvU26gYOjrrAu73kCWRaL8AjhmlFr0DZ/ZjfaaJINRNEwNs yv3FvOcI/pbaExknPB372t0WeZWnTWlBgOmSXhOIY9N6AP3IGO0MQ2Vv9mclIVcatCQJ QgDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hwDrV73b; 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 17si1512319ejt.419.2019.10.09.10.16.53; Wed, 09 Oct 2019 10:17:16 -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=hwDrV73b; 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 S1732036AbfJIRP7 (ORCPT + 99 others); Wed, 9 Oct 2019 13:15:59 -0400 Received: from mail-yw1-f67.google.com ([209.85.161.67]:41443 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731948AbfJIRP2 (ORCPT ); Wed, 9 Oct 2019 13:15:28 -0400 Received: by mail-yw1-f67.google.com with SMTP id 129so1087876ywb.8; Wed, 09 Oct 2019 10:15:28 -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=hwDrV73b1Avzv1ol5VQppYlIxu1TTuEK+isNnmnLVblA+yhsovmwg7qYnyTKByvRgk bxQBvPvUqDA+O/nOpVN0alP2eBcA13VvqM9ZPTXHsrZ6LQX+HRL8Xn+aFGWapS8oNDA/ 4ZtueKBJmaHTQytL3ObzqT8QkEiiQEP92dIzfq5QpY8QxhNJlRwgXJJYdzeenEOJWI0D fAT1lp4Pb2d4MiBr/7vlbyopDjeQ2cq/qndfd0MvciDrk9Q/oavaITOhrxTaZuCxiNy7 LBTTeeJ8ubleTuZedOBOSJVn8h82ersc3dnGBCHLTpKiGR6RRPXyk3lXflTLge2UUwod nX3w== 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=gsvBQWCOMbAWKrVySRICQjWnUuMwpiro/yL5TVy1WVItuTHos/G3z+2neVSabTggtH XhLfcVRlS45E9aKgMBwAx5mm6qMjH96vUjc3L07r42rLgqNUYgfqg2idIHUvigFtdeMM Wlwd319DJzgGVE+9SL1ZnC7pWgm6KguCE8bUlvom/0+j/MJpKBUeGX3GPdeI641ZfE+B NlliVpN9rPJoEiW0/Bb/oR47Z7a7pKts/eB1KpzZnFtS49rA43lTeqNaytc1NSiTuXro 0kFW2wSil4Vau/IUFYVvkxUdwLt7PVH+shRX4B/TLb+bPmtYcK9gkOSa8zKQa1Y/QL9W IDAA== X-Gm-Message-State: APjAAAV6g8RyFaghwYWyGRQ6Xx1eAk7CUGe+VARVop4Cix5E29guBpvo /WQuM5UHlaxMv9/vhIZGGa7WPl47 X-Received: by 2002:a81:2d41:: with SMTP id t62mr3704519ywt.368.1570641327784; Wed, 09 Oct 2019 10:15:27 -0700 (PDT) Received: from localhost.localdomain (072-189-084-142.res.spectrum.com. [72.189.84.142]) by smtp.gmail.com with ESMTPSA id r63sm743292ywg.36.2019.10.09.10.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2019 10:15:27 -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, William Breathitt Gray , Geert Uytterhoeven Subject: [PATCH v18 10/14] gpio: 74x164: Utilize the for_each_set_clump8 macro Date: Wed, 9 Oct 2019 13:14:46 -0400 Message-Id: <7ea2df7182a50a1136ca36edc46dffcb2446fd27.1570641097.git.vilhelm.gray@gmail.com> 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