Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1075084ybp; Wed, 9 Oct 2019 08:29:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqymK9tXCgnhiezKxikPwNI74uN5jIe5bheUpCj0/M8AOCrLNtbRKxljAeI025ilJQQ8/4CG X-Received: by 2002:aa7:c38f:: with SMTP id k15mr3649855edq.100.1570634944113; Wed, 09 Oct 2019 08:29:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570634944; cv=none; d=google.com; s=arc-20160816; b=oYlWR6gf3bfI7N7sHbZyLIi9QTAQZjpZRUrzA3QEQj1hgIKx5QrDJlLMzZYShQmUwD vZr0YV0YjxW8VSxNWotSVG/bhQLjdomAmdFzaao9hrHe5ah/4oPgX3HCZEep91Xrddmt AoqgMu1G5zR2b9EfkDUeRo6M5IzR3+zsd33sSwiKge9PzCYOiBWQTkpapy4rvSJe0mjG yUsjgR0xVlATeBQQbFodt51PFCL6vo3H/QePHoeyp/pgkIskJl8eKM+RRQU7pR1vZrg0 ZPCgT9p3R5h3CgCTJDUPtBXNEwu6/QKqs2bOh86Uw7dUC+WurBxq1IxXBPIz1nscWX9v Sdxg== 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=TIsD27X04cefc4QEpIIDnE6M3VLzdX/SogH0k9LRMZOgwG9Ow9sLSDZ/bc93MfaOes dOvwZDydMM4rzTXI2crLJyIbvZo84tTDJbHOeq4hd1PDgJDIXfdInQE1cVpxywq35XZX 5nMgMau5uJMF+hSn8krPL/JGMfVsP/x1us+br1BBg9IZ+MeFUKAR9QoiIKG7IITuhv48 TjbC5rGjuG+qcxunknW6mljDMnD+wwxcp4AHSyrHbybGYiFnwcaCgcXptUFTEhaqpWM/ v2uCkSNx0C08NxLqPd7t2wZVcBkHQSjmB7n98pEnR9fC/o2BviRjQCpyQH519+wyGTu7 EKVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=M6XRUjfZ; 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 b13si1470926edy.320.2019.10.09.08.28.40; Wed, 09 Oct 2019 08:29:04 -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=M6XRUjfZ; 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 S1731823AbfJIP2B (ORCPT + 99 others); Wed, 9 Oct 2019 11:28:01 -0400 Received: from mail-yw1-f66.google.com ([209.85.161.66]:38417 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731800AbfJIP16 (ORCPT ); Wed, 9 Oct 2019 11:27:58 -0400 Received: by mail-yw1-f66.google.com with SMTP id s6so959687ywe.5; Wed, 09 Oct 2019 08:27:58 -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=M6XRUjfZq39AjkcgPSUAdckM2+dSQa7UVUtap+gSKdeq297uOsrTQOStLUzvs00Qrb 606E6Wl/7AIVW+481GiVFj9U70JbVhcT4rJQhU8u0cdjRd/ahDVXc08IZfHlfsRisU65 HUf/gtgrZDf8ucFfmS7yer7Q2ZO4chbV49OgeG+21rgNRnhnrhWYgbBCAc/TInIbmwv/ 1kQeiD7tPqfWieHEf4TGMLOkmFlM8tdMHUxPbTMWXppeJrqD/PuAwT34w/ZYKtG9VlRn zeCV/UDX85wFycgwSfM7h2+qKSN4ukBHcA7y8FcnEjOH1cWoWnqsTz0WE5j6yXxO/LoN Tf5g== 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=mnRUMoeAiKH+pNpo4CxoVSDIMGnFWRLt/yxZhbKxVw9rchURr/lsvSLvQsk0LP3e7V HMWhPwNBEaLPtQbQpKYAOZxUJII64ztBxsxpexdt8C7hGkCUAgBRIqQ0TY9t6ejFPcDW ShTpKE1gEy+Ex/RQlinJ0mpmTL8DEScijH392EsW1osRKXiqAD4FjLDU2GaKEBVBEA1c 23huAZ04BomRfVZyRA88WQYupsC2oOXrMfymCf4KW/VOM4ABSEtA0CW/mauFyWXdTXGU OyX+5c9fuhF/Ueg2sFbNAMSNaxwD8Fnhj3s4ciWvsOkATFD2QDITVlmzlDjj8WEBp7Qn JYrA== X-Gm-Message-State: APjAAAXJNvZm7jfKjHyABZSoC4K9MJeTslTI40QFdsXhNBwL3udT9aTJ Hj+h/AHwTFIPdwTaZ96meuM= X-Received: by 2002:a81:1ec8:: with SMTP id e191mr2994034ywe.447.1570634877541; Wed, 09 Oct 2019 08:27:57 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2019 08:27:56 -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 Subject: [PATCH v17 14/14] gpio: pca953x: Utilize the for_each_set_clump8 macro Date: Wed, 9 Oct 2019 11:27:12 -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