[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2c22b52f-9a1f-06f5-f008-d568096f5c4d@fi.rohmeurope.com>
Date: Mon, 22 Nov 2021 12:42:21 +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 13:28, Andy Shevchenko wrote:
> On Mon, Nov 22, 2021 at 01:03:25PM +0200, Matti Vaittinen wrote:
>> There are cases when it is useful to check a bit-mask has only one bit
>> set. Add a generic helper for it instead of baking own one for each
>> user.
>>
>> Signed-off-by: Matti Vaittinen <matti.vaittinen@...rohmeurope.com>
>> ---
>> I am not at all sure what would be the best place for this. Please let
>> me know if you think some other file would be more appropriate.
>
> So, you decided to reinvent hamming weight...
> Please, drop this patch and use corresponding hweight() call.
>
Thanks Andy.
There are few differences to hamming weight here. We scan only given
amount of bits - and we will end scanning immediately when we hit second
set bit. Oh, and obviously we only return information whether there is
exactly one bit set. So no, this is not hamming weight().
Yet, I think you are correct. My use-case does not warrant adding this.
I have no need for scanning only certain amount of bits.
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).
I'll see how it works out and if (when) it does I'll respin the series
w/o this as you suggested. So thanks.
--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