All of lore.kernel.org
 help / color / mirror / Atom feed
From: William Breathitt Gray <vilhelm.gray@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>,
	Lukas Wunner <lukas@wunner.de>
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,
	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,
	Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH v12 01/11] bitops: Introduce the for_each_set_clump8 macro
Date: Tue, 26 Mar 2019 19:28:43 +0900	[thread overview]
Message-ID: <20190326102843.GA10264@icarus> (raw)
In-Reply-To: <20190326101933.GW9224@smile.fi.intel.com>

On Tue, Mar 26, 2019 at 12:19:33PM +0200, Andy Shevchenko wrote:
> On Tue, Mar 26, 2019 at 07:08:18PM +0900, William Breathitt Gray wrote:
> > On Tue, Mar 26, 2019 at 10:43:45AM +0100, Lukas Wunner wrote:
> > > On Tue, Mar 26, 2019 at 12:14:22PM +0900, William Breathitt Gray wrote:
> 
> > > Why is it so complicated, does it allow passing in a start value
> > > that's not a multiple of 8?  Do you really need that?  I imagine
> > > a simplification is possible if that assumption can be made (and
> > > is spelled out in the kerneldoc).
> > 
> > That's a good point. Originally, I had envisioned the possibility of
> > calling bitmap_get_value8/bitmap_set_value8 at odd start offsets; this
> > would open up the possibility of a clump landing as a split between 2
> > words, thus requiring this complicated case handling code. However, I'm
> > not sure how often users would need this case; none of the drivers right
> > now require clumps at odd offsets.
> > 
> > Andy, would you have any objection to restricting the start offset
> > values for bitmap_get_value8/bitmap_set_value8 to multiples of 8? That
> > would prevent the split word case, and thus allow the implementation for
> > those functions to be a lot simpler.
> 
> No, I have no objection.
> 
> -- 
> With Best Regards,
> Andy Shevchenko

In this case, bitmap_get_value8 could be simplified to something like
this:

        index = BIT_WORD(start);
        offset = start % BITS_PER_LONG;
        return (bitmap[index] >> offset) & 0xFF;

Or if you prefer a single line:

        (bitmap[BIT_WORD(start)] >> (start % BITS_PER_LONG)) & 0xFF;

Would it be better to define bitmap_get_value8 as a macro then?

William Breathitt Gray

WARNING: multiple messages have this Message-ID (diff)
From: William Breathitt Gray <vilhelm.gray@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>,
	Lukas Wunner <lukas@wunner.de>
Cc: linux-arch@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	linux-gpio@vger.kernel.org, yamada.masahiro@socionext.com,
	linus.walleij@linaro.org, linux-pm@vger.kernel.org,
	linux@rasmusvillemoes.dk, linux-kernel@vger.kernel.org,
	bgolaszewski@baylibre.com, geert@linux-m68k.org,
	akpm@linux-foundation.org, preid@electromag.com.au,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v12 01/11] bitops: Introduce the for_each_set_clump8 macro
Date: Tue, 26 Mar 2019 19:28:43 +0900	[thread overview]
Message-ID: <20190326102843.GA10264@icarus> (raw)
In-Reply-To: <20190326101933.GW9224@smile.fi.intel.com>

On Tue, Mar 26, 2019 at 12:19:33PM +0200, Andy Shevchenko wrote:
> On Tue, Mar 26, 2019 at 07:08:18PM +0900, William Breathitt Gray wrote:
> > On Tue, Mar 26, 2019 at 10:43:45AM +0100, Lukas Wunner wrote:
> > > On Tue, Mar 26, 2019 at 12:14:22PM +0900, William Breathitt Gray wrote:
> 
> > > Why is it so complicated, does it allow passing in a start value
> > > that's not a multiple of 8?  Do you really need that?  I imagine
> > > a simplification is possible if that assumption can be made (and
> > > is spelled out in the kerneldoc).
> > 
> > That's a good point. Originally, I had envisioned the possibility of
> > calling bitmap_get_value8/bitmap_set_value8 at odd start offsets; this
> > would open up the possibility of a clump landing as a split between 2
> > words, thus requiring this complicated case handling code. However, I'm
> > not sure how often users would need this case; none of the drivers right
> > now require clumps at odd offsets.
> > 
> > Andy, would you have any objection to restricting the start offset
> > values for bitmap_get_value8/bitmap_set_value8 to multiples of 8? That
> > would prevent the split word case, and thus allow the implementation for
> > those functions to be a lot simpler.
> 
> No, I have no objection.
> 
> -- 
> With Best Regards,
> Andy Shevchenko

In this case, bitmap_get_value8 could be simplified to something like
this:

        index = BIT_WORD(start);
        offset = start % BITS_PER_LONG;
        return (bitmap[index] >> offset) & 0xFF;

Or if you prefer a single line:

        (bitmap[BIT_WORD(start)] >> (start % BITS_PER_LONG)) & 0xFF;

Would it be better to define bitmap_get_value8 as a macro then?

William Breathitt Gray

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-03-26 10:28 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-25  6:20 [PATCH v12 00/11] Introduce the for_each_set_clump8 macro William Breathitt Gray
2019-03-25  6:20 ` William Breathitt Gray
2019-03-25  6:22 ` [PATCH v12 01/11] bitops: " William Breathitt Gray
2019-03-25  6:22   ` William Breathitt Gray
2019-03-25  9:38   ` Lukas Wunner
2019-03-25 13:09     ` Andy Shevchenko
2019-03-25 13:09       ` Andy Shevchenko
2019-03-26  3:14     ` William Breathitt Gray
2019-03-26  3:14       ` William Breathitt Gray
2019-03-26  9:43       ` Lukas Wunner
2019-03-26  9:53         ` Andy Shevchenko
2019-03-26  9:53           ` Andy Shevchenko
2019-03-26 10:08         ` William Breathitt Gray
2019-03-26 10:08           ` William Breathitt Gray
2019-03-26 10:19           ` Andy Shevchenko
2019-03-26 10:19             ` Andy Shevchenko
2019-03-26 10:28             ` William Breathitt Gray [this message]
2019-03-26 10:28               ` William Breathitt Gray
2019-03-26 13:03           ` Lukas Wunner
2019-03-26 13:18             ` Andy Shevchenko
2019-03-26 13:18               ` Andy Shevchenko
2019-03-25 13:12   ` Andy Shevchenko
2019-03-25 13:12     ` Andy Shevchenko
2019-03-26  2:54     ` William Breathitt Gray
2019-03-26  2:54       ` William Breathitt Gray
2019-03-26 11:42       ` Andy Shevchenko
2019-03-26 11:42         ` Andy Shevchenko
2019-03-25  6:23 ` [PATCH v12 02/11] lib/test_bitmap.c: Add for_each_set_clump8 test cases William Breathitt Gray
2019-03-25  6:23   ` William Breathitt Gray
2019-03-25  6:23 ` [PATCH v12 03/11] gpio: 104-dio-48e: Utilize for_each_set_clump8 macro William Breathitt Gray
2019-03-25  6:23   ` William Breathitt Gray
2019-03-25  6:23 ` [PATCH v12 04/11] gpio: 104-idi-48: " William Breathitt Gray
2019-03-25  6:23   ` William Breathitt Gray
2019-03-25  6:24 ` [PATCH v12 05/11] gpio: gpio-mm: " William Breathitt Gray
2019-03-25  6:24   ` William Breathitt Gray
2019-03-25  6:24 ` [PATCH v12 06/11] gpio: ws16c48: " William Breathitt Gray
2019-03-25  6:24   ` William Breathitt Gray
2019-03-25  6:24 ` [PATCH v12 07/11] gpio: pci-idio-16: " William Breathitt Gray
2019-03-25  6:24   ` William Breathitt Gray
2019-03-25  6:25 ` [PATCH v12 08/11] gpio: pcie-idio-24: " William Breathitt Gray
2019-03-25  6:25   ` William Breathitt Gray
2019-03-25  6:25 ` [PATCH v12 09/11] gpio: uniphier: " William Breathitt Gray
2019-03-25  6:25   ` William Breathitt Gray
2019-03-25  6:26 ` [PATCH v12 10/11] thermal: intel: intel_soc_dts_iosf: " William Breathitt Gray
2019-03-25  6:26   ` William Breathitt Gray
2019-03-25  6:26 ` [PATCH v12 11/11] gpio: 74x164: Utilize the " William Breathitt Gray
2019-03-25  6:26   ` William Breathitt Gray
2019-03-25 13:11   ` Andy Shevchenko
2019-03-25 13:11     ` 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=20190326102843.GA10264@icarus \
    --to=vilhelm.gray@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=arnd@arndb.de \
    --cc=bgolaszewski@baylibre.com \
    --cc=geert@linux-m68k.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=lukas@wunner.de \
    --cc=preid@electromag.com.au \
    --cc=yamada.masahiro@socionext.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.