Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1201737ybp; Wed, 9 Oct 2019 10:16:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNU9XY5gVHZVRHB9OF40dY7SlKcav3tth/eQyG9RF3cIx8s+AqOiL+MtUPNeJFWCuya9PH X-Received: by 2002:aa7:d753:: with SMTP id a19mr4147296eds.80.1570641390735; Wed, 09 Oct 2019 10:16:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570641390; cv=none; d=google.com; s=arc-20160816; b=g5zfZGPPIyG7JfwjWAA+aICBORJlcpjz7uvkgDkpu/aYooWyY+XFhI5FSTApd+gsKs XUq6LNnOxYBT5IAgXCXtqlvFtbXmZUTMHbtj1CJ4vX9gdsVXFaViX4vrWL8sw/eJe2Pv 8IuoTh0c/48kpVH545H0Gk6wb1AM9KVtpgynJ6i8Wg5GplyXMCNUafJIsjLq52FXzeaQ Wux0uqe0PZgbLpCD4KHv2Sp0+RghPT+fx5lnSKj8oX6VfaekL32owDukDVQ84P9Rkjr5 ali9yhefVv9dUJx57va9+Y/xpXZu1E0EMlSySSQK1FHbMcy7zqPaFsNrCqzx5W687HXw W7Kw== 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=dY0ps12MEXzwjM2gLMAJY+ya/FG8xr/ro4V+433VKsm77d8YD6VoMS4BNYchsFr8xj u75tjGFulA2V0X1iqrnNTc7RfgR6qdLmuJXYmDb3GS2jDA46maPXgV7HB3ZxYEhnaqJi 1Ik3KzWvAwYqEq4V4HMe/qVxyNxbEJK+V9S0ANM2vWUqmkoB23Gu+xrv9AS6Yfr32P0D pJRxr6iMxj9raqgleEqi4KsBdJ0iM+qv+QbYou5Gy400QXnk8gq8Jm5rZW6B2vWvM7Uz hAEKTKgWgAl0nTuGzA8hcJt2AE6+vMztJSL30rNmC7Ljdidl+X29dGCfkfGy4pEN5mAG pt6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kdbV1nKB; 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 d23si1698460edb.55.2019.10.09.10.16.07; Wed, 09 Oct 2019 10:16:30 -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=kdbV1nKB; 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 S1732016AbfJIRPj (ORCPT + 99 others); Wed, 9 Oct 2019 13:15:39 -0400 Received: from mail-yw1-f66.google.com ([209.85.161.66]:36335 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731990AbfJIRPf (ORCPT ); Wed, 9 Oct 2019 13:15:35 -0400 Received: by mail-yw1-f66.google.com with SMTP id x64so1096084ywg.3; Wed, 09 Oct 2019 10:15:34 -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=kdbV1nKBX7QFRZZuqVlE1hddyif21obkYZGvk5fHtWvd6zoj6Pz93eZ+xnzRnwZjgS Nqvjk26iFkR4G8mVxThcXfh8q57/Pmn8tIVhB6h9M3pjsIcqrA2wZ8sJlc1753CAsMLP +JFodP7LOpcyFh9w4MnAX6uCZn7hhYk6rChrZ3eep/OSGHy+P8wGrf+g7RKM8wI9hk0c 5Ko7/NuVNnd8hm/WAN/JQlZamaAA/MKjpFNpkKDDQZyqFRxyXKoXbiXsnuQdMs8VaUbK H91vFRRQYM9IUkULnr7kOYNzEbwx+cC1IQX8UKP+c1wn/Tsjq/ey0WU6Fjvf+w/mhnFs i53w== 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=WAr4OTetn4hLKaD/oHy5t8SDipzh7xBZavhflzpV6g8EsH852L+nfc7OVdyQfPXB7w yiOFKHB4GAyCR2ayFRVPhA6cKIrnb9kR3gYUp/Hx8C/2aQpSZDfmpk4otkvc1Oe2LEeq 5gpcfkoBnbM19NrCsdBSE2EApV4RbxG30gDtSv9LXjyiEdzGf2sJzil78BoYXyzWSE8z zf/MGji+rFvp9Urmr6rStQfMcJYlbxS1oKv5e7ZJPQhEtJ7UdCSTBM18u/TEzatnvUws V/U0r/g6bQHdB2FHlLKBElcnObyK5gET7Kx+P/dwYpEl0aNJQ/bnT1bD6xS3cds+5RKa GkIw== X-Gm-Message-State: APjAAAW/5voUX4Wyrvc29laiB+1l91+/t76gwXm8twrbX1m69K+PeA3f i0mVDQydjywK7o/R9NdsY6o= X-Received: by 2002:a0d:d490:: with SMTP id w138mr3761909ywd.139.1570641334354; Wed, 09 Oct 2019 10:15:34 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2019 10:15:33 -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 Subject: [PATCH v18 14/14] gpio: pca953x: Utilize the for_each_set_clump8 macro Date: Wed, 9 Oct 2019 13:14:50 -0400 Message-Id: <3543ffc3668ad4ed4c00e8ebaf14a5559fd6ddf2.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. 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