diff options
author | Richard Fitzgerald <rf@opensource.cirrus.com> | 2023-03-15 14:50:51 +0000 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2023-04-12 15:30:35 +0530 |
commit | 9ddae9dad09e8bdaa33909bdcbb062c883c3c332 (patch) | |
tree | 81f67cde2e1f44a79aa66fb7a241727fa027e83e /drivers/soundwire/bus.h | |
parent | 2367e0ecb498764e95cfda691ff0828f7d25f9a4 (diff) |
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>
Diffstat (limited to 'drivers/soundwire/bus.h')
-rw-r--r-- | drivers/soundwire/bus.h | 11 |
1 files changed, 0 insertions, 11 deletions
diff --git a/drivers/soundwire/bus.h b/drivers/soundwire/bus.h index 96927a143796..f0a59e5df631 100644 --- a/drivers/soundwire/bus.h +++ b/drivers/soundwire/bus.h @@ -158,17 +158,6 @@ int sdw_transfer_defer(struct sdw_bus *bus, struct sdw_msg *msg); int sdw_fill_msg(struct sdw_msg *msg, struct sdw_slave *slave, u32 addr, size_t count, u16 dev_num, u8 flags, u8 *buf); -/* Retrieve and return channel count from channel mask */ -static inline int sdw_ch_mask_to_ch(int ch_mask) -{ - int c = 0; - - for (c = 0; ch_mask; ch_mask >>= 1) - c += ch_mask & 1; - - return c; -} - /* Fill transport parameter data structure */ static inline void sdw_fill_xport_params(struct sdw_transport_params *params, int port_num, bool grp_ctrl_valid, |