public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/17] Add a new SoundWire enumeration helper
@ 2026-05-05 16:47 Charles Keepax
  2026-05-05 16:47 ` [PATCH 01/17] soundwire: Add a helper function to wait for device initialisation Charles Keepax
                   ` (16 more replies)
  0 siblings, 17 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:47 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Add a new SoundWire enumeration helper function, many drivers have
almost identical code in runtime resume so it makes sense to move this
to the core.

It is worth noting this is really step one of a larger process, there
are a few drivers that do more custom things and are not covered by this
series. But this series picks up the low hanging fruit and moves things
in a good direction.

The next step is to look at drivers that also wait at probe time, where
the unattached_request flag is not going to be valid.

Thanks,
Charles

Charles Keepax (17):
  soundwire: Add a helper function to wait for device initialisation
  ASoC: cs42l42: Use new SoundWire enumeration helper
  ASoC: max98363: Use new SoundWire enumeration helper
  ASoC: max98373: Use new SoundWire enumeration helper
  ASoC: rt700: Use new SoundWire enumeration helper
  ASoC: rt711: Use new SoundWire enumeration helper
  ASoC: rt712: Use new SoundWire enumeration helper
  ASoC: rt715: Use new SoundWire enumeration helper
  ASoc: rt721: Use new SoundWire enumeration helper
  ASoC: rt722: Use new SoundWire enumeration helper
  ASoC: rt1017: Use new SoundWire enumeration helper
  ASoC: rt1308: Use new SoundWire enumeration helper
  ASoC: rt1316: Use new SoundWire enumeration helper
  ASoC: rt1318: Use new SoundWire enumeration helper
  ASoC: rt1320: Use new SoundWire enumeration helper
  ASoC: rt5682: Use new SoundWire enumeration helper
  ASoC: tas2783: Use new SoundWire enumeration helper

 drivers/soundwire/bus.c            | 21 +++++++++++++++++++++
 include/linux/soundwire/sdw.h      |  2 ++
 sound/soc/codecs/cs42l42-sdw.c     | 15 ++++-----------
 sound/soc/codecs/max98363.c        | 17 ++++-------------
 sound/soc/codecs/max98373-sdw.c    | 18 ++++--------------
 sound/soc/codecs/rt1017-sdca-sdw.c | 18 ++++--------------
 sound/soc/codecs/rt1308-sdw.c      | 18 ++++--------------
 sound/soc/codecs/rt1316-sdw.c      | 18 ++++--------------
 sound/soc/codecs/rt1318-sdw.c      | 16 ++++------------
 sound/soc/codecs/rt1320-sdw.c      | 16 ++++------------
 sound/soc/codecs/rt5682-sdw.c      | 16 ++++------------
 sound/soc/codecs/rt700-sdw.c       | 18 ++++--------------
 sound/soc/codecs/rt711-sdca-sdw.c  | 16 ++++------------
 sound/soc/codecs/rt711-sdw.c       | 14 ++++----------
 sound/soc/codecs/rt712-sdca-dmic.c | 19 ++++---------------
 sound/soc/codecs/rt712-sdca-sdw.c  | 16 ++++------------
 sound/soc/codecs/rt715-sdca-sdw.c  | 18 ++++--------------
 sound/soc/codecs/rt715-sdw.c       | 18 ++++--------------
 sound/soc/codecs/rt721-sdca-sdw.c  | 16 ++++------------
 sound/soc/codecs/rt722-sdca-sdw.c  | 16 ++++------------
 sound/soc/codecs/tas2783-sdw.c     | 18 ++++--------------
 21 files changed, 99 insertions(+), 245 deletions(-)

-- 
2.47.3


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

* [PATCH 01/17] soundwire: Add a helper function to wait for device initialisation
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
@ 2026-05-05 16:47 ` Charles Keepax
  2026-05-05 16:57   ` Charles Keepax
  2026-05-05 16:47 ` [PATCH 02/17] ASoC: cs42l42: Use new SoundWire enumeration helper Charles Keepax
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:47 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Add a new helper function to wait for the device to enumerate
and be initialised by the SoundWire core. Most of the SoundWire
drivers have very similar boiler plate code in their runtime
resume, and that boiler plate tends to access various internals
of the SoundWire structs which is a mild layering violation.

Adding a new core helper function greatly eases both of these
issues.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 drivers/soundwire/bus.c       | 21 +++++++++++++++++++++
 include/linux/soundwire/sdw.h |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index fe5316d93fefe..b9ca35e530a3b 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -1372,6 +1372,27 @@ int sdw_slave_get_current_bank(struct sdw_slave *slave)
 }
 EXPORT_SYMBOL_GPL(sdw_slave_get_current_bank);
 
+int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout)
+{
+	unsigned long time;
+
+	if (!slave->unattach_request)
+		return 0;
+
+	time = wait_for_completion_timeout(&slave->initialization_complete,
+					   msecs_to_jiffies(timeout));
+	if (!time) {
+		dev_err(&slave->dev, "Initialization not complete\n");
+		sdw_show_ping_status(slave->bus, true);
+		return -ETIMEDOUT;
+	}
+
+	slave->unattach_request = 0;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(sdw_slave_wait_for_init);
+
 static int sdw_slave_set_frequency(struct sdw_slave *slave)
 {
 	int scale_index;
diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
index 6147eb1fb210d..847b001d1a774 100644
--- a/include/linux/soundwire/sdw.h
+++ b/include/linux/soundwire/sdw.h
@@ -1093,6 +1093,8 @@ int sdw_slave_get_current_bank(struct sdw_slave *sdev);
 
 int sdw_slave_get_scale_index(struct sdw_slave *slave, u8 *base);
 
+int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout);
+
 /* messaging and data APIs */
 int sdw_read(struct sdw_slave *slave, u32 addr);
 int sdw_write(struct sdw_slave *slave, u32 addr, u8 value);
-- 
2.47.3


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

* [PATCH 02/17] ASoC: cs42l42: Use new SoundWire enumeration helper
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
  2026-05-05 16:47 ` [PATCH 01/17] soundwire: Add a helper function to wait for device initialisation Charles Keepax
@ 2026-05-05 16:47 ` Charles Keepax
  2026-05-06  0:13   ` Mark Brown
  2026-05-05 16:47 ` [PATCH 03/17] ASoC: max98363: " Charles Keepax
                   ` (14 subsequent siblings)
  16 siblings, 1 reply; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:47 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Update the driver to use the new core helper that waits for the device
to enumerate on SoundWire and be initialised by the SoundWire core.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/cs42l42-sdw.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/sound/soc/codecs/cs42l42-sdw.c b/sound/soc/codecs/cs42l42-sdw.c
index d5999ad9ff9b4..ef030d0ddce94 100644
--- a/sound/soc/codecs/cs42l42-sdw.c
+++ b/sound/soc/codecs/cs42l42-sdw.c
@@ -433,19 +433,12 @@ static const struct reg_sequence cs42l42_soft_reboot_seq[] = {
 static int cs42l42_sdw_handle_unattach(struct cs42l42_private *cs42l42)
 {
 	struct sdw_slave *peripheral = cs42l42->sdw_peripheral;
-
-	if (!peripheral->unattach_request)
-		return 0;
+	int ret;
 
 	/* Cannot access registers until master re-attaches. */
-	dev_dbg(&peripheral->dev, "Wait for initialization_complete\n");
-	if (!wait_for_completion_timeout(&peripheral->initialization_complete,
-					 msecs_to_jiffies(5000))) {
-		dev_err(&peripheral->dev, "initialization_complete timed out\n");
-		return -ETIMEDOUT;
-	}
-
-	peripheral->unattach_request = 0;
+	ret = sdw_slave_wait_for_init(peripheral, 5000);
+	if (ret)
+		return ret;
 
 	/*
 	 * After a bus reset there must be a reconfiguration reset to
-- 
2.47.3


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

* [PATCH 03/17] ASoC: max98363: Use new SoundWire enumeration helper
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
  2026-05-05 16:47 ` [PATCH 01/17] soundwire: Add a helper function to wait for device initialisation Charles Keepax
  2026-05-05 16:47 ` [PATCH 02/17] ASoC: cs42l42: Use new SoundWire enumeration helper Charles Keepax
@ 2026-05-05 16:47 ` Charles Keepax
  2026-05-05 16:47 ` [PATCH 04/17] ASoC: max98373: " Charles Keepax
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:47 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Update the driver to use the new core helper that waits for the device
to enumerate on SoundWire and be initialised by the SoundWire core.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/max98363.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/sound/soc/codecs/max98363.c b/sound/soc/codecs/max98363.c
index 25af78ab30d5c..099dc5bf6195f 100644
--- a/sound/soc/codecs/max98363.c
+++ b/sound/soc/codecs/max98363.c
@@ -90,24 +90,15 @@ static int max98363_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct max98363_priv *max98363 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!max98363->first_hw_init)
 		return 0;
 
-	if (!slave->unattach_request)
-		goto regmap_sync;
-
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-					   msecs_to_jiffies(MAX98363_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(dev, "Initialization not complete, timed out\n");
-		return -ETIMEDOUT;
-	}
-
-regmap_sync:
+	ret = sdw_slave_wait_for_init(slave, MAX98363_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-	slave->unattach_request = 0;
 	regcache_cache_only(max98363->regmap, false);
 	regcache_sync(max98363->regmap);
 
-- 
2.47.3


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

* [PATCH 04/17] ASoC: max98373: Use new SoundWire enumeration helper
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
                   ` (2 preceding siblings ...)
  2026-05-05 16:47 ` [PATCH 03/17] ASoC: max98363: " Charles Keepax
@ 2026-05-05 16:47 ` Charles Keepax
  2026-05-05 16:47 ` [PATCH 05/17] ASoC: rt700: " Charles Keepax
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:47 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Update the driver to use the new core helper that waits for the device
to enumerate on SoundWire and be initialised by the SoundWire core.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/max98373-sdw.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/sound/soc/codecs/max98373-sdw.c b/sound/soc/codecs/max98373-sdw.c
index 16673440218cb..6829fa07c9ecb 100644
--- a/sound/soc/codecs/max98373-sdw.c
+++ b/sound/soc/codecs/max98373-sdw.c
@@ -266,25 +266,15 @@ static int max98373_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct max98373_priv *max98373 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!max98373->first_hw_init)
 		return 0;
 
-	if (!slave->unattach_request)
-		goto regmap_sync;
-
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-					   msecs_to_jiffies(MAX98373_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(dev, "Initialization not complete, timed out\n");
-		sdw_show_ping_status(slave->bus, true);
-
-		return -ETIMEDOUT;
-	}
+	ret = sdw_slave_wait_for_init(slave, MAX98373_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-regmap_sync:
-	slave->unattach_request = 0;
 	regcache_cache_only(max98373->regmap, false);
 	regcache_sync(max98373->regmap);
 
-- 
2.47.3


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

* [PATCH 05/17] ASoC: rt700: Use new SoundWire enumeration helper
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
                   ` (3 preceding siblings ...)
  2026-05-05 16:47 ` [PATCH 04/17] ASoC: max98373: " Charles Keepax
@ 2026-05-05 16:47 ` Charles Keepax
  2026-05-05 16:47 ` [PATCH 06/17] ASoC: rt711: " Charles Keepax
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:47 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Update the driver to use the new core helper that waits for the device
to enumerate on SoundWire and be initialised by the SoundWire core.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/rt700-sdw.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/sound/soc/codecs/rt700-sdw.c b/sound/soc/codecs/rt700-sdw.c
index 9ce36a66fae1d..30fcca210f051 100644
--- a/sound/soc/codecs/rt700-sdw.c
+++ b/sound/soc/codecs/rt700-sdw.c
@@ -522,25 +522,15 @@ static int rt700_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct rt700_priv *rt700 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!rt700->first_hw_init)
 		return 0;
 
-	if (!slave->unattach_request)
-		goto regmap_sync;
-
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-				msecs_to_jiffies(RT700_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(&slave->dev, "Initialization not complete, timed out\n");
-		sdw_show_ping_status(slave->bus, true);
-
-		return -ETIMEDOUT;
-	}
+	ret = sdw_slave_wait_for_init(slave, RT700_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-regmap_sync:
-	slave->unattach_request = 0;
 	regcache_cache_only(rt700->regmap, false);
 	regcache_sync_region(rt700->regmap, 0x3000, 0x8fff);
 	regcache_sync_region(rt700->regmap, 0x752010, 0x75206b);
-- 
2.47.3


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

* [PATCH 06/17] ASoC: rt711: Use new SoundWire enumeration helper
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
                   ` (4 preceding siblings ...)
  2026-05-05 16:47 ` [PATCH 05/17] ASoC: rt700: " Charles Keepax
@ 2026-05-05 16:47 ` Charles Keepax
  2026-05-05 16:47 ` [PATCH 07/17] ASoC: rt712: " Charles Keepax
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:47 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Update the driver to use the new core helper that waits for the device
to enumerate on SoundWire and be initialised by the SoundWire core.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/rt711-sdca-sdw.c | 16 ++++------------
 sound/soc/codecs/rt711-sdw.c      | 14 ++++----------
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/sound/soc/codecs/rt711-sdca-sdw.c b/sound/soc/codecs/rt711-sdca-sdw.c
index 49dacceddf815..a8164fc3979ab 100644
--- a/sound/soc/codecs/rt711-sdca-sdw.c
+++ b/sound/soc/codecs/rt711-sdca-sdw.c
@@ -438,7 +438,7 @@ static int rt711_sdca_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct rt711_sdca_priv *rt711 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!rt711->first_hw_init)
 		return 0;
@@ -451,20 +451,12 @@ static int rt711_sdca_dev_resume(struct device *dev)
 			rt711->disable_irq = false;
 		}
 		mutex_unlock(&rt711->disable_irq_lock);
-		goto regmap_sync;
 	}
 
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-				msecs_to_jiffies(RT711_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
-		sdw_show_ping_status(slave->bus, true);
+	ret = sdw_slave_wait_for_init(slave, RT711_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-		return -ETIMEDOUT;
-	}
-
-regmap_sync:
-	slave->unattach_request = 0;
 	regcache_cache_only(rt711->regmap, false);
 	regcache_sync(rt711->regmap);
 	regcache_cache_only(rt711->mbq_regmap, false);
diff --git a/sound/soc/codecs/rt711-sdw.c b/sound/soc/codecs/rt711-sdw.c
index 72ddf4cebdf36..df3c43f2ab6b8 100644
--- a/sound/soc/codecs/rt711-sdw.c
+++ b/sound/soc/codecs/rt711-sdw.c
@@ -530,7 +530,7 @@ static int rt711_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct rt711_priv *rt711 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!rt711->first_hw_init)
 		return 0;
@@ -542,18 +542,12 @@ static int rt711_dev_resume(struct device *dev)
 			rt711->disable_irq = false;
 		}
 		mutex_unlock(&rt711->disable_irq_lock);
-		goto regmap_sync;
 	}
 
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-				msecs_to_jiffies(RT711_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
-		return -ETIMEDOUT;
-	}
+	ret = sdw_slave_wait_for_init(slave, RT711_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-regmap_sync:
-	slave->unattach_request = 0;
 	regcache_cache_only(rt711->regmap, false);
 	regcache_sync_region(rt711->regmap, 0x3000, 0x8fff);
 	regcache_sync_region(rt711->regmap, 0x752009, 0x752091);
-- 
2.47.3


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

* [PATCH 07/17] ASoC: rt712: Use new SoundWire enumeration helper
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
                   ` (5 preceding siblings ...)
  2026-05-05 16:47 ` [PATCH 06/17] ASoC: rt711: " Charles Keepax
@ 2026-05-05 16:47 ` Charles Keepax
  2026-05-05 16:47 ` [PATCH 08/17] ASoC: rt715: " Charles Keepax
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:47 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Update the driver to use the new core helper that waits for the device
to enumerate on SoundWire and be initialised by the SoundWire core.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/rt712-sdca-dmic.c | 19 ++++---------------
 sound/soc/codecs/rt712-sdca-sdw.c  | 16 ++++------------
 2 files changed, 8 insertions(+), 27 deletions(-)

diff --git a/sound/soc/codecs/rt712-sdca-dmic.c b/sound/soc/codecs/rt712-sdca-dmic.c
index 4d83544ef2049..4c5c2f5ba5edf 100644
--- a/sound/soc/codecs/rt712-sdca-dmic.c
+++ b/sound/soc/codecs/rt712-sdca-dmic.c
@@ -905,26 +905,15 @@ static int rt712_sdca_dmic_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct rt712_sdca_dmic_priv *rt712 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!rt712->first_hw_init)
 		return 0;
 
-	if (!slave->unattach_request)
-		goto regmap_sync;
-
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-				msecs_to_jiffies(RT712_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(&slave->dev, "%s: Initialization not complete, timed out\n",
-			__func__);
-		sdw_show_ping_status(slave->bus, true);
-
-		return -ETIMEDOUT;
-	}
+	ret = sdw_slave_wait_for_init(slave, RT712_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-regmap_sync:
-	slave->unattach_request = 0;
 	regcache_cache_only(rt712->regmap, false);
 	regcache_sync(rt712->regmap);
 	regcache_cache_only(rt712->mbq_regmap, false);
diff --git a/sound/soc/codecs/rt712-sdca-sdw.c b/sound/soc/codecs/rt712-sdca-sdw.c
index 8c82887174db2..5817321804736 100644
--- a/sound/soc/codecs/rt712-sdca-sdw.c
+++ b/sound/soc/codecs/rt712-sdca-sdw.c
@@ -450,7 +450,7 @@ static int rt712_sdca_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct rt712_sdca_priv *rt712 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!rt712->first_hw_init)
 		return 0;
@@ -464,20 +464,12 @@ static int rt712_sdca_dev_resume(struct device *dev)
 			rt712->disable_irq = false;
 		}
 		mutex_unlock(&rt712->disable_irq_lock);
-		goto regmap_sync;
 	}
 
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-				msecs_to_jiffies(RT712_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
-		sdw_show_ping_status(slave->bus, true);
+	ret = sdw_slave_wait_for_init(slave, RT712_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-		return -ETIMEDOUT;
-	}
-
-regmap_sync:
-	slave->unattach_request = 0;
 	regcache_cache_only(rt712->regmap, false);
 	regcache_sync(rt712->regmap);
 	regcache_cache_only(rt712->mbq_regmap, false);
-- 
2.47.3


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

* [PATCH 08/17] ASoC: rt715: Use new SoundWire enumeration helper
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
                   ` (6 preceding siblings ...)
  2026-05-05 16:47 ` [PATCH 07/17] ASoC: rt712: " Charles Keepax
@ 2026-05-05 16:47 ` Charles Keepax
  2026-05-05 16:47 ` [PATCH 09/17] ASoc: rt721: " Charles Keepax
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:47 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Update the driver to use the new core helper that waits for the device
to enumerate on SoundWire and be initialised by the SoundWire core.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/rt715-sdca-sdw.c | 18 ++++--------------
 sound/soc/codecs/rt715-sdw.c      | 18 ++++--------------
 2 files changed, 8 insertions(+), 28 deletions(-)

diff --git a/sound/soc/codecs/rt715-sdca-sdw.c b/sound/soc/codecs/rt715-sdca-sdw.c
index 968bc183b8d8c..4b9815b5628db 100644
--- a/sound/soc/codecs/rt715-sdca-sdw.c
+++ b/sound/soc/codecs/rt715-sdca-sdw.c
@@ -224,25 +224,15 @@ static int rt715_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct rt715_sdca_priv *rt715 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!rt715->first_hw_init)
 		return 0;
 
-	if (!slave->unattach_request)
-		goto regmap_sync;
+	ret = sdw_slave_wait_for_init(slave, RT715_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-					   msecs_to_jiffies(RT715_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
-		sdw_show_ping_status(slave->bus, true);
-
-		return -ETIMEDOUT;
-	}
-
-regmap_sync:
-	slave->unattach_request = 0;
 	regcache_cache_only(rt715->regmap, false);
 	regcache_sync_region(rt715->regmap,
 		SDW_SDCA_CTL(FUN_JACK_CODEC, RT715_SDCA_ST_EN, RT715_SDCA_ST_CTRL,
diff --git a/sound/soc/codecs/rt715-sdw.c b/sound/soc/codecs/rt715-sdw.c
index 49c91d015be4d..7f83a8f1a06e9 100644
--- a/sound/soc/codecs/rt715-sdw.c
+++ b/sound/soc/codecs/rt715-sdw.c
@@ -501,25 +501,15 @@ static int rt715_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct rt715_priv *rt715 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!rt715->first_hw_init)
 		return 0;
 
-	if (!slave->unattach_request)
-		goto regmap_sync;
-
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-					   msecs_to_jiffies(RT715_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
-		sdw_show_ping_status(slave->bus, true);
-
-		return -ETIMEDOUT;
-	}
+	ret = sdw_slave_wait_for_init(slave, RT715_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-regmap_sync:
-	slave->unattach_request = 0;
 	regcache_cache_only(rt715->regmap, false);
 	regcache_sync_region(rt715->regmap, 0x3000, 0x8fff);
 	regcache_sync_region(rt715->regmap, 0x752039, 0x752039);
-- 
2.47.3


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

* [PATCH 09/17] ASoc: rt721: Use new SoundWire enumeration helper
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
                   ` (7 preceding siblings ...)
  2026-05-05 16:47 ` [PATCH 08/17] ASoC: rt715: " Charles Keepax
@ 2026-05-05 16:47 ` Charles Keepax
  2026-05-05 16:48 ` [PATCH 10/17] ASoC: rt722: " Charles Keepax
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:47 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Update the driver to use the new core helper that waits for the device
to enumerate on SoundWire and be initialised by the SoundWire core.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/rt721-sdca-sdw.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/sound/soc/codecs/rt721-sdca-sdw.c b/sound/soc/codecs/rt721-sdca-sdw.c
index 6eb8512975b85..58606209316a4 100644
--- a/sound/soc/codecs/rt721-sdca-sdw.c
+++ b/sound/soc/codecs/rt721-sdca-sdw.c
@@ -489,7 +489,7 @@ static int rt721_sdca_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct rt721_sdca_priv *rt721 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!rt721->first_hw_init)
 		return 0;
@@ -502,20 +502,12 @@ static int rt721_sdca_dev_resume(struct device *dev)
 			rt721->disable_irq = false;
 		}
 		mutex_unlock(&rt721->disable_irq_lock);
-		goto regmap_sync;
 	}
 
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-				msecs_to_jiffies(RT721_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(&slave->dev, "Initialization not complete, timed out\n");
-		sdw_show_ping_status(slave->bus, true);
+	ret = sdw_slave_wait_for_init(slave, RT721_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-		return -ETIMEDOUT;
-	}
-
-regmap_sync:
-	slave->unattach_request = 0;
 	regcache_cache_only(rt721->regmap, false);
 	regcache_sync(rt721->regmap);
 	regcache_cache_only(rt721->mbq_regmap, false);
-- 
2.47.3


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

* [PATCH 10/17] ASoC: rt722: Use new SoundWire enumeration helper
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
                   ` (8 preceding siblings ...)
  2026-05-05 16:47 ` [PATCH 09/17] ASoc: rt721: " Charles Keepax
@ 2026-05-05 16:48 ` Charles Keepax
  2026-05-05 16:48 ` [PATCH 11/17] ASoC: rt1017: " Charles Keepax
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:48 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Update the driver to use the new core helper that waits for the device
to enumerate on SoundWire and be initialised by the SoundWire core.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/rt722-sdca-sdw.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/sound/soc/codecs/rt722-sdca-sdw.c b/sound/soc/codecs/rt722-sdca-sdw.c
index 0a5b3ffa90daf..a5feba3d0c182 100644
--- a/sound/soc/codecs/rt722-sdca-sdw.c
+++ b/sound/soc/codecs/rt722-sdca-sdw.c
@@ -501,7 +501,7 @@ static int rt722_sdca_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct rt722_sdca_priv *rt722 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!rt722->first_hw_init)
 		return 0;
@@ -514,20 +514,12 @@ static int rt722_sdca_dev_resume(struct device *dev)
 			rt722->disable_irq = false;
 		}
 		mutex_unlock(&rt722->disable_irq_lock);
-		goto regmap_sync;
 	}
 
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-				msecs_to_jiffies(RT722_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(&slave->dev, "Initialization not complete, timed out\n");
-		sdw_show_ping_status(slave->bus, true);
+	ret = sdw_slave_wait_for_init(slave, RT722_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-		return -ETIMEDOUT;
-	}
-
-regmap_sync:
-	slave->unattach_request = 0;
 	regcache_cache_only(rt722->regmap, false);
 	regcache_sync(rt722->regmap);
 	return 0;
-- 
2.47.3


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

* [PATCH 11/17] ASoC: rt1017: Use new SoundWire enumeration helper
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
                   ` (9 preceding siblings ...)
  2026-05-05 16:48 ` [PATCH 10/17] ASoC: rt722: " Charles Keepax
@ 2026-05-05 16:48 ` Charles Keepax
  2026-05-05 16:48 ` [PATCH 12/17] ASoC: rt1308: " Charles Keepax
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:48 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Update the driver to use the new core helper that waits for the device
to enumerate on SoundWire and be initialised by the SoundWire core.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/rt1017-sdca-sdw.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/sound/soc/codecs/rt1017-sdca-sdw.c b/sound/soc/codecs/rt1017-sdca-sdw.c
index 148b36173a257..d62e8a2536767 100644
--- a/sound/soc/codecs/rt1017-sdca-sdw.c
+++ b/sound/soc/codecs/rt1017-sdca-sdw.c
@@ -773,25 +773,15 @@ static int rt1017_sdca_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct rt1017_sdca_priv *rt1017 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!rt1017->first_hw_init)
 		return 0;
 
-	if (!slave->unattach_request)
-		goto regmap_sync;
-
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-				msecs_to_jiffies(RT1017_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(&slave->dev, "Initialization not complete, timed out\n");
-		sdw_show_ping_status(slave->bus, true);
-
-		return -ETIMEDOUT;
-	}
+	ret = sdw_slave_wait_for_init(slave, RT1017_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-regmap_sync:
-	slave->unattach_request = 0;
 	regcache_cache_only(rt1017->regmap, false);
 	regcache_sync(rt1017->regmap);
 
-- 
2.47.3


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

* [PATCH 12/17] ASoC: rt1308: Use new SoundWire enumeration helper
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
                   ` (10 preceding siblings ...)
  2026-05-05 16:48 ` [PATCH 11/17] ASoC: rt1017: " Charles Keepax
@ 2026-05-05 16:48 ` Charles Keepax
  2026-05-05 16:48 ` [PATCH 13/17] ASoC: rt1316: " Charles Keepax
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:48 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Update the driver to use the new core helper that waits for the device
to enumerate on SoundWire and be initialised by the SoundWire core.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/rt1308-sdw.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/sound/soc/codecs/rt1308-sdw.c b/sound/soc/codecs/rt1308-sdw.c
index e077d096bc239..39e06a3a75609 100644
--- a/sound/soc/codecs/rt1308-sdw.c
+++ b/sound/soc/codecs/rt1308-sdw.c
@@ -768,25 +768,15 @@ static int rt1308_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!rt1308->first_hw_init)
 		return 0;
 
-	if (!slave->unattach_request)
-		goto regmap_sync;
-
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-				msecs_to_jiffies(RT1308_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(&slave->dev, "Initialization not complete, timed out\n");
-		sdw_show_ping_status(slave->bus, true);
-
-		return -ETIMEDOUT;
-	}
+	ret = sdw_slave_wait_for_init(slave, RT1308_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-regmap_sync:
-	slave->unattach_request = 0;
 	regcache_cache_only(rt1308->regmap, false);
 	regcache_sync_region(rt1308->regmap, 0xc000, 0xcfff);
 
-- 
2.47.3


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

* [PATCH 13/17] ASoC: rt1316: Use new SoundWire enumeration helper
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
                   ` (11 preceding siblings ...)
  2026-05-05 16:48 ` [PATCH 12/17] ASoC: rt1308: " Charles Keepax
@ 2026-05-05 16:48 ` Charles Keepax
  2026-05-05 16:48 ` [PATCH 14/17] ASoC: rt1318: " Charles Keepax
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:48 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Update the driver to use the new core helper that waits for the device
to enumerate on SoundWire and be initialised by the SoundWire core.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/rt1316-sdw.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/sound/soc/codecs/rt1316-sdw.c b/sound/soc/codecs/rt1316-sdw.c
index 20fc1579eb9cf..1828fd9d5af6a 100644
--- a/sound/soc/codecs/rt1316-sdw.c
+++ b/sound/soc/codecs/rt1316-sdw.c
@@ -745,25 +745,15 @@ static int rt1316_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct rt1316_sdw_priv *rt1316 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!rt1316->first_hw_init)
 		return 0;
 
-	if (!slave->unattach_request)
-		goto regmap_sync;
-
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-				msecs_to_jiffies(RT1316_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
-		sdw_show_ping_status(slave->bus, true);
-
-		return -ETIMEDOUT;
-	}
+	ret = sdw_slave_wait_for_init(slave, RT1316_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-regmap_sync:
-	slave->unattach_request = 0;
 	regcache_cache_only(rt1316->regmap, false);
 	regcache_sync(rt1316->regmap);
 
-- 
2.47.3


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

* [PATCH 14/17] ASoC: rt1318: Use new SoundWire enumeration helper
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
                   ` (12 preceding siblings ...)
  2026-05-05 16:48 ` [PATCH 13/17] ASoC: rt1316: " Charles Keepax
@ 2026-05-05 16:48 ` Charles Keepax
  2026-05-05 16:48 ` [PATCH 15/17] ASoC: rt1320: " Charles Keepax
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:48 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Update the driver to use the new core helper that waits for the device
to enumerate on SoundWire and be initialised by the SoundWire core.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/rt1318-sdw.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/sound/soc/codecs/rt1318-sdw.c b/sound/soc/codecs/rt1318-sdw.c
index d28f1afe68f18..51bd11b92a554 100644
--- a/sound/soc/codecs/rt1318-sdw.c
+++ b/sound/soc/codecs/rt1318-sdw.c
@@ -821,23 +821,15 @@ static int rt1318_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct rt1318_sdw_priv *rt1318 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!rt1318->first_hw_init)
 		return 0;
 
-	if (!slave->unattach_request)
-		goto regmap_sync;
-
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-				msecs_to_jiffies(RT1318_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
-		return -ETIMEDOUT;
-	}
+	ret = sdw_slave_wait_for_init(slave, RT1318_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-regmap_sync:
-	slave->unattach_request = 0;
 	regcache_cache_only(rt1318->regmap, false);
 	regcache_sync(rt1318->regmap);
 
-- 
2.47.3


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

* [PATCH 15/17] ASoC: rt1320: Use new SoundWire enumeration helper
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
                   ` (13 preceding siblings ...)
  2026-05-05 16:48 ` [PATCH 14/17] ASoC: rt1318: " Charles Keepax
@ 2026-05-05 16:48 ` Charles Keepax
  2026-05-05 16:48 ` [PATCH 16/17] ASoC: rt5682: " Charles Keepax
  2026-05-05 16:48 ` [PATCH 17/17] ASoC: tas2783: " Charles Keepax
  16 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:48 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Update the driver to use the new core helper that waits for the device
to enumerate on SoundWire and be initialised by the SoundWire core.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/rt1320-sdw.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/sound/soc/codecs/rt1320-sdw.c b/sound/soc/codecs/rt1320-sdw.c
index 192faa431b5e9..13493b85f3c95 100644
--- a/sound/soc/codecs/rt1320-sdw.c
+++ b/sound/soc/codecs/rt1320-sdw.c
@@ -3053,23 +3053,15 @@ static int rt1320_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct rt1320_sdw_priv *rt1320 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!rt1320->first_hw_init)
 		return 0;
 
-	if (!slave->unattach_request)
-		goto regmap_sync;
-
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-				msecs_to_jiffies(RT1320_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
-		return -ETIMEDOUT;
-	}
+	ret = sdw_slave_wait_for_init(slave, RT1320_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-regmap_sync:
-	slave->unattach_request = 0;
 	regcache_cache_only(rt1320->regmap, false);
 	regcache_sync(rt1320->regmap);
 	regcache_cache_only(rt1320->mbq_regmap, false);
-- 
2.47.3


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

* [PATCH 16/17] ASoC: rt5682: Use new SoundWire enumeration helper
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
                   ` (14 preceding siblings ...)
  2026-05-05 16:48 ` [PATCH 15/17] ASoC: rt1320: " Charles Keepax
@ 2026-05-05 16:48 ` Charles Keepax
  2026-05-05 16:48 ` [PATCH 17/17] ASoC: tas2783: " Charles Keepax
  16 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:48 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Update the driver to use the new core helper that waits for the device
to enumerate on SoundWire and be initialised by the SoundWire core.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/rt5682-sdw.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/sound/soc/codecs/rt5682-sdw.c b/sound/soc/codecs/rt5682-sdw.c
index fc464538ceffb..ec2a35a0cacde 100644
--- a/sound/soc/codecs/rt5682-sdw.c
+++ b/sound/soc/codecs/rt5682-sdw.c
@@ -754,7 +754,7 @@ static int rt5682_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct rt5682_priv *rt5682 = dev_get_drvdata(dev);
-	unsigned long time;
+	int ret;
 
 	if (!rt5682->first_hw_init)
 		return 0;
@@ -766,20 +766,12 @@ static int rt5682_dev_resume(struct device *dev)
 			rt5682->disable_irq = false;
 		}
 		mutex_unlock(&rt5682->disable_irq_lock);
-		goto regmap_sync;
 	}
 
-	time = wait_for_completion_timeout(&slave->initialization_complete,
-				msecs_to_jiffies(RT5682_PROBE_TIMEOUT));
-	if (!time) {
-		dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
-		sdw_show_ping_status(slave->bus, true);
-
-		return -ETIMEDOUT;
-	}
+	ret = sdw_slave_wait_for_init(slave, RT5682_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-regmap_sync:
-	slave->unattach_request = 0;
 	regcache_cache_only(rt5682->sdw_regmap, false);
 	regcache_cache_only(rt5682->regmap, false);
 	regcache_sync(rt5682->regmap);
-- 
2.47.3


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

* [PATCH 17/17] ASoC: tas2783: Use new SoundWire enumeration helper
  2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
                   ` (15 preceding siblings ...)
  2026-05-05 16:48 ` [PATCH 16/17] ASoC: rt5682: " Charles Keepax
@ 2026-05-05 16:48 ` Charles Keepax
  16 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:48 UTC (permalink / raw)
  To: broonie
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

Update the driver to use the new core helper that waits for the device
to enumerate on SoundWire and be initialised by the SoundWire core.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/tas2783-sdw.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/sound/soc/codecs/tas2783-sdw.c b/sound/soc/codecs/tas2783-sdw.c
index 38009168c5a11..69d03ddc7a0ba 100644
--- a/sound/soc/codecs/tas2783-sdw.c
+++ b/sound/soc/codecs/tas2783-sdw.c
@@ -1082,22 +1082,12 @@ static s32 tas2783_sdca_dev_resume(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
 	struct tas2783_prv *tas_dev = dev_get_drvdata(dev);
-	unsigned long t;
-
-	if (!slave->unattach_request)
-		goto regmap_sync;
-
-	t = wait_for_completion_timeout(&slave->initialization_complete,
-					msecs_to_jiffies(TAS2783_PROBE_TIMEOUT));
-	if (!t) {
-		dev_err(&slave->dev, "resume: initialization timed out\n");
-		sdw_show_ping_status(slave->bus, true);
-		return -ETIMEDOUT;
-	}
+	int ret;
 
-	slave->unattach_request = 0;
+	ret = sdw_slave_wait_for_init(slave, TAS2783_PROBE_TIMEOUT);
+	if (ret)
+		return ret;
 
-regmap_sync:
 	regcache_cache_only(tas_dev->regmap, false);
 	regcache_sync(tas_dev->regmap);
 	return 0;
-- 
2.47.3


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

* Re: [PATCH 01/17] soundwire: Add a helper function to wait for device initialisation
  2026-05-05 16:47 ` [PATCH 01/17] soundwire: Add a helper function to wait for device initialisation Charles Keepax
@ 2026-05-05 16:57   ` Charles Keepax
  2026-05-06 10:53     ` Charles Keepax
  0 siblings, 1 reply; 22+ messages in thread
From: Charles Keepax @ 2026-05-05 16:57 UTC (permalink / raw)
  To: broonie, vkoul
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

On Tue, May 05, 2026 at 05:47:51PM +0100, Charles Keepax wrote:
> Add a new helper function to wait for the device to enumerate
> and be initialised by the SoundWire core. Most of the SoundWire
> drivers have very similar boiler plate code in their runtime
> resume, and that boiler plate tends to access various internals
> of the SoundWire structs which is a mild layering violation.
> 
> Adding a new core helper function greatly eases both of these
> issues.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> ---

Sorry Vinod, it appears I somehow completely forgot to CC you on
this series. Let me know if you got it through the mailing list,
and if not I will do a resend.

Thanks,
Charles

>  drivers/soundwire/bus.c       | 21 +++++++++++++++++++++
>  include/linux/soundwire/sdw.h |  2 ++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
> index fe5316d93fefe..b9ca35e530a3b 100644
> --- a/drivers/soundwire/bus.c
> +++ b/drivers/soundwire/bus.c
> @@ -1372,6 +1372,27 @@ int sdw_slave_get_current_bank(struct sdw_slave *slave)
>  }
>  EXPORT_SYMBOL_GPL(sdw_slave_get_current_bank);
>  
> +int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout)
> +{
> +	unsigned long time;
> +
> +	if (!slave->unattach_request)
> +		return 0;
> +
> +	time = wait_for_completion_timeout(&slave->initialization_complete,
> +					   msecs_to_jiffies(timeout));
> +	if (!time) {
> +		dev_err(&slave->dev, "Initialization not complete\n");
> +		sdw_show_ping_status(slave->bus, true);
> +		return -ETIMEDOUT;
> +	}
> +
> +	slave->unattach_request = 0;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(sdw_slave_wait_for_init);
> +
>  static int sdw_slave_set_frequency(struct sdw_slave *slave)
>  {
>  	int scale_index;
> diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
> index 6147eb1fb210d..847b001d1a774 100644
> --- a/include/linux/soundwire/sdw.h
> +++ b/include/linux/soundwire/sdw.h
> @@ -1093,6 +1093,8 @@ int sdw_slave_get_current_bank(struct sdw_slave *sdev);
>  
>  int sdw_slave_get_scale_index(struct sdw_slave *slave, u8 *base);
>  
> +int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout);
> +
>  /* messaging and data APIs */
>  int sdw_read(struct sdw_slave *slave, u32 addr);
>  int sdw_write(struct sdw_slave *slave, u32 addr, u8 value);
> -- 
> 2.47.3
> 

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

* Re: [PATCH 02/17] ASoC: cs42l42: Use new SoundWire enumeration helper
  2026-05-05 16:47 ` [PATCH 02/17] ASoC: cs42l42: Use new SoundWire enumeration helper Charles Keepax
@ 2026-05-06  0:13   ` Mark Brown
  2026-05-06  8:26     ` Charles Keepax
  0 siblings, 1 reply; 22+ messages in thread
From: Mark Brown @ 2026-05-06  0:13 UTC (permalink / raw)
  To: Charles Keepax
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

[-- Attachment #1: Type: text/plain, Size: 644 bytes --]

On Tue, May 05, 2026 at 05:47:52PM +0100, Charles Keepax wrote:
> Update the driver to use the new core helper that waits for the device
> to enumerate on SoundWire and be initialised by the SoundWire core.

>  static int cs42l42_sdw_handle_unattach(struct cs42l42_private *cs42l42)
>  {

> -	if (!peripheral->unattach_request)
> -		return 0;

...

>  
>  	/*
>  	 * After a bus reset there must be a reconfiguration reset to

We now always fall through to this block of code instead of exiting
early if the device wasn't actually reset, the new helper doesn't
distinguish between no reset and successfully waited for reset.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 02/17] ASoC: cs42l42: Use new SoundWire enumeration helper
  2026-05-06  0:13   ` Mark Brown
@ 2026-05-06  8:26     ` Charles Keepax
  0 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-06  8:26 UTC (permalink / raw)
  To: Mark Brown
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

On Wed, May 06, 2026 at 09:13:55AM +0900, Mark Brown wrote:
> On Tue, May 05, 2026 at 05:47:52PM +0100, Charles Keepax wrote:
> > Update the driver to use the new core helper that waits for the device
> > to enumerate on SoundWire and be initialised by the SoundWire core.
> 
> >  static int cs42l42_sdw_handle_unattach(struct cs42l42_private *cs42l42)
> >  {
> 
> > -	if (!peripheral->unattach_request)
> > -		return 0;
> 
> ...
> 
> >  
> >  	/*
> >  	 * After a bus reset there must be a reconfiguration reset to
> 
> We now always fall through to this block of code instead of exiting
> early if the device wasn't actually reset, the new helper doesn't
> distinguish between no reset and successfully waited for reset.

Thanks will give a couple days for any other comments then do a
spin.

Thanks,
Charles

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

* Re: [PATCH 01/17] soundwire: Add a helper function to wait for device initialisation
  2026-05-05 16:57   ` Charles Keepax
@ 2026-05-06 10:53     ` Charles Keepax
  0 siblings, 0 replies; 22+ messages in thread
From: Charles Keepax @ 2026-05-06 10:53 UTC (permalink / raw)
  To: broonie, vkoul
  Cc: lgirdwood, yung-chuan.liao, pierre-louis.bossart, peter.ujfalusi,
	oder_chiou, jack.yu, shumingf, shenghao-ding, niranjan.hy,
	kevin-lu, baojun.xu, sen, linux-sound, linux-kernel, patches

On Tue, May 05, 2026 at 05:57:05PM +0100, Charles Keepax wrote:
> On Tue, May 05, 2026 at 05:47:51PM +0100, Charles Keepax wrote:
> > --- a/include/linux/soundwire/sdw.h
> > +++ b/include/linux/soundwire/sdw.h
> > @@ -1093,6 +1093,8 @@ int sdw_slave_get_current_bank(struct sdw_slave *sdev);
> >  
> >  int sdw_slave_get_scale_index(struct sdw_slave *slave, u8 *base);
> >  
> > +int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout);
> > +

This should also probably get a stub for the no soundwire case.

Thanks,
Charles

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

end of thread, other threads:[~2026-05-06 10:54 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-05 16:47 [PATCH 00/17] Add a new SoundWire enumeration helper Charles Keepax
2026-05-05 16:47 ` [PATCH 01/17] soundwire: Add a helper function to wait for device initialisation Charles Keepax
2026-05-05 16:57   ` Charles Keepax
2026-05-06 10:53     ` Charles Keepax
2026-05-05 16:47 ` [PATCH 02/17] ASoC: cs42l42: Use new SoundWire enumeration helper Charles Keepax
2026-05-06  0:13   ` Mark Brown
2026-05-06  8:26     ` Charles Keepax
2026-05-05 16:47 ` [PATCH 03/17] ASoC: max98363: " Charles Keepax
2026-05-05 16:47 ` [PATCH 04/17] ASoC: max98373: " Charles Keepax
2026-05-05 16:47 ` [PATCH 05/17] ASoC: rt700: " Charles Keepax
2026-05-05 16:47 ` [PATCH 06/17] ASoC: rt711: " Charles Keepax
2026-05-05 16:47 ` [PATCH 07/17] ASoC: rt712: " Charles Keepax
2026-05-05 16:47 ` [PATCH 08/17] ASoC: rt715: " Charles Keepax
2026-05-05 16:47 ` [PATCH 09/17] ASoc: rt721: " Charles Keepax
2026-05-05 16:48 ` [PATCH 10/17] ASoC: rt722: " Charles Keepax
2026-05-05 16:48 ` [PATCH 11/17] ASoC: rt1017: " Charles Keepax
2026-05-05 16:48 ` [PATCH 12/17] ASoC: rt1308: " Charles Keepax
2026-05-05 16:48 ` [PATCH 13/17] ASoC: rt1316: " Charles Keepax
2026-05-05 16:48 ` [PATCH 14/17] ASoC: rt1318: " Charles Keepax
2026-05-05 16:48 ` [PATCH 15/17] ASoC: rt1320: " Charles Keepax
2026-05-05 16:48 ` [PATCH 16/17] ASoC: rt5682: " Charles Keepax
2026-05-05 16:48 ` [PATCH 17/17] ASoC: tas2783: " Charles Keepax

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