Skip to content

Commit ab8d66d

Browse files
krzkvinodkoul
authored andcommitted
soundwire: stream: fix programming slave ports for non-continous port maps
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]>
1 parent 8400291 commit ab8d66d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/soundwire/stream.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,18 +1291,18 @@ struct sdw_dpn_prop *sdw_get_slave_dpn_prop(struct sdw_slave *slave,
12911291
unsigned int port_num)
12921292
{
12931293
struct sdw_dpn_prop *dpn_prop;
1294-
u8 num_ports;
1294+
unsigned long mask;
12951295
int i;
12961296

12971297
if (direction == SDW_DATA_DIR_TX) {
1298-
num_ports = hweight32(slave->prop.source_ports);
1298+
mask = slave->prop.source_ports;
12991299
dpn_prop = slave->prop.src_dpn_prop;
13001300
} else {
1301-
num_ports = hweight32(slave->prop.sink_ports);
1301+
mask = slave->prop.sink_ports;
13021302
dpn_prop = slave->prop.sink_dpn_prop;
13031303
}
13041304

1305-
for (i = 0; i < num_ports; i++) {
1305+
for_each_set_bit(i, &mask, 32) {
13061306
if (dpn_prop[i].num == port_num)
13071307
return &dpn_prop[i];
13081308
}

0 commit comments

Comments
 (0)