Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2454443imm; Wed, 16 May 2018 13:09:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpnJbnuOo4LZFAt9Fz6fAuO6mkG8iJ0uO9VFDmxl6mKEgbnU1jQDDnyC0LsFOAe0I9PO+jo X-Received: by 2002:a62:7f91:: with SMTP id a139-v6mr2351899pfd.25.1526501354408; Wed, 16 May 2018 13:09:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526501354; cv=none; d=google.com; s=arc-20160816; b=FrNztjOB00LmyQTn66Ig5fAtM/Asl1DMBGDx9M5n8JN7d88In8Tw/+OTzI3C+4F5hV WfcQG1zBlWHzzdvT6Bpt8EfZbsVMCMJx8uUI1Mx7N3kYRHpG50BL1bZhJLX6QBMD7XOD zTdbwwG8OBLU6pGv2sb7Yp1+CqdmX7pRPQ4s7HJ40BSxcr8qO0WM2+E9uK6F3woJkrRD b2qIGOqLZP/ZyQUJ6La5udvAtsXr+7H4USEivhxShLI4GmD6jUPpDKxrxo4b007Pmrz6 JSRx6d5F8cM1As/DwrhJaspjZYzJ7q3Y2U+nGfcXsNpjOk8OoRc/RY5Fa6K9FlrJt1vD lAow== 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=B1mXDECNKyGeV4WvTGwEeGi2h4YOPfixv8oX2YluUmA=; b=zffv+hKHcP+15PypJrmNBTwBfaDEBZESp6i7cf7mQWV1pASwMpU1kprfbS1MpJOr1k JZsvLYu2TI5tkySUwFYQdR07SHVnMIPEvhK5B8Iw85+alwIkMaT3afos+nT6K6/0t7iH y8yEmlGTufK9bt/5YSVklwjI/xlblZY4DEAdboeQ388dC8Q4m/d3Jkj/Eoz7GACdmw66 hva41NRsRngnLbUoL4xyegsioaY6qW85MHjp+fM8+Gr63RsAiOgIBxza/abgvwgsCSXl 091JyFHhf8P9aWM8aKQbk0u+bj6D3KjY+MLhal7Ahy68Bw4BacFaq1JuibHY4xk68Pd0 FVBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KQfkpR7d; 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 r134-v6si2595877pgr.491.2018.05.16.13.08.54; Wed, 16 May 2018 13:09:14 -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=KQfkpR7d; 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 S1751395AbeEPUId (ORCPT + 99 others); Wed, 16 May 2018 16:08:33 -0400 Received: from mail-qt0-f170.google.com ([209.85.216.170]:38269 "EHLO mail-qt0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751153AbeEPUIa (ORCPT ); Wed, 16 May 2018 16:08:30 -0400 Received: by mail-qt0-f170.google.com with SMTP id m9-v6so2816268qtb.5; Wed, 16 May 2018 13:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=B1mXDECNKyGeV4WvTGwEeGi2h4YOPfixv8oX2YluUmA=; b=KQfkpR7deWy70b7eXARG6k4/5UaGNMxNrYR0ZgTi+x/UO2U2UXPt+4oQZmx7fqBzVp Z49TOpUGUmKi5FDPQCNCXTUYjMhgpWnqXXwECEA1eHsTp1fu+Xisrw2km4LNkApgvLkg Uhj6LE8YoZHx+fOQgeO4eqxi4U4dBkHs04KamD0nn/PWOCR3p7wQ/hPY0OBa9EAqXyO5 87tjRJnZcw309VgFtHqrCwu3zt0Zyrp9L/ROy4vchjgX1H3UurwUauyd8gR4SIKRNPOW eEaY7hyDt2HaYUSTLoVQqfIGY46qTZNotJc6ug8cnJSo8vU0egf9OIHqkm8jsTu2f8P5 z+EQ== 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=B1mXDECNKyGeV4WvTGwEeGi2h4YOPfixv8oX2YluUmA=; b=sIsBu5q0jhbrdQHUiuXYUID3k33qshMjp4SzXdpXxgbFDYgDcyzBX9mc531Dz08Zx+ lvWfhnBS4lcd5v1CFd81cyaRdjm+IUbyOq1JT1Vc5KzJmqKweI2+Vbrpe/F6wIXTVkO9 uT4bt6E2ZuNWJnxlIaK3JW/+5E7MROAi4rneH8ME71dn5LASh/nCpJ0WKLhHpqgBZL7o EWH5g3Ejzvii5uGzFgtNaNN4WVD2RCMWXjMl5hsgsT86FEBQNUas/9mXFOs36TUisKOI ACBGp83Lk3Da3wLHyDeHuhvrSEQOrYMOlqIC7Gg+ZDfhMpn54d5qcuRwDytfkWkSSGgn Lv7g== X-Gm-Message-State: ALKqPwef1XgWu38ONGJmB728hJzr01tY7aDVt/6+brbrG1leuQsRvPqa 1H3fTkoYt+N9dj7l85JkzBhiRNC4UtqS6jr88P8= X-Received: by 2002:a0c:f288:: with SMTP id k8-v6mr2503435qvl.14.1526501309567; Wed, 16 May 2018 13:08:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.152.150 with HTTP; Wed, 16 May 2018 13:08:28 -0700 (PDT) In-Reply-To: References: From: Andy Shevchenko Date: Wed, 16 May 2018 23:08:28 +0300 Message-ID: Subject: Re: [PATCH v4 0/8] Introduce the for_each_set_clump macro To: Linus Walleij Cc: William Breathitt Gray , "open list:GPIO SUBSYSTEM" , Linux-Arch , "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 Wed, May 16, 2018 at 5:03 PM, Linus Walleij wrote: > 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. Give me also some time to go through proposed API, I think it might have needed more alignment with existing find_* and for_* helpers. > 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. I can also add the Standford collection of bit algos here: https://graphics.stanford.edu/~seander/bithacks.html -- With Best Regards, Andy Shevchenko