Skip to content

Commit

Permalink
soundwire: stream: fix programming slave ports for non-continous port…
Browse files Browse the repository at this point in the history
… maps

commit ab8d66d upstream.

Two bitmasks in 'struct sdw_slave_prop' - 'source_ports' and
'sink_ports' - define which ports to program in
sdw_program_slave_port_params().  The masks are used to get the
appropriate data port properties ('struct sdw_get_slave_dpn_prop') from
an array.

Bitmasks can be non-continuous or can start from index different than 0,
thus when looking for matching port property for given port, we must
iterate over mask bits, not from 0 up to number of ports.

This fixes allocation and programming slave ports, when a source or sink
masks start from further index.

Fixes: f8101c7 ("soundwire: Add Master and Slave port programming")
Cc: [email protected]
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Reviewed-by: Pierre-Louis Bossart <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Vinod Koul <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
krzk authored and gregkh committed Sep 4, 2024
1 parent 4626787 commit 6fa78e9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/soundwire/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -1286,18 +1286,18 @@ struct sdw_dpn_prop *sdw_get_slave_dpn_prop(struct sdw_slave *slave,
unsigned int port_num)
{
struct sdw_dpn_prop *dpn_prop;
u8 num_ports;
unsigned long mask;
int i;

if (direction == SDW_DATA_DIR_TX) {
num_ports = hweight32(slave->prop.source_ports);
mask = slave->prop.source_ports;
dpn_prop = slave->prop.src_dpn_prop;
} else {
num_ports = hweight32(slave->prop.sink_ports);
mask = slave->prop.sink_ports;
dpn_prop = slave->prop.sink_dpn_prop;
}

for (i = 0; i < num_ports; i++) {
for_each_set_bit(i, &mask, 32) {
if (dpn_prop[i].num == port_num)
return &dpn_prop[i];
}
Expand Down

0 comments on commit 6fa78e9

Please sign in to comment.