Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2354890ybp; Thu, 10 Oct 2019 06:17:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBQX7pMNWtOGPPN+UaIOGioAG6mFTNUzBjLwywZVHP+hk9Z4JVYk74yz09A+7JxhLInvvn X-Received: by 2002:a17:906:4806:: with SMTP id w6mr8382184ejq.44.1570713467176; Thu, 10 Oct 2019 06:17:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570713467; cv=none; d=google.com; s=arc-20160816; b=Od7T8eUrM2j57MM+OCdrjEdnYzPy8gaaysMemSPo2QJF8XMKHvQd2V47bU58UU5yCW Lb17XjbLUnlLZz9ESTbNPsPEdtzKVicCWYZCVvJ0MJDjEYsfFo1HGhMqSjUMzk0NdqVH fIqUeiLg9BmjCWHzx6uEwEUWwlrRmrSgIdeSRnu3EhvOK8lsA7a6ODCp0FC0rUtputz+ VZNW/3NReVM08AaDdgWINog4NBnHdJqOEsegwtKayrcrOFvtUOzjJFDJUK3msiZe6D1g DLANL0DOULkBUcjSOnWoX55jCv5ILe4d875thcIbw0DBpyO9dXrpt9RYupxHVYO2mp+Q YGvA== 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=9nm2VZ96eFacoXWabmJTxU8oei3FmcihSVM8XPxrPSM=; b=R2NxMWqtBQA3RfmlJWamtIZxymfphX0WDqPGA4R7r1Frn0AyAVDvy5dl0Kk+dRDt9G o95Fln9/AzIyhOZYauJp6fXk0M58npQgds8wngR0iKBWMfPtnnR6HZe92PgmPIrUmo5w 0sshzyQs6RP5vKXBfNYcmoaJaY0CKt//diUZoIk6hRGD/KX+4qL0M2rrUtMVGk/htxdg 9wVFE6UOvsk5leENoiRFS8FOyd0J1HZvD9vyqoGwunApSXjJMKEmx+WO7LEOa5ratrFi bNegaHcjUFi6QeMcKqYdhcKKm0OhMunHLl/UnNnkOnWZIGZPrBuf4f7juroPb6qwN1rX O1sw== 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 a33si3453502edf.121.2019.10.10.06.17.21; Thu, 10 Oct 2019 06:17:47 -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 S2388163AbfJJNRB (ORCPT + 99 others); Thu, 10 Oct 2019 09:17:01 -0400 Received: from mga01.intel.com ([192.55.52.88]:43101 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388002AbfJJNRB (ORCPT ); Thu, 10 Oct 2019 09:17:01 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Oct 2019 06:17:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,280,1566889200"; d="scan'208";a="197245140" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga003.jf.intel.com with ESMTP; 10 Oct 2019 06:16:56 -0700 Received: from andy by smile with local (Exim 4.92.2) (envelope-from ) id 1iIYJL-0006hE-Cl; Thu, 10 Oct 2019 16:16:55 +0300 Date: Thu, 10 Oct 2019 16:16:55 +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 Subject: Re: [PATCH v18 14/14] gpio: pca953x: Utilize the for_each_set_clump8 macro Message-ID: <20191010131655.GS32742@smile.fi.intel.com> References: <3543ffc3668ad4ed4c00e8ebaf14a5559fd6ddf2.1570641097.git.vilhelm.gray@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3543ffc3668ad4ed4c00e8ebaf14a5559fd6ddf2.1570641097.git.vilhelm.gray@gmail.com> 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 Wed, Oct 09, 2019 at 01:14:50PM -0400, William Breathitt Gray wrote: > Replace verbose implementation in set_multiple callback with > for_each_set_clump8 macro to simplify code and improve clarity. Tested-by: Andy Shevchenko > 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