Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4004955ybp; Mon, 7 Oct 2019 01:25:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1APkbAD72MVE+g+1BaW3vqAjOc68zKXW/zVEmSyBY6IMynre6Sx1PiU/34vFlEs6ZuUGH X-Received: by 2002:a50:9402:: with SMTP id p2mr27804465eda.111.1570436715699; Mon, 07 Oct 2019 01:25:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570436715; cv=none; d=google.com; s=arc-20160816; b=rNGB9mgpH1OLYwlW9i1UfA6PVqou7HPQn+4x9JPBHLaQ61a48HOsBQvN2TafLEzBf+ SrM0jKUAvZ5ZWUfMSYfrb3jabfZUQH6+yRWtts2VXwN0p40SHiLY6J5xMJ7STuVdjZSB 5dmQ663J8jXMW0y47vw0035bD7eBveZAutie/I12rUV4KQ5ECiNf8CZMhQIKNC6O1be0 DXFJNV1vzy2P9n9em2qWssG/bLwpPhnHV0dGaEZnbqX/MPgeMVFJUOkTylx4ywLUdzJc EH3cgL6sfNY2fUVpAOCfxA7yPs/Sp5ma8LlYrHNDqetTZoG2RneLmmNmYZB1NHHMaasN 91sQ== 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=9qiOeBhp/yMNT4Y2Z6MnyL30aLj8gVC35ZrTgBKQE3g=; b=pwb3R1Hl2vjPygrQ2/6bfeatXIETy00eVTUeBcGbLiq8+N0l818RwNBhFCJlu9UQIt R/CJiYb3WZmEKP66/tY6p8m+7PwLdszksERJ5hJ6VlE62chg5urKdgUzzHA5Q1ICUKsI dNlVNszw8CjvNcR4yGDwIAieatLsECin7dOg2ESovXsL9SvphKH/Haxtw5sjjAuGMiX1 HV9ZXA3fk7Kxpz/g8v69E2xNBqRbWMleb9noz8yc0JJVjA6P7Ce+Y7z/2d2nGPKHsvEX ET98HG03E5DG5Q5WZQ3/d5e4T4E6lwLATcUh/OuKx84+GlQUiVw+Z0DwTDPiPd6lWywN 69Bg== 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 np3si6606338ejb.384.2019.10.07.01.24.51; Mon, 07 Oct 2019 01:25:15 -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 S1727302AbfJGIYe (ORCPT + 99 others); Mon, 7 Oct 2019 04:24:34 -0400 Received: from mga11.intel.com ([192.55.52.93]:56608 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727028AbfJGIYd (ORCPT ); Mon, 7 Oct 2019 04:24:33 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Oct 2019 01:24:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,267,1566889200"; d="scan'208";a="222841357" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga002.fm.intel.com with ESMTP; 07 Oct 2019 01:24:28 -0700 Received: from andy by smile with local (Exim 4.92.2) (envelope-from ) id 1iHOJf-00059c-CT; Mon, 07 Oct 2019 11:24:27 +0300 Date: Mon, 7 Oct 2019 11:24:27 +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, Geert Uytterhoeven Subject: Re: [PATCH v16 10/14] gpio: 74x164: Utilize the for_each_set_clump8 macro Message-ID: <20191007082427.GM32742@smile.fi.intel.com> References: <13f5d24820e5e3a17a64d025f09efc37eda77739.1570374078.git.vilhelm.gray@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <13f5d24820e5e3a17a64d025f09efc37eda77739.1570374078.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 Sun, Oct 06, 2019 at 11:11:07AM -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 it somewhat later. > 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