Skip to content

Commit 49aadf8

Browse files
jhovoldbroonie
authored andcommitted
ASoC: codecs: wsa883x: fix unnecessary initialisation
The soundwire update_status() callback may be called multiple times with the same ATTACHED status but initialisation should only be done when transitioning from UNATTACHED to ATTACHED. This avoids repeated initialisation of the codecs during boot of machines like the Lenovo ThinkPad X13s: [ 11.614523] wsa883x-codec sdw:1:0:0217:0202:00:1: WSA883X Version 1_1, Variant: WSA8835_V2 [ 11.618022] wsa883x-codec sdw:1:0:0217:0202:00:1: WSA883X Version 1_1, Variant: WSA8835_V2 [ 11.621377] wsa883x-codec sdw:1:0:0217:0202:00:1: WSA883X Version 1_1, Variant: WSA8835_V2 [ 11.624065] wsa883x-codec sdw:1:0:0217:0202:00:1: WSA883X Version 1_1, Variant: WSA8835_V2 [ 11.631382] wsa883x-codec sdw:1:0:0217:0202:00:2: WSA883X Version 1_1, Variant: WSA8835_V2 [ 11.634424] wsa883x-codec sdw:1:0:0217:0202:00:2: WSA883X Version 1_1, Variant: WSA8835_V2 Fixes: 43b8c7d ("ASoC: codecs: add wsa883x amplifier support") Cc: stable@vger.kernel.org # 6.0 Cc: Srinivas Kandagatla <srini@kernel.org> Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com> Link: https://patch.msgid.link/20260102111413.9605-2-johan@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 9ace475 commit 49aadf8

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

sound/soc/codecs/wsa883x.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ struct wsa883x_priv {
475475
int active_ports;
476476
int dev_mode;
477477
int comp_offset;
478+
bool hw_init;
478479
/*
479480
* Protects temperature reading code (related to speaker protection) and
480481
* fields: temperature and pa_on.
@@ -1043,6 +1044,9 @@ static int wsa883x_init(struct wsa883x_priv *wsa883x)
10431044
struct regmap *regmap = wsa883x->regmap;
10441045
int variant, version, ret;
10451046

1047+
if (wsa883x->hw_init)
1048+
return 0;
1049+
10461050
ret = regmap_read(regmap, WSA883X_OTP_REG_0, &variant);
10471051
if (ret)
10481052
return ret;
@@ -1085,6 +1089,8 @@ static int wsa883x_init(struct wsa883x_priv *wsa883x)
10851089
wsa883x->comp_offset);
10861090
}
10871091

1092+
wsa883x->hw_init = true;
1093+
10881094
return 0;
10891095
}
10901096

@@ -1093,6 +1099,9 @@ static int wsa883x_update_status(struct sdw_slave *slave,
10931099
{
10941100
struct wsa883x_priv *wsa883x = dev_get_drvdata(&slave->dev);
10951101

1102+
if (status == SDW_SLAVE_UNATTACHED)
1103+
wsa883x->hw_init = false;
1104+
10961105
if (status == SDW_SLAVE_ATTACHED && slave->dev_num > 0)
10971106
return wsa883x_init(wsa883x);
10981107

0 commit comments

Comments
 (0)