Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3048129img; Mon, 25 Mar 2019 02:40:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkMOZlJCljIYxyUVmXqt38IM4XcSXWa+Hfp2T+xKZU6uZiCLTqrBbNeptp9kDlkrQYStT0 X-Received: by 2002:a63:1912:: with SMTP id z18mr22959805pgl.115.1553506803593; Mon, 25 Mar 2019 02:40:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553506803; cv=none; d=google.com; s=arc-20160816; b=Eu6TFplmSo5Ly+LBm3Qr+AVNvhzgjVNezrFjRjMUFQKJkgUTAk65ECACIRtgt7Ybsz PFQxmxFBqLTfeXuXMYTudHsBscTy0oNNpo2Qxt+x5TkK3rGvkRn/GjJcglXdSMwi7NUS b2SdD/a0DakVKV4LCbSd5qwdBoi14CxlTgObxuMCa4z3kw2k+2OlcGZLVvDSeD9eUFpP SHUHKvGKxDDJdwm1STHtJ0tx9QLOS2/r76ace3bCXrV9eg6l4w7vZIvxwVbrxn7TbMAQ 0P62DLEXi9dkbdsRETtc1cteOtC7JjGLK9K30Jif81HY2SEvjYRbr39vagqNDmo8FRzC 3edQ== 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; bh=Cxc7A3nuoON1YWUIYbtXAUb8R3WaT7s6JITRQaJdZBc=; b=jLHhHXHHY5jx2e8wJxFkUolPpWeSEOlr2485w0R/WAP5fCOWE3+z2+49b2PfuvfCYH KQxtv7Vb82otM/Lo8G8fKMA04XKPTnMvDOm4Lr7rJqbpfSpkAjJR4Zf+wDimW3JdjGKd 3AmkHuOEsV0zudVuard0EemP0g2fIgXD3eI/DysXIcZra9c5TvicRLpRnMnVRqE8DWtO 8Vu1mOe1qGX/deJvHuF9qFqh+22dJGbATmV43E2/3SrKcP5+5nhyrlHtLbuUGvaumst7 6yfK3sLMZ3vDx5CbwMzaoTOGdiFPJ0SA3Vd8hvabZHGZ3HiaBVhQLGOUc/PXOwI+1Llz wBhQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k3si13416289pfb.100.2019.03.25.02.39.48; Mon, 25 Mar 2019 02:40:03 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730344AbfCYJi4 (ORCPT + 99 others); Mon, 25 Mar 2019 05:38:56 -0400 Received: from bmailout2.hostsharing.net ([83.223.90.240]:44887 "EHLO bmailout2.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729608AbfCYJi4 (ORCPT ); Mon, 25 Mar 2019 05:38:56 -0400 Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (not verified)) by bmailout2.hostsharing.net (Postfix) with ESMTPS id 7BE5D2800B4AE; Mon, 25 Mar 2019 10:38:54 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 2AF7E1FB80; Mon, 25 Mar 2019 10:38:54 +0100 (CET) Date: Mon, 25 Mar 2019 10:38:54 +0100 From: Lukas Wunner To: William Breathitt Gray Cc: linus.walleij@linaro.org, bgolaszewski@baylibre.com, akpm@linux-foundation.org, linux-gpio@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, andriy.shevchenko@linux.intel.com, 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, Andy Shevchenko , Arnd Bergmann Subject: Re: [PATCH v12 01/11] bitops: Introduce the for_each_set_clump8 macro Message-ID: <20190325093854.jzkkwaksxi7zvtrg@wunner.de> References: <9afc30a574ce3e6a86b51dd522146a1d2156dedd.1553494625.git.vilhelm.gray@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9afc30a574ce3e6a86b51dd522146a1d2156dedd.1553494625.git.vilhelm.gray@gmail.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 25, 2019 at 03:22:23PM +0900, William Breathitt Gray wrote: > +/** > + * find_next_clump8 - find next 8-bit clump with set bits in a memory region > + * @clump: location to store copy of found clump > + * @addr: address to base the search on > + * @offset: bit offset at which to start searching > + * @size: bitmap size in number of bits > + * > + * Returns the bit offset for the next set clump; the found clump value is > + * copied to the location pointed by @clump. If no bits are set, returns @size. > + */ > +unsigned int find_next_clump8(unsigned long *const clump, > + const unsigned long *const addr, > + unsigned int offset, const unsigned int size) > +{ > + for (; offset < size; offset += 8) { > + *clump = bitmap_get_value8(addr, size, offset); > + if (!*clump) > + continue; > + > + return offset; > + } > + > + return size; > +} > +EXPORT_SYMBOL(find_next_clump8); Just use find_first_bit() / find_next_bit() to use optimized arch-specific bitops instead of open-coding the iteration over the bitmap. See max3191x_get_multiple() for an example. Thanks, Lukas