Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2043274imm; Wed, 16 May 2018 07:04:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoNLbKNNk/HK48NSOfVeI9VmaFLCv/92DhfEJPeEqSAbqMoEC7DJmRlNFPUvXUONhvJbi99 X-Received: by 2002:a63:9a49:: with SMTP id e9-v6mr871040pgo.251.1526479478347; Wed, 16 May 2018 07:04:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526479478; cv=none; d=google.com; s=arc-20160816; b=ertwuatipUh00tRoVCPnGVttl8X7z5kfdu7TMnueO/UJoIVy57ZskDWJjk5W0P5FaB nrvyFc6Qsd2GPp6BXEQIkW0BHBMGIfPbbdCu45lfkebWLToAC7YtRLmNdS9t6M+k6ilW i7jV6iri+t+hiaWso6yAkXSGy7rDg4FiQVtenfjOrFf9fgC0jZTZiUEKa0AfA7hLZaKl YxbGXdMSnrA2dlzqe4er+KnxkuhmEzJGWGu2ZIRH3PreGNadxGU89hfxCHNElvmvJj/r gPRpSh5I3KKigaXgkHETrq+JP2ksPbnr8qAFkNrVYix6+0YUCAUKL8OqpzuwZLfWvTMB c/WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=a9SQ9sZmYuHV4G+LPeUpg4w8h/uctpLaK+nlTusPHDk=; b=lkdAaW5Ttt1Ro0K8OwKhwaXKcUCFLFLQcgwN4Rm7G/4azD1kSn0kctimvpO7S1/jNq jpZIoG23u5XjMon7T9HOg69wvqlzq0Nm7ApvIU8palrfHXbaMy+9Y9XX9/KE3tNf4nrQ dVc2PwWIKpnxmnHOhyO4HG4qP5SBQC2jfwf3n8K82rChOOFGejIuubu+PC/cpM22492E phtjhgEsb7hKbUg5yIm/gx/fYZ7bmd7BE1xARcdbZPm2CqW3PxV7zInX5tQ5GxEVmcDs IyzhFVcBGVII3vdnejXdBhXRvkmHT7vaBOJqZKf8fxUMfz8lNDAiNP+DsBAu04wBFU4N 2rgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=URtVPJEz; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b190-v6si2162287pgc.18.2018.05.16.07.04.23; Wed, 16 May 2018 07:04:38 -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=@linaro.org header.s=google header.b=URtVPJEz; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752538AbeEPODz (ORCPT + 99 others); Wed, 16 May 2018 10:03:55 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:52954 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752081AbeEPODw (ORCPT ); Wed, 16 May 2018 10:03:52 -0400 Received: by mail-it0-f66.google.com with SMTP id y189-v6so2122879itb.2 for ; Wed, 16 May 2018 07:03:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=a9SQ9sZmYuHV4G+LPeUpg4w8h/uctpLaK+nlTusPHDk=; b=URtVPJEz8sffY3Zl9uMhTmuV1MiKsTYjyb+Bj0aqEg2HU8X489PG8p7x5J3zTeQcWB lmlzr97ku+atbtSjeWdIFxYRCiFsWldkGw5vIvDkYJ7zaJAyPJxKLE/mouD+xsTwytRW qpEvGwCoPG1hzTSeD++2MENkL9Hz+tHvEBVH0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=a9SQ9sZmYuHV4G+LPeUpg4w8h/uctpLaK+nlTusPHDk=; b=EBlfAFwpAeBxnAqgjYGiCKQ+LkO3NA3DrsyAKyvQhDwmK7VeD1abyrZ6yXF38Fz5vq FjxEHXODFdB3rEj8s9a4Pg27H2KY9llaXeLmP8H2KWXDPwHsHnGlavRrzs4b/IzkmXS5 jn89OrBjbRHWRHloPSNzHsymN6FsGTMAU03LZlgJac+weN7DwT9hWCt5+8EAtR9d1ARB QhEHmDrie2uj4oTupFzYXjMPCBBx/GVZLdm9fB92+TTw/Er3qLos7L35qq5DoTt5YNX4 IMBP2bPoofudD+KF+zWzhKJnzzcRrwbP8ev0cMzGZzwkdS5UmAebl8Fcggkh/fbU8LvL nHow== X-Gm-Message-State: ALKqPwdA09tNUbkcQ3jQqea6pp9Gh20iwsagKVMzO7c0Om1hbMTHuycm 2jDcRCDqAmcsJKOLMbWO30aaXhp1QCODrNs0PUyCrDLVqpI= X-Received: by 2002:a6b:cc02:: with SMTP id c2-v6mr1133618iog.304.1526479432255; Wed, 16 May 2018 07:03:52 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4f:4c95:0:0:0:0:0 with HTTP; Wed, 16 May 2018 07:03:51 -0700 (PDT) In-Reply-To: References: From: Linus Walleij Date: Wed, 16 May 2018 16:03:51 +0200 Message-ID: Subject: Re: [PATCH v4 0/8] Introduce the for_each_set_clump macro To: William Breathitt Gray Cc: "open list:GPIO SUBSYSTEM" , linux-arch@vger.kernel.org, "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 15, 2018 at 6:22 PM, William Breathitt Gray wrote: > For example, suppose you would like to iterate over a 16-bit integer 4 > bits at a time, skipping over 4-bit groups with no set bit, where XXXX > represents the current 4-bit group: > > Example: 1011 1110 0000 1111 > First loop: 1011 1110 0000 XXXX > Second loop: 1011 XXXX 0000 1111 > Third loop: XXXX 1110 0000 1111 > > Each iteration of the loop returns the next 4-bit group that has at > least one set bit. > > The for_each_set_clump macro has six parameters: > > * clump: set to current clump index for the iteration > * index: set to current bitmap word index for the iteration > * offset: bits offset of the found clump in the bitmap word > * bits: bitmap to search within > * size: bitmap size in number of clumps > * clump_size: clump size in number of bits > > The clump_size argument can be an arbitrary number of bits and is not > required to be a multiple of 2. I must say I'm impressed. Very nice arithmetics going on there. If I can get some ACK for the bitops patch I'd be happy to merge it all through the GPIO tree. The users are pretty clear cut. BTW: if I could, I would pull out Donald Knuth's "The Art of Computer Programming vol 4A" chapter 7.1.3 "Bitwise Tricks and Techniques" to see what he has to say about the subject, but I don't have that book as it turns out. Yours, Linus Walleij