[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e2675600-7b04-19b0-79ce-28a4e1d1f225@fi.rohmeurope.com>
Date: Mon, 22 Nov 2021 13:18:42 +0000
From: "Vaittinen, Matti" <Matti.Vaittinen@...rohmeurope.com>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
CC: Matti Vaittinen <mazziesaccount@...il.com>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Jiri Kosina <trivial@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Yury Norov <yury.norov@...il.com>,
Kumar Kartikeya Dwivedi <memxor@...il.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Geert Uytterhoeven <geert+renesas@...der.be>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/4] bitops: Add single_bit_set()
On 11/22/21 14:57, Andy Shevchenko wrote:
> On Mon, Nov 22, 2021 at 12:42:21PM +0000, Vaittinen, Matti wrote:
>> On 11/22/21 13:28, Andy Shevchenko wrote:
>>> On Mon, Nov 22, 2021 at 01:03:25PM +0200, Matti Vaittinen wrote:
>
> What do you mean by this?
>
> hweight() will return you the number of the non-zero elements in the set.
Exactly. The function I added did only check if given set of bits had
only one bit set.
> In application to boolean based arrays it means the number of bits that
> are set. Obviously, the condition `hweight() == 1` is what you are looking
> for.
Yes. (hweight() == 1) will result exactly same result - which does not
mean the single_bit_set() was same as hweight(). Say, we have a 32bit
wide value, which is likely to be '11' (binary). The single_bit_set()
would return 0 after checking the 2.nd bit. So, this is not equal to
hamming weight. But as I said, none of this is really needed for my
use-case and does not warrant adding new function.
>> I think I actually tried using hweight() at some point but don't really
>> remember why I rolled the single_bit_set. (I remember the hweight()
>> usage because I had to do some googling as I had never heard term
>> hamming weight before).
>
> Oh, it should be a very good reason not to use hweight() since on some
> architectures it might become just one assembly instruction.
I didn't know of this. Thanks for sharing.
> (Side note: all your sentences but last in all of the paragraphs are ending
> with trailing space. For example, "series " and "thanks." for the comparison
> in the previous paragraph. Can you fix this, please?)
I changed from evolution to Thunderbird when my old laptop broke. It
seems Thunderbird is doing this by default, don't know if it can be
changed :( I'll see if I find a solution.
Best Regards
--Matti
--
The Linux Kernel guy at ROHM Semiconductors
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND
~~ this year is the year of a signature writers block ~~
Powered by blists - more mailing lists