Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1074954ybp; Wed, 9 Oct 2019 08:28:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKkcRQnIRB18oVS8ZJ4QyZklYGv6itJ2+/d7IGzr/zIb7REh4USDpOS/Kf29igbpbCvTn7 X-Received: by 2002:a17:906:80cd:: with SMTP id a13mr3476691ejx.12.1570634936536; Wed, 09 Oct 2019 08:28:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570634936; cv=none; d=google.com; s=arc-20160816; b=zhtIq7mPIXoCtYWff5ZATJUF8IrcHWLw1HwSJnTXAJ7gHbyTeMU+5FvcK/kLaq+nq/ WiyJU3vbZINwXktH4txZO0p4r/bq7Gd5pnfSL1NSWt33fyzgSppdFpvVuDH9U5J/bWyJ jgDaRUvdNd3oKUdBa0S1/Wox5dErKb8Ux2EBKxd2+mtbSrq9mwbJZ/mOoFhHVkRLne3L 9uluuXtv3ee/SSB0S+QuMgzDpL8H6FfU1nX+Aia2FhC2bxzrOvxH9OHnTUEd8JEzyTfn zTKCYSkmRqzLXUb/Xxt4jD+Jk80Ex5xaoJ6a5WaJYHGx5c3p/qcIvx4HWAaRrjL4ZaL9 66hw== 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=OQMsvrMqAN5cYMrSu91Pu66B0Sg+HB0aWPXdvZz2KcA=; b=pq1QrtneNf1Xdz4NK5amvIAc9WAYKCoLwB2DJZw943+C8inFscZRxN/FQXUf7eImFB sH3yOt4eOH3+ZbzLELTrDQylzSo0AKr3hFnSI6Kq94UhdqrAcNpqTndx8bec/I5KYWbc MjbTA/UaaWJc6csEbNTa+IgpBMkgi7HgrwRwdQNEZGMXjAlylWQTddIMevksYfD9rzZ9 Qjt8cq9hnUNkUi9mfedAk8XBXT/91sH8eHUTY6qwQprEL3Qv1cDAB1V1wPOY3+2RJ+Wf 0DyAL7XPGjzgXBmE13owGxGIAcIceKOmWOHPCIVVL3+cMC60QepgvZhsunnuLlC9zNkr 1S5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=r+SUHFOZ; 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 h13si1362526edw.348.2019.10.09.08.28.33; Wed, 09 Oct 2019 08:28: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=r+SUHFOZ; 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 S1731814AbfJIP17 (ORCPT + 99 others); Wed, 9 Oct 2019 11:27:59 -0400 Received: from mail-yw1-f68.google.com ([209.85.161.68]:45197 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731788AbfJIP14 (ORCPT ); Wed, 9 Oct 2019 11:27:56 -0400 Received: by mail-yw1-f68.google.com with SMTP id x65so944371ywf.12; Wed, 09 Oct 2019 08:27:56 -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=OQMsvrMqAN5cYMrSu91Pu66B0Sg+HB0aWPXdvZz2KcA=; b=r+SUHFOZ26RdG6VxUf2qcKuuetu4H5Jy71X9gc45BPmyGIWDg+m2ICnyeTlBpzTaYy CJkhi1YwtYAxMoW2sb6vh3kuTTCfvBmqCwee3qYMm9xq9sebu8z28QBS9rsm9eXEa51A ub0qbTjI1gW3bcXOW4Eyo5fCs+2Re21sEbFuCcGQBVDxubUvTdPwINl476Z4v1Vj9XdB H7VyPRNQhG6wbT+vhq1A31C3lYT6kFCpppGlzRPxPly3PC51nS0pThzV8ALxXAWBqubq vWhmV++0papriWbPkg1Fa2NPp+EazD8WfSX4yTy8E/IOYfTMd4pKaHju+rZ14PSsS8WY qQfg== 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=OQMsvrMqAN5cYMrSu91Pu66B0Sg+HB0aWPXdvZz2KcA=; b=Ez5Pj0opTBEkIDOBOijxqvDQa2MAPSKPgzmcXCEkebC7mNe7zzxP/rbvimunrXSQtT d/yS/iXBfXu3z015U74IRRAZLvP4cSw58aSZTlhFnuo611l7qMJVg1gMFBo9xhCC5rfU mRic9EkIRge8x4OEt9g8ycfCFPkgbgc6fRy428DqPG6KwPFIWSlQEMIt3+ov0Yr9yNCd pc7fgMDuqS/ofQlklA4D9tesRddSDMDrTG2uZFXAKPe8MsHMgkDUH0iAtG0VmqKOQXTX gWQMiUEo+pbqdgRhd0ekKHEKbTLRVp9tUZaR8Uf23Qp3uoSFUT8ZmTsHqZ9URzYu7SDJ YUyQ== X-Gm-Message-State: APjAAAX/4vKPwWYIZY/B3pfr/8ZBoHeDY0vndMf1GH4aBJ2tHqyrDZYR h3y61CnCYvC3aUAB0Zqyj/I= X-Received: by 2002:a81:5d5:: with SMTP id 204mr2951452ywf.441.1570634875666; Wed, 09 Oct 2019 08:27:55 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2019 08:27:54 -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 , Mathias Duckeck Subject: [PATCH v17 13/14] gpio: max3191x: Utilize the for_each_set_clump8 macro Date: Wed, 9 Oct 2019 11:27:11 -0400 Message-Id: <84b39366ee561aa63214bf3e74716d821157c531.1570633189.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 get_multiple callback with for_each_set_clump8 macro to simplify code and improve clarity. Cc: Mathias Duckeck Cc: Lukas Wunner Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-max3191x.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-max3191x.c b/drivers/gpio/gpio-max3191x.c index 4b4b2ceb82fc..0242c6187bf5 100644 --- a/drivers/gpio/gpio-max3191x.c +++ b/drivers/gpio/gpio-max3191x.c @@ -31,6 +31,7 @@ */ #include +#include #include #include #include @@ -232,16 +233,20 @@ static int max3191x_get_multiple(struct gpio_chip *gpio, unsigned long *mask, unsigned long *bits) { struct max3191x_chip *max3191x = gpiochip_get_data(gpio); - int ret, bit = 0, wordlen = max3191x_wordlen(max3191x); + const unsigned int wordlen = max3191x_wordlen(max3191x); + int ret; + unsigned long bit; + unsigned long gpio_mask; + unsigned long in; mutex_lock(&max3191x->lock); ret = max3191x_readout_locked(max3191x); if (ret) goto out_unlock; - while ((bit = find_next_bit(mask, gpio->ngpio, bit)) != gpio->ngpio) { + bitmap_zero(bits, gpio->ngpio); + for_each_set_clump8(bit, gpio_mask, mask, gpio->ngpio) { unsigned int chipnum = bit / MAX3191X_NGPIO; - unsigned long in, shift, index; if (max3191x_chip_is_faulting(max3191x, chipnum)) { ret = -EIO; @@ -249,12 +254,8 @@ static int max3191x_get_multiple(struct gpio_chip *gpio, unsigned long *mask, } in = ((u8 *)max3191x->xfer.rx_buf)[chipnum * wordlen]; - shift = round_down(bit % BITS_PER_LONG, MAX3191X_NGPIO); - index = bit / BITS_PER_LONG; - bits[index] &= ~(mask[index] & (0xff << shift)); - bits[index] |= mask[index] & (in << shift); /* copy bits */ - - bit = (chipnum + 1) * MAX3191X_NGPIO; /* go to next chip */ + in &= gpio_mask; + bitmap_set_value8(bits, in, bit); } out_unlock: -- 2.23.0