Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH] soundwire: stream: fix programming slave ports for non-continous port maps
@ 2024-07-29 14:01 Krzysztof Kozlowski
  2024-07-29 14:25 ` Pierre-Louis Bossart
  2024-08-18  7:28 ` Vinod Koul
  0 siblings, 2 replies; 16+ messages in thread
From: Krzysztof Kozlowski @ 2024-07-29 14:01 UTC (permalink / raw)
  To: Vinod Koul, Bard Liao, Pierre-Louis Bossart, Sanyog Kale,
	Shreyas NC, alsa-devel, linux-kernel
  Cc: Krzysztof Kozlowski, stable

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: f8101c74aa54 ("soundwire: Add Master and Slave port programming")
Cc: <stable@vger.kernel.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/soundwire/stream.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
index 7aa4900dcf31..f275143d7b18 100644
--- a/drivers/soundwire/stream.c
+++ b/drivers/soundwire/stream.c
@@ -1291,18 +1291,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];
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-09-09 14:35 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-29 14:01 [PATCH] soundwire: stream: fix programming slave ports for non-continous port maps Krzysztof Kozlowski
2024-07-29 14:25 ` Pierre-Louis Bossart
2024-07-30  8:23   ` Krzysztof Kozlowski
2024-07-30  8:39     ` Krzysztof Kozlowski
2024-07-30  8:59       ` Pierre-Louis Bossart
2024-07-30  9:19         ` Krzysztof Kozlowski
2024-07-30  9:28           ` Pierre-Louis Bossart
2024-07-30  9:29             ` Krzysztof Kozlowski
2024-07-30  9:43               ` Pierre-Louis Bossart
2024-07-31  6:56   ` Vinod Koul
2024-09-03  7:34     ` Liao, Bard
2024-09-03 12:50       ` Krzysztof Kozlowski
2024-09-03 15:17         ` Liao, Bard
2024-09-04 11:43           ` Krzysztof Kozlowski
2024-09-09 14:34             ` Charles Keepax
2024-08-18  7:28 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox