Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1801059imc; Tue, 12 Mar 2019 00:29:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqziv6WAOe8MjhhMpFpKdbD8ISz/87ArpvXxf0wzTeb+qzg5eT0KTeLds1179t6C/YHUULBx X-Received: by 2002:a63:1d65:: with SMTP id d37mr1141375pgm.254.1552375766939; Tue, 12 Mar 2019 00:29:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552375766; cv=none; d=google.com; s=arc-20160816; b=N0Xk5VpI4pjVnS2cSmX8gH4sMR4pJjFD+5adXY/64c2y5HdgT4+rlLeF1DYaG499IO 5hf3Hf5DMCVkhZDymWcuVWa8Nr48sEnMlH7SPOmF8HPtDh0N9Ac7FRvhaLmi+SCTeq/y ajVMKf2JOXAv5R0Sv1ALhIn/GOjO6T1s7XnEyrARmUQayb/hUS4Wxkygj4UxGUcZdaL6 r5uGHctcilxR8znvK7cm4V5liy7lAJRaOXX7bpcaqQD5aC0ExkOiXihbE1rohGLsZfnu ODsr6NpbbHse/utIjoZZxJSF0mcRlyIV5hFglbG9SXsJeaDlytuNF0oXwGDOofhra1hE 7JfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=pGH9hXHyWER1pzm+u0uu4GolUUMTfbEFKb7Hx7Ab1a0=; b=HMnpmbSUQznncx4CJ1YRdQgghXsEi6fGeKiD3I/MQOeP7hVfZSwvEz0y2z471hq1AJ WEqzCuuxdsb2gcH1KQwPrbvNjfRNSo3INri2DLEHvTiO9wrBYMrxRsj63LMc29JZEERO Av62XQejB29b6+lp8Rx5Qm8DfCu6q44yPiFMMWlk+d0iD9XMSjuvv2C1JD3aIyMXNj2P uJ2vNCTQO5chO+9KyiLNbVjsyqSAsUe4QDrYNXkiVFRa6oyD87t0uNELowNOpLNay2X/ v0ZtvUmge58etnKyihdv8vRKNN0bdskaOv5jx3G9vNHOBnfBr0Q9TC30kiAP9/wSxSOu 495w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=POqBjfSp; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q23si4018047plr.79.2019.03.12.00.29.11; Tue, 12 Mar 2019 00:29:26 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=POqBjfSp; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727286AbfCLH23 (ORCPT + 99 others); Tue, 12 Mar 2019 03:28:29 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:54717 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbfCLH22 (ORCPT ); Tue, 12 Mar 2019 03:28:28 -0400 Received: by mail-it1-f195.google.com with SMTP id w18so2800214itj.4; Tue, 12 Mar 2019 00:28:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=pGH9hXHyWER1pzm+u0uu4GolUUMTfbEFKb7Hx7Ab1a0=; b=POqBjfSpw237O6zafNWy3TXebdvmelN33JuEv5KOCALT9ol+B/rxb4LDXQuYaMJGlC xZgePmcPsyMY0bYQGexZjA9D1iVHXUnnWuOHrPbCAQ10zrWvVl0Ty4nfnQCVaAXELYOh gm0oT1hkqUrz1vBdkh/lVSCcAQnSHn0PbBPK7/6ZajJXipCxRgX16tVwT4eH882nOg5s GRB526Q82bw/W0Hr2zF9SiLHr5Z+GX94caJXdFhRJOXX7awyBZD9byQb4kS+LbB9qxbW hAyxHE/KRmQ4LQ+9E9bosXTYrlagNZ5Rc8rgb3+/B+aFc2SGAPy4pWHnxlh7Nfb/e9di 6WMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=pGH9hXHyWER1pzm+u0uu4GolUUMTfbEFKb7Hx7Ab1a0=; b=UWxfZTipuWcaeIWRS1NU7KsKYRHC3//c+pAbLPi/Z40ghNUeKDj+aWpcTkNGcT99vh wjss9ys66gRvKb1QPevP9Vf83ezNfS23CqC6O4HMmViaOobIDqMTb0SZfw9iFFXw4v8N 9Fp3lBdpG78vweR47qsFPi7dk2tZZVDbkJ6JAcFnygOr3LaH+YT04nQd+nzm0LM7vOYa 8dSJPhQ/up2t75g7Zoye4lt+2uBOeedARBuIyUhlGzszJNaKib9K19R1NF6kYtvCQJ1l EhE5C02PgVHwhrgQXqYnpKOWv81hBObTdxoYm/hWNCDkqugLW0kI06JqO9O+lHCtwJwL nAnA== X-Gm-Message-State: APjAAAVjSr9NtvyokSZy5puzcB0J4STKf7foo1Jh0gH3OoD8utCgCOup AfPjSNmRqsTF39PPreXdOXs= X-Received: by 2002:a24:7d94:: with SMTP id b142mr1223093itc.136.1552375707571; Tue, 12 Mar 2019 00:28:27 -0700 (PDT) Received: from icarus ([2001:268:c0a3:c255:c70:4af9:86e2:2]) by smtp.gmail.com with ESMTPSA id q133sm934219itb.19.2019.03.12.00.28.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 00:28:26 -0700 (PDT) Date: Tue, 12 Mar 2019 16:29:23 +0900 From: William Breathitt Gray To: Masahiro Yamada Cc: Linus Walleij , Andrew Morton , "open list:GPIO SUBSYSTEM" , linux-arch , Linux Kernel Mailing List , Andy Shevchenko , Rasmus Villemoes , bgolaszewski@baylibre.com, linux-arm-kernel Subject: Re: [PATCH v9 9/9] gpio: uniphier: Utilize for_each_set_clump8 macro Message-ID: <20190312072923.GB2898@icarus> References: <0840d55707dacd1121659723246fa9f55737f426.1551598603.git.vilhelm.gray@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 12, 2019 at 01:36:57PM +0900, Masahiro Yamada wrote: > On Sun, Mar 3, 2019 at 4:51 PM William Breathitt Gray > wrote: > > > > Replace verbose implementation in set_multiple callback with > > for_each_set_clump8 macro to simplify code and improve clarity. An > > improvement in this case is that banks that are not masked will now be > > skipped. > > > > Cc: Masahiro Yamada > > Signed-off-by: William Breathitt Gray > > --- > > drivers/gpio/gpio-uniphier.c | 16 ++++++---------- > > 1 file changed, 6 insertions(+), 10 deletions(-) > > > > diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c > > index 0f662b297a95..df640cb29b9c 100644 > > --- a/drivers/gpio/gpio-uniphier.c > > +++ b/drivers/gpio/gpio-uniphier.c > > @@ -15,9 +15,6 @@ > > #include > > #include > > > > -#define UNIPHIER_GPIO_BANK_MASK \ > > - GENMASK((UNIPHIER_GPIO_LINES_PER_BANK) - 1, 0) > > - > > #define UNIPHIER_GPIO_IRQ_MAX_NUM 24 > > > > #define UNIPHIER_GPIO_PORT_DATA 0x0 /* data */ > > @@ -147,15 +144,14 @@ static void uniphier_gpio_set(struct gpio_chip *chip, > > static void uniphier_gpio_set_multiple(struct gpio_chip *chip, > > unsigned long *mask, unsigned long *bits) > > { > > - unsigned int bank, shift, bank_mask, bank_bits; > > - int i; > > + unsigned int i; > > + unsigned long bank_mask; > > + unsigned int bank; > > + unsigned int bank_bits; > > > > - for (i = 0; i < chip->ngpio; i += UNIPHIER_GPIO_LINES_PER_BANK) { > > + for_each_set_clump8(i, bank_mask, mask, chip->ngpio) { > > bank = i / UNIPHIER_GPIO_LINES_PER_BANK; > > - shift = i % BITS_PER_LONG; > > - bank_mask = (mask[BIT_WORD(i)] >> shift) & > > - UNIPHIER_GPIO_BANK_MASK; > > - bank_bits = bits[BIT_WORD(i)] >> shift; > > + bank_bits = bitmap_get_value8(bits, chip->ngpio, i); > > > > uniphier_gpio_bank_write(chip, bank, UNIPHIER_GPIO_PORT_DATA, > > bank_mask, bank_bits); > > > Please do not do this. > > Nothing in this driver says the GPIO width is 8-bit. > > You are hard-coding '8-bit'. The for_each_set_clump8 macro is hardcoded to 8-bit clumps because the current drivers utilizing this functionality are only updating their GPIO ports 8-bits at a time. However, if this driver updates more or less GPIO at a time, we can easily update the macro by replacing the hardcoded '8' value with a variable, thus giving us the generic for_each_set_clump macro. How many GPIO can be updated at a time for this device? William Breathitt Gray > > > > > > > > > -- > > 2.21.0 > > > > > -- > Best Regards > Masahiro Yamada