From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2EE3C10F14 for ; Thu, 10 Oct 2019 13:17:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8FBD92064A for ; Thu, 10 Oct 2019 13:17:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388146AbfJJNRB (ORCPT ); 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