Skip to contentSkip to conversation

ASoC: codecs: propagate sdw_write() errors from bus_config callbacks

PATCH Superseded Andrey Karelin 1 participant 3 messages Oct 16

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover ASoC: codecs: propagate sdw_write() errors from bus_config callbacks

wsa881x_bus_config() and wcd_bus_config() (shared by the WCD938x and WCD939x SoundWire drivers) program the clock divider for the next bank with sdw_write() but ignore its result and always return 0, so a failed write is never reported to sdw_notify_config(). The other SoundWire codec drivers that implement bus_config already return the error.

Both patches simply return the result of sdw_write().

Andrey Karelin (2):
ASoC: codecs: wsa881x: propagate sdw_write() error from bus_config
ASoC: codecs: wcd-common: propagate sdw_write() error from bus_config

 sound/soc/codecs/wcd-common.c | 4 +---
 sound/soc/codecs/wsa881x.c    | 6 ++----
 2 files changed, 3 insertions(+), 7 deletions(-)

base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907

Signature · 1 line
2.56.0
#1 lore raw

PATCH 1/2 ASoC: codecs: wsa881x: propagate sdw_write() error from bus_config

wsa881x_bus_config() programs the clock divider for the next bank via sdw_write() but ignores its result and always returns 0. A failed write is therefore hidden from sdw_notify_config(), which aborts programming of the stream parameters when a bus_config callback fails, and the amplifier may keep running with a wrong clock configuration after the bank switch.

Return the result of sdw_write() instead.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes a0aab9e1404a ("ASoC: codecs: add wsa881x amplifier support")
---
 sound/soc/codecs/wsa881x.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/codecs/wsa881x.c +2 -4
index 47ac3e4985a5..0fc7132c0a9c 100644
@@ -1093,10 +1093,8 @@ static int wsa881x_port_prep(struct sdw_slave *slave,
 static int wsa881x_bus_config(struct sdw_slave *slave,
 			      struct sdw_bus_params *params)
 {
-	sdw_write(slave, SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(params->next_bank),
-		  0x01);
-
-	return 0;
+	return sdw_write(slave, SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(params->next_bank),
+			 0x01);
 }
 
 static const struct sdw_slave_ops wsa881x_slave_ops = {
Signature · 1 line
2.56.0
#2 lore raw

PATCH 2/2 ASoC: codecs: wcd-common: propagate sdw_write() error from bus_config

In reply to Andrey Karelin

wcd_bus_config() programs the clock divider for the next bank via sdw_write() but ignores its result and always returns 0. A failed write is therefore hidden from sdw_notify_config(), which aborts programming of the stream parameters when a bus_config callback fails, and the codec may keep running with a wrong clock configuration after the bank switch.

The callback is shared by the WCD938x and WCD939x SoundWire drivers. It was moved to the common helper as is by commit 59aebbbb0b47 ("ASoC:
codecs: wcd-common: move status_update callback to common"); the original per-driver callbacks had the same problem.

Return the result of sdw_write() instead.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 16572522aece ("ASoC: codecs: wcd938x-sdw: add SoundWire driver")
Fixes be2af391cea0 ("ASoC: codecs: Add WCD939x Soundwire devices driver")
---
 sound/soc/codecs/wcd-common.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
sound/soc/codecs/wcd-common.c +1 -3
index 9016e974582f..74bd718b8a34 100644
@@ -115,9 +115,7 @@ EXPORT_SYMBOL_GPL(wcd_update_status);
 
 int wcd_bus_config(struct sdw_slave *slave, struct sdw_bus_params *params)
 {
-	sdw_write(slave, SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(params->next_bank), 0x01);
-
-	return 0;
+	return sdw_write(slave, SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(params->next_bank), 0x01);
 }
 EXPORT_SYMBOL_GPL(wcd_bus_config);
 
Signature · 1 line
2.56.0