Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3265366ybp; Sun, 6 Oct 2019 08:12:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzv+afZpxJCN5EVx9PIbsGdy22y87FuUVqI9xmo6qA/wB5LNUtgqhJU2CxOKJWumzdn+rvH X-Received: by 2002:a50:eb03:: with SMTP id y3mr25541283edp.194.1570374775713; Sun, 06 Oct 2019 08:12:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570374775; cv=none; d=google.com; s=arc-20160816; b=wrFCdaKRHm63WaiZzPduL1S9ip/H3E3CvTMrNC860z8EUY0t2EksQTjEAdP66DnotM n+ajfyaoJ+/+ABKWqDZc1p5mTjRVhERnmacKYSU0l5xFJIvPJP5X9s/YDyTXSUYp4e3z 6jUDP/uAsHmX2xv6DzsDcXv7Ycxjd8RwWlZ7Du3vo0SXlso189aMBD6+8ophyYsr64n4 RKg1N/JAtrvBzPHE7H+h80VuIpr2r6YGaQWrM+/ytHkkj5ox5abtXWEggrsQWTZnbOmC +xOZn74IpdNNfTtUp5ElyF53/4NFIfZMsyMpW9qST/62OuzV5CPgTPUihuMu3WG6qA/L z1Ng== 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=+D/uU8MO7mShW9teASkMb7bJZjWkGz/G9NDBF9ekIAA=; b=mRwyWs/p4Vs4m/PUzsJ/dJKLf1chfyjckmps4NYbpqsNScw7RPr/hB9iXm5/J2CpbU EPZ3XwWKyDs/PhLm+A7LzqAlVTFmMv6AfR8hxYnUeWRhi5EPqXy8viJ1R+sXPdzjJQmh Qo2fJL8C8W7/sg6EVc1K3ldJCm56jwoII00g42ylVd7WDrDiH1UAwIWkDvqWEZ5q6LKn PFbzAj+OoaNnqeZwZNTpfJII+zH6pEKJOP6AC0a7aK2SO9CHabcuqC3KrFjQPeO/a4Ai kN5LMEI6l/5CX/W06wmkJ3QMQ+GxtRKOKyWObi4s+Kt8+kHFKYSl4OvwO3+th9xoa5te oA1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bSaBzvAm; 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 f30si7558408ede.435.2019.10.06.08.12.32; Sun, 06 Oct 2019 08:12:55 -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=bSaBzvAm; 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 S1726975AbfJFPMD (ORCPT + 99 others); Sun, 6 Oct 2019 11:12:03 -0400 Received: from mail-yw1-f66.google.com ([209.85.161.66]:38086 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726875AbfJFPLx (ORCPT ); Sun, 6 Oct 2019 11:11:53 -0400 Received: by mail-yw1-f66.google.com with SMTP id s6so4177576ywe.5; Sun, 06 Oct 2019 08:11: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=+D/uU8MO7mShW9teASkMb7bJZjWkGz/G9NDBF9ekIAA=; b=bSaBzvAm7KA+Z/RsiMdo7RdD6lPZanjxLUuwHA3WYW2PklPBygtPZwz4rImtHSmqZC /HnjmIQeRebqFtRiVoceY8ds406L6UZJ1DYUz6ZGQMD3INfafFKEi+0wwYVbdhwnGQ4a bvIxyiWv7HzbHyulJAhvUugTqHm1U7VG2ajipNGF3dnH3fIqjZ5QJTm2Oq5C2bvtG91u mTeUEGBRdsPJ8krYvExNEWIcqP12Wr6LNuPVnkE9XcriRZf18Ct/5hZyXXXWy9yQF+98 l7ZGiLbhCnrhPU3yw8EGIF8ZkLWst53Ovm89jxBlqlzykMnTtxQIzw8KT+2DWIoapry4 NUhQ== 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=+D/uU8MO7mShW9teASkMb7bJZjWkGz/G9NDBF9ekIAA=; b=k+0MYw7cIXj2dtmbQ/yij8ruuhW9E7PP+qr4WWNO57jwHn4eD4fejlxVddpbm8nRdy JcPuQOmaqU7p0gy4oPAvsI2mgFN0a2NqcRXvlcv+xxt6jASUgc1fCcLU6p+jOAxpqX1T 6i3wFVOP4SFNDPFbBbbp2fjNPvh2JsTWfh6rB5PZEnm4XDuhlvMfXYHsn2VOwze1PH0D TWsLtE+MPrx8i/GE1VQkGPGilJVUFXXTUPPzXrXk/J1f9JIUYhNxR0qN+LLtBcAVPjMM +P0x5xHRJ6R+3MBlFo4laKcoqYbCNzPaDbI3FqcFU2I6KcCoS5adiUsIHD0TD+sg982v nHng== X-Gm-Message-State: APjAAAXD2aqqQlEZK+0bDZ0bipt93MYxMQ0ag8nK2BN028hUB5PNlbRQ KMskIxtHjmvUztWnAeXEC2o= X-Received: by 2002:a81:6bc2:: with SMTP id g185mr16996224ywc.316.1570374712617; Sun, 06 Oct 2019 08:11:52 -0700 (PDT) Received: from localhost.localdomain (072-189-084-142.res.spectrum.com. [72.189.84.142]) by smtp.gmail.com with ESMTPSA id e82sm2662434ywc.43.2019.10.06.08.11.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2019 08:11:52 -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-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 Subject: [PATCH v16 14/14] gpio: pca953x: Utilize the for_each_set_clump8 macro Date: Sun, 6 Oct 2019 11:11:11 -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. Cc: Phil Reid Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-pca953x.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index de5d1383f28d..10b669b8f27d 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -456,7 +457,8 @@ static void pca953x_gpio_set_multiple(struct gpio_chip *gc, unsigned long *mask, unsigned long *bits) { struct pca953x_chip *chip = gpiochip_get_data(gc); - unsigned int bank_mask, bank_val; + unsigned long offset; + unsigned long bank_mask; int bank; u8 reg_val[MAX_BANK]; int ret; @@ -466,15 +468,10 @@ static void pca953x_gpio_set_multiple(struct gpio_chip *gc, if (ret) goto exit; - for (bank = 0; bank < NBANK(chip); bank++) { - bank_mask = mask[bank / sizeof(*mask)] >> - ((bank % sizeof(*mask)) * 8); - if (bank_mask) { - bank_val = bits[bank / sizeof(*bits)] >> - ((bank % sizeof(*bits)) * 8); - bank_val &= bank_mask; - reg_val[bank] = (reg_val[bank] & ~bank_mask) | bank_val; - } + for_each_set_clump8(offset, bank_mask, mask, gc->ngpio) { + bank = offset / 8; + reg_val[bank] &= ~bank_mask; + reg_val[bank] |= bitmap_get_value8(bits, offset) & bank_mask; } pca953x_write_regs(chip, chip->regs->output, reg_val); -- 2.23.0