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=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable 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 046CDC43381 for ; Tue, 12 Mar 2019 07:28:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C1DFB2147C for ; Tue, 12 Mar 2019 07:28:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PlyuAboX"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="POqBjfSp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C1DFB2147C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mT0rcZfAdnuY9tx8uzLGoxxcRa3Lo6BlISoyP4HM+ao=; b=PlyuAboXFQU5hu c0ycOoMxYKIFYOyITNZmzJBdGyKUfnMiMMYQDU/P/SWBNXyEGvVbIKKVCwf3wxGtCXVIQ2NMcDB+J b4Ci9Y2/ZHGt+jtDrmyQ3KX6i9gnKOCuty6zz4r6hoGv7htrBh6cDpvGafNn850FT/iGbUnceNU4/ oCJ7aq9hWG1VX1eQKLhymyCmlUVEwdfJA1QMgmwKjT9MpGS27BDDiTDrSJwFzFZTXAT0Q0DRKOHok xzLFdattQd9HZ6Pm6/e83bWwRejAWfMU5GMeWAlO8AqVGEQrNqhibV9serrIbXAKSkTpGpTtJPesc ax/QTaa/Rf+dg0PCk04A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3bpv-00032D-D5; Tue, 12 Mar 2019 07:28:31 +0000 Received: from mail-it1-x142.google.com ([2607:f8b0:4864:20::142]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3bps-00031p-I9 for linux-arm-kernel@lists.infradead.org; Tue, 12 Mar 2019 07:28:29 +0000 Received: by mail-it1-x142.google.com with SMTP id z131so2784418itf.5 for ; 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=DtZ/LgMsXyesuZy5Jwo9EsT7Gav3EyRPlQqdGveagUL4IGHhnveUYJ3olgzu5+YrQ5 dh3N8CPxqJfGhkbG0JstZoLLn6YbmZaQpuns5+bLX2N/PkrqAVYm8WG6SfgMfAL1cD3O AQqtKlN3DbQLJq9RUDI/Eqf7BlDIh5wF3E7lIEhG+kPnCROBO4OTjIeZ9ufq/gKk1Y65 znpahRaADf0jIBRtrbpc3aDnnLuSuifbAmKH6RlDcDg2+WDf20pzTpdzdFU2XAtPP2rX VqW9MNdpgG0UZ8I8WghllpYhZDMn1r26PtLyzBW8uIyL6+lR9JOm0w4jqkSArfsmKpRI VXAw== X-Gm-Message-State: APjAAAUlkVi6S3tSJHmo7iZ5tItWNJJSFGL+pBlz92qQg7+09yua3b7m Z9p6RbiwcDA6p8R4ZtcdZCA= X-Google-Smtp-Source: APXvYqxHmJIesELkAUVHhYJBu7fCXcjUEEHHegnqY/1JirI+FJjFiyvRjFogljWslviP9cCxbj3Lnw== 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 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-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190312_002828_596715_47B61FCA X-CRM114-Status: GOOD ( 21.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch , bgolaszewski@baylibre.com, Linus Walleij , Rasmus Villemoes , Linux Kernel Mailing List , "open list:GPIO SUBSYSTEM" , Andrew Morton , Andy Shevchenko , linux-arm-kernel Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel