linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: William Breathitt Gray <vilhelm.gray@gmail.com>
Cc: "open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	linux-arch@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 0/8] Introduce the for_each_set_clump macro
Date: Wed, 16 May 2018 16:03:51 +0200	[thread overview]
Message-ID: <CACRpkdbRH-Bz3BoczD+YmaSGqtoeCwtvGj4dGm8PKRKYFXTdKA@mail.gmail.com> (raw)
In-Reply-To: <cover.1526400945.git.vilhelm.gray@gmail.com>

On Tue, May 15, 2018 at 6:22 PM, William Breathitt Gray
<vilhelm.gray@gmail.com> 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

  parent reply	other threads:[~2018-05-16 14:03 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-15 16:22 [PATCH v4 0/8] Introduce the for_each_set_clump macro William Breathitt Gray
2018-05-15 16:22 ` William Breathitt Gray
2018-05-15 16:22 ` [PATCH v4 1/8] bitops: " William Breathitt Gray
2018-05-15 16:22   ` William Breathitt Gray
2018-05-15 16:22 ` [PATCH v4 2/8] lib/test_bitmap.c: Add for_each_set_clump test cases William Breathitt Gray
2018-05-15 16:22   ` William Breathitt Gray
2018-05-15 16:22 ` [PATCH v4 3/8] gpio: 104-dio-48e: Utilize for_each_set_clump macro William Breathitt Gray
2018-05-15 16:22   ` William Breathitt Gray
2018-05-15 16:22 ` [PATCH v4 4/8] gpio: 104-idi-48: " William Breathitt Gray
2018-05-15 16:22   ` William Breathitt Gray
2018-05-15 16:23 ` [PATCH v4 5/8] gpio: gpio-mm: " William Breathitt Gray
2018-05-15 16:23   ` William Breathitt Gray
2018-05-15 16:23 ` [PATCH v4 6/8] gpio: ws16c48: " William Breathitt Gray
2018-05-15 16:23   ` William Breathitt Gray
2018-05-15 16:23 ` [PATCH v4 7/8] gpio: pci-idio-16: " William Breathitt Gray
2018-05-15 16:23   ` William Breathitt Gray
2018-05-15 16:23 ` [PATCH v4 8/8] gpio: pcie-idio-24: " William Breathitt Gray
2018-05-15 16:23   ` William Breathitt Gray
2018-05-16 14:03 ` Linus Walleij [this message]
2018-05-16 14:03   ` [PATCH v4 0/8] Introduce the " Linus Walleij
2018-05-16 20:08   ` Andy Shevchenko
2018-05-16 20:08     ` Andy Shevchenko
2018-06-16 19:16     ` William Breathitt Gray
2018-06-16 19:16       ` William Breathitt Gray
2018-09-05 15:04   ` William Breathitt Gray
2018-09-05 15:04     ` William Breathitt Gray
2018-09-10  7:54     ` Linus Walleij
2018-09-10  7:54       ` Linus Walleij
2018-09-10 14:47       ` Andy Shevchenko
2018-09-10 14:47         ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACRpkdbRH-Bz3BoczD+YmaSGqtoeCwtvGj4dGm8PKRKYFXTdKA@mail.gmail.com \
    --to=linus.walleij@linaro.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vilhelm.gray@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).