[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190326130319.cwn5zl4e222zh6ak@wunner.de>
Date: Tue, 26 Mar 2019 14:03:19 +0100
From: Lukas Wunner <lukas@...ner.de>
To: William Breathitt Gray <vilhelm.gray@...il.com>
Cc: Andy Shevchenko <andy.shevchenko@...il.com>,
linus.walleij@...aro.org, bgolaszewski@...libre.com,
akpm@...ux-foundation.org, linux-gpio@...r.kernel.org,
linux-arch@...r.kernel.org, linux-kernel@...r.kernel.org,
andriy.shevchenko@...ux.intel.com, linux@...musvillemoes.dk,
yamada.masahiro@...ionext.com,
linux-arm-kernel@...ts.infradead.org, linux-pm@...r.kernel.org,
geert@...ux-m68k.org, preid@...ctromag.com.au,
Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH v12 01/11] bitops: Introduce the for_each_set_clump8 macro
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:
> > I'd try to avoid copying around the clump value and use a pointer
> > to u8 instead.
>
> Although in this case we are handling 8-bit clumps, I anticipate device
> drivers in the future which may benefit from larger size clumps (e.g.
> GPIO devices with 24-bit ports). It'll be better to define clumps
> similar to how we're defining bitmaps now (unsigned long *) so that we
> can support these sizes if need be in the future without requiring data
> type changes.
It's just that copying around data in memory may be more expensive
than, say, returning from a function, in which case it's usually
stored in a register.
> 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;
Hm, shouldn't that be "offset = round_down(start, 8)" ?
(I prefer the multi-line version FWIW.)
> Would it be better to define bitmap_get_value8 as a macro then?
Or a static inline.
Thanks,
Lukas
Powered by blists - more mailing lists