soundwire: bandwidth allocation: Use hweight32() to calculate set bits
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Wed, 15 Mar 2023 14:50:51 +0000 (14:50 +0000)
committerVinod Koul <vkoul@kernel.org>
Wed, 12 Apr 2023 10:00:35 +0000 (15:30 +0530)
commit9ddae9dad09e8bdaa33909bdcbb062c883c3c332
tree81f67cde2e1f44a79aa66fb7a241727fa027e83e
parent2367e0ecb498764e95cfda691ff0828f7d25f9a4
soundwire: bandwidth allocation: Use hweight32() to calculate set bits

Replace the call to sdw_ch_mask_to_ch() with a call to hweight32().

sdw_ch_mask_to_ch() is counting the number of set bits. The hweight()
family of functions already do this, and they have an advantage of
using a bit-counting instruction if it is available on the target CPU.
This also fixes a potential infinite loop bug in the implementation of
sdw_ch_mask_to_ch().

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230315145051.2299822-1-rf@opensource.cirrus.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/bus.h
drivers/soundwire/generic_bandwidth_allocation.c