Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2357401ybp; Thu, 10 Oct 2019 06:19:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyrq4RAvt5al/be1+qYJD6+KdZEgZka/cmn6TSS4SgKUniggzTdYT9XimXgTs3xdjdANFDs X-Received: by 2002:a17:906:e89:: with SMTP id p9mr7940312ejf.95.1570713582658; Thu, 10 Oct 2019 06:19:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570713582; cv=none; d=google.com; s=arc-20160816; b=QGewjwlPGsx8qJft0VafNLKbPN+SL3qADNGmzZVcMdgzA5s6L0L1OLIos21lvvhbKk yfLX7LPluH+Japi4buW8bFWuc5ASP+OTPxE0pjJAUp9x/F8lF4hulgzunOslHEkMh27P OWXqVAczhnH2JZRqLRA3cPFnZGZf5LjFTciBwX9W/gufVklZ+htoxw5e+XBxVXYP69zi bN8nYx9++ydkxP20pS8vta8yCUKaFpbBuwsPbOzQGQxVj/U89NFCubzv02L+HDfvkGC4 VgyVHTNF1/mQf21hV2DdHzcKFxDn2Wkx7iKSnM6V/3Ew64UU8AixI4bkXKC+VeEEPB6j xt+A== 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=sH4nmYQYpt95Pj6heGQEorokoca4BkN5+slmyqKKC9U=; b=0bCIurJqm+7J+4/nwYW1GJhHFTGEh66r9TG7tIJezRdRFytfQNar+DoSbdsPROhV5+ 0MuaSu4bc0XqRz7GLVJnfz4N/JSxmpHxo6fDiWLvzYTmNII7Fd7ArzotXBHTqlv3sjMh fI1j0Bh9UbFYDWHhWuI3/m7NQJkCSx7Q872rASX5LG++0FWEVnB1DQJrb4yZZljN0st7 g18VHMBgKOq2vNlseVkDvlSy7BrvWRenIqXK1yiYzUHwAggKn/a7bjfygckKdbHsTLy8 yGUD03dZNGkkmqObFdCIFxOKcoLymnBazh3tc+e7s6dJfeM1kyITlt6EZs9GCyL/42Gq pacA== 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 e5si3147811ejj.70.2019.10.10.06.19.17; Thu, 10 Oct 2019 06:19:42 -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 S2387746AbfJJNQm (ORCPT + 99 others); Thu, 10 Oct 2019 09:16:42 -0400 Received: from mga03.intel.com ([134.134.136.65]:6261 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728286AbfJJNQl (ORCPT ); Thu, 10 Oct 2019 09:16:41 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Oct 2019 06:16:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,280,1566889200"; d="scan'208";a="187960124" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga008.jf.intel.com with ESMTP; 10 Oct 2019 06:16:36 -0700 Received: from andy by smile with local (Exim 4.92.2) (envelope-from ) id 1iIYJ1-0006gs-2z; Thu, 10 Oct 2019 16:16:35 +0300 Date: Thu, 10 Oct 2019 16:16:35 +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, Geert Uytterhoeven Subject: Re: [PATCH v18 10/14] gpio: 74x164: Utilize the for_each_set_clump8 macro Message-ID: <20191010131635.GR32742@smile.fi.intel.com> References: <7ea2df7182a50a1136ca36edc46dffcb2446fd27.1570641097.git.vilhelm.gray@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7ea2df7182a50a1136ca36edc46dffcb2446fd27.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:46PM -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 > Suggested-by: Andy Shevchenko > Cc: Geert Uytterhoeven > Cc: Phil Reid > Signed-off-by: William Breathitt Gray > --- > drivers/gpio/gpio-74x164.c | 19 +++++++++---------- > 1 file changed, 9 insertions(+), 10 deletions(-) > > diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c > index e81307f9754e..05637d585152 100644 > --- a/drivers/gpio/gpio-74x164.c > +++ b/drivers/gpio/gpio-74x164.c > @@ -6,6 +6,7 @@ > * Copyright (C) 2010 Miguel Gaio > */ > > +#include > #include > #include > #include > @@ -72,20 +73,18 @@ static void gen_74x164_set_multiple(struct gpio_chip *gc, unsigned long *mask, > unsigned long *bits) > { > struct gen_74x164_chip *chip = gpiochip_get_data(gc); > - unsigned int i, idx, shift; > - u8 bank, bankmask; > + unsigned long offset; > + unsigned long bankmask; > + size_t bank; > + unsigned long bitmask; > > mutex_lock(&chip->lock); > - for (i = 0, bank = chip->registers - 1; i < chip->registers; > - i++, bank--) { > - idx = i / sizeof(*mask); > - shift = i % sizeof(*mask) * BITS_PER_BYTE; > - bankmask = mask[idx] >> shift; > - if (!bankmask) > - continue; > + for_each_set_clump8(offset, bankmask, mask, chip->registers * 8) { > + bank = chip->registers - 1 - offset / 8; > + bitmask = bitmap_get_value8(bits, offset) & bankmask; > > chip->buffer[bank] &= ~bankmask; > - chip->buffer[bank] |= bankmask & (bits[idx] >> shift); > + chip->buffer[bank] |= bitmask; > } > __gen_74x164_write_config(chip); > mutex_unlock(&chip->lock); > -- > 2.23.0 > -- With Best Regards, Andy Shevchenko