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=-5.4 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, 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 1E95CC43381 for ; Fri, 8 Mar 2019 08:57:03 +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 CB90A20684 for ; Fri, 8 Mar 2019 08:57:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gBQP4Mbb"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gHL3NkzM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB90A20684 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=kRZlxm26YzYnIyH9c/XdiYEOqsrgCVubXcSLeCQE60k=; b=gBQP4MbbF6rFXk vWCvy5ysDcAHvybI96PoioAFw+OCxnzvC/MKmxcgfzcpkEQmYeu4CquT9LFoak3agp27qdU+eThUM GI7dMMIp2czhb5buQVEqVqC5lOdZnFON61iWl6CdtNAwXGvYaq48TDfOFogVaOTo9v+frRVTBNU56 +X0eor2tITLGRiFKZYvB+6uxmOw3Zq2cbWtTE5ooxb6gKgVgNsHsVcuC/phLSPDUGuSJEitlRaSjQ OhioQqizltpL5F7FYLlcX15+mADVfHSzMkgQQYjrfJc2aYnaX+dgZgBIaVGef75ZODfskZG+7M4up MFuKBBNjkaI2qA5WvAog==; 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 1h2BJJ-0006AL-Cl; Fri, 08 Mar 2019 08:56:57 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h2BJG-00069z-Qy for linux-arm-kernel@lists.infradead.org; Fri, 08 Mar 2019 08:56:56 +0000 Received: by mail-pg1-x541.google.com with SMTP id i130so13633824pgd.1 for ; Fri, 08 Mar 2019 00:56:54 -0800 (PST) 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=EvaF26RI7c5HyTPz/s7fr3l3YkC9rN6qerGwkguRTR8=; b=gHL3NkzMk1rMibDf4b7nqUDivvpIM8faxWPoOea5c8ln2b9GzJbwW8+kqpdb3KQOVS S0ttHMbEGe3tlrF4cP3chkm3KHKGufEgDPpEDDqHkV2xTEEyDaB+35pywPK++4lc4cYt G3NjQ1JZXfQvS87kPipvCvbmUTwntS3owjOPIst5LqYyq/pMd+ZUmDsWsJleAuHpWJ/J +cap0A5siHiHMcJSbS1YotI/T0OAlaJiVKwHy10y4gYbs6i3ak87ruIjJa8vhKeQaYW8 Cb/iwj+81A1k4vA0pBEvuiMqyw/bZUTj0FZWGxIxCo42BP8SJgM9px39W3D6XBHqzx3p aGRA== 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=EvaF26RI7c5HyTPz/s7fr3l3YkC9rN6qerGwkguRTR8=; b=BV8MAn6mws4BcHkB1XN5jSXbE7lg4P50XbD7FWwVtfxdGof5F0287fZXLFjlmkceBT qnvJIA2bclsvGOs1g68EsMgSVr8cDIwc54kuLkoBxl2neWJ/2FiJSqBmby3bCySv7DNw fozSFhVnxoOpac66ufYWnhJFCRFvV6DZ6ev2VuNLQsj55ur8aqDaobhYmP8/lC1tcE8A +ZJX+sUjEtmRuM1QDcFrIYAJBOG23jgx7DXDZWfUOwO2eWGgfHNsq0V4RTWAo0n+EZSj XxsTUlC5ymdkvNUPdXMs9CWPlqKjd1lyrAEntTYe13EzwUov3OAGKLuEuq/NYHfzGFB/ nR4w== X-Gm-Message-State: APjAAAUl3J3DhfWaWn9SdKtY+VtjWSayEbcxCuzi7Qxqttw4vaBlSW4l 5/xNHyf/u1vyN7BTqVnssNU= X-Google-Smtp-Source: APXvYqxjNo60pDjliav6Hb6c59I3IewkFpnQk8a3UZqoyEjjf0blzslJRWbMbT5LxTFtZoONDR90wQ== X-Received: by 2002:aa7:8497:: with SMTP id u23mr17544958pfn.253.1552035414114; Fri, 08 Mar 2019 00:56:54 -0800 (PST) Received: from icarus ([2001:268:c0a4:4f3d:c70:4af9:86e2:2]) by smtp.gmail.com with ESMTPSA id n10sm9524340pfa.139.2019.03.08.00.56.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Mar 2019 00:56:53 -0800 (PST) Date: Fri, 8 Mar 2019 17:57:33 +0900 From: William Breathitt Gray To: Linus Walleij Subject: Re: [PATCH v9 1/9] bitops: Introduce the for_each_set_clump8 macro Message-ID: <20190308085733.GA3903@icarus> References: <12b3a364ac7fc32194fa6f55911dd800aca92a56.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-20190308_005654_900373_65BB9BD8 X-CRM114-Status: GOOD ( 20.88 ) 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@vger.kernel.org, Arnd Bergmann , Masahiro Yamada , Rasmus Villemoes , "linux-kernel@vger.kernel.org" , "open list:GPIO SUBSYSTEM" , Andy Shevchenko , Bartosz Golaszewski , Andrew Morton , Andy Shevchenko , Linux ARM 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 Fri, Mar 08, 2019 at 09:31:00AM +0100, Linus Walleij wrote: > On Sun, Mar 3, 2019 at 8:47 AM William Breathitt Gray > wrote: > > > This macro iterates for each 8-bit group of bits (clump) with set bits, > > within a bitmap memory region. For each iteration, "start" is set to the > > bit offset of the found clump, while the respective clump value is > > stored to the location pointed by "clump". Additionally, the > > bitmap_get_value8 and bitmap_set_value8 functions are introduced to > > respectively get and set an 8-bit value in a bitmap memory region. > > > > Suggested-by: Andy Shevchenko > > Suggested-by: Rasmus Villemoes > > Cc: Arnd Bergmann > > Cc: Andrew Morton > > Reviewed-by: Andy Shevchenko > > Reviewed-by: Linus Walleij > > Signed-off-by: William Breathitt Gray > > Andrew: would you be OK with this being merged in v5.1? > > If we need to move the code to drivers/gpio that's OK (though > I think it's generally useful) but I need to know to proceed with > the William's nice optimization of these drivers. > > Yours, > Linus Walleij I was waiting on Andy to suggest some examples out of the GPIO realm, but he may be under a heavy workload right so I decided to do a quick search for one. In drivers/of/unittest.c, there is loop across a bitmap in the of_unittest_destroy_tracked_overlays function: for (id = MAX_UNITTEST_OVERLAYS - 1; id >= 0; id--) { if (!(overlay_id_bits[BIT_WORD(id)] & BIT_MASK(id))) continue; This section of code is checking each bit individually, and skipping if that bit is not set. This looping can be optimized by using the for_each_set_clump8 macro to skip clumps of nonset bits (not to mention make the logic of the code much simpler and easier to follow by reducing the code to a single line): for_each_set_clump8(id, clump, overlay_id_bits, MAX_UNITTEST_OVERLAYS-1) The for_each_set_clump8 macro is not specific to the GPIO subsystem; I just happen to use it in these GPIO drivers simply because I am most familar with this section of the kernel (it's where most of my contributions occur afterall). Consider this, if I am able to find a use for this macro outside of the GPIO subsystem within a matter minutes, then there must be some benefit in allowing the rest of the kernel to use the for_each_set_clump8 macro. So let's put it in bitops.h rather than restrict it to just the GPIO subsystem. William Breathitt Gray _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel