Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4021153ybp; Mon, 7 Oct 2019 01:46:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqza0D8DST8G60mHX7Ap2iSdV6oo1vwOTQmgwZmn9gOwz9bxkAaDxzQa5AL58bD4x/KfoG3R X-Received: by 2002:a17:907:2118:: with SMTP id qn24mr22220947ejb.81.1570438006754; Mon, 07 Oct 2019 01:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570438006; cv=none; d=google.com; s=arc-20160816; b=GchH2PdgKqTTYoejYhQszV82xBA4NJo5KUVHHRYFabzrFY6EzXa1v+2xwgasl9q9mB Kip545qA/Vjp1RHJY6iMl6K4X3CkodK9O+u4FQNk5A7HQg7YVK2eRZq3hZimlyYaOE71 cfS6naBScJxsZTe2+ErZR09a7dL+IVQnAaEPKh2B6flL8FNzBKra0GfGeb9p9B5c6105 vXcmsziRFXGaLPWme+oISMZak5Nz824gGSp+o0ESOm/GgCtic88FwOpFkQRd9CMoTttX 7Wkz2dI3YQ+OBsK+HJOVy2IbnZHh7vCulng/L6uVww4SiLmB3i57Cwxcw9AHT+RvedgE AVMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Z9CPiavHzPUiyhMW95LRdcuULV+s9JsR8uCIylg8p9Y=; b=pvISSoX48ROTxC5+G+k8VwucD2DCaJtjgQoX1Ng3hJfZMpvjsySeR56VjooTvWU6+m Jnup3ZA0j5lKltV4BO55BIEy1JPDPQfsZ6KIAzlQVJYxzmfGLEuxS4xpm9drTe92rIgk V31hYQQnOC2qJH0DUtfK3+1gp/wpKf5L99oCr/Ge9xifTpvzU05qEaMqzGPHUW5Xk6gy UglDnRuf+56inbNwyfcye69ObdiPvH2byjuSosZNieWfkv0qRthRk8Kd40y47iiNwrXh +Atc1cEGLbVRV4fSv6JR1KrwfoTk3bsiJV2YpefeVM8Tm+deoDoZtZJIL2CF6i8hXm1F PMsA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y28si8383251edb.162.2019.10.07.01.46.23; Mon, 07 Oct 2019 01:46:46 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727372AbfJGIpw (ORCPT + 99 others); Mon, 7 Oct 2019 04:45:52 -0400 Received: from mga11.intel.com ([192.55.52.93]:57972 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726010AbfJGIpw (ORCPT ); Mon, 7 Oct 2019 04:45:52 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Oct 2019 01:45:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,267,1566889200"; d="scan'208";a="192226354" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga008.fm.intel.com with ESMTP; 07 Oct 2019 01:45:47 -0700 Received: from andy by smile with local (Exim 4.92.2) (envelope-from ) id 1iHOeI-0005Oq-FC; Mon, 07 Oct 2019 11:45:46 +0300 Date: Mon, 7 Oct 2019 11:45:46 +0300 From: Andy Shevchenko To: William Breathitt Gray Cc: linus.walleij@linaro.org, bgolaszewski@baylibre.com, akpm@linux-foundation.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, 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 Subject: Re: [PATCH v16 14/14] gpio: pca953x: Utilize the for_each_set_clump8 macro Message-ID: <20191007084546.GO32742@smile.fi.intel.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 06, 2019 at 11:11:11AM -0400, William Breathitt Gray wrote: > Replace verbose implementation in set_multiple callback with > for_each_set_clump8 macro to simplify code and improve clarity. I can test this along with 74x164 at the same time. > 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 > -- With Best Regards, Andy Shevchenko