mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bard Liao <yung-chuan.liao@linux.intel.com>
To: broonie@kernel.org, tiwai@suse.de, linux-sound@vger.kernel.org,
	vkoul@kernel.org
Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org,
	pierre-louis.bossart@linux.dev, bard.liao@intel.com
Subject: [PATCH 01/15] soundwire: add sdw_slave_wait_for_initialization helper
Date: Thu, 26 Jun 2025 19:56:11 +0800	[thread overview]
Message-ID: <20250626115625.536423-2-yung-chuan.liao@linux.intel.com> (raw)
In-Reply-To: <20250626115625.536423-1-yung-chuan.liao@linux.intel.com>

waiting for slave->initialization_complete is commonly used by SoundWire
codec drivers. Add a helper to reduce the duplicated code.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Shuming Fan <shumingf@realtek.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 drivers/soundwire/slave.c     | 17 +++++++++++++++++
 include/linux/soundwire/sdw.h |  1 +
 2 files changed, 18 insertions(+)

diff --git a/drivers/soundwire/slave.c b/drivers/soundwire/slave.c
index d2d99555ec5a..5d45adb28491 100644
--- a/drivers/soundwire/slave.c
+++ b/drivers/soundwire/slave.c
@@ -104,6 +104,23 @@ int sdw_slave_add(struct sdw_bus *bus,
 }
 EXPORT_SYMBOL(sdw_slave_add);
 
+int sdw_slave_wait_for_initialization(struct sdw_slave *slave, unsigned int timeout)
+{
+	unsigned long time;
+
+	time = wait_for_completion_timeout(&slave->initialization_complete,
+					   msecs_to_jiffies(timeout));
+	if (!time) {
+		dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
+		sdw_show_ping_status(slave->bus, true);
+
+		return -ETIMEDOUT;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL(sdw_slave_wait_for_initialization);
+
 #if IS_ENABLED(CONFIG_ACPI)
 
 static bool find_slave(struct sdw_bus *bus,
diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h
index 0832776262ac..961a10af12c1 100644
--- a/include/linux/soundwire/sdw.h
+++ b/include/linux/soundwire/sdw.h
@@ -1087,6 +1087,7 @@ int sdw_stream_remove_slave(struct sdw_slave *slave,
 			    struct sdw_stream_runtime *stream);
 
 int sdw_slave_get_scale_index(struct sdw_slave *slave, u8 *base);
+int sdw_slave_wait_for_initialization(struct sdw_slave *slave, unsigned int timeout);
 
 /* messaging and data APIs */
 int sdw_read(struct sdw_slave *slave, u32 addr);
-- 
2.43.0


  reply	other threads:[~2025-06-26 11:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-26 11:56 [PATCH 00/15] ASoC/soundwire: Realtek codecs: wait codec init in hw_params Bard Liao
2025-06-26 11:56 ` Bard Liao [this message]
2025-06-26 11:56 ` [PATCH 02/15] ASoC: rt722: " Bard Liao
2025-06-26 11:56 ` [PATCH 03/15] ASoC: rt712: " Bard Liao
2025-06-26 11:56 ` [PATCH 04/15] ASoC: rt1320: " Bard Liao
2025-06-26 11:56 ` [PATCH 05/15] ASoC: rt721: " Bard Liao
2025-06-26 11:56 ` [PATCH 06/15] ASoC: rt715-sdca: " Bard Liao
2025-06-26 11:56 ` [PATCH 07/15] ASoC: rt711-sdca: " Bard Liao
2025-06-26 11:56 ` [PATCH 08/15] ASoC: rt711: " Bard Liao
2025-06-26 11:56 ` [PATCH 09/15] ASoC: rt715: " Bard Liao
2025-06-26 11:56 ` [PATCH 10/15] ASoC: rt700: " Bard Liao
2025-06-26 11:56 ` [PATCH 11/15] ASoC: rt1316: " Bard Liao
2025-06-26 11:56 ` [PATCH 12/15] ASoC: rt1318: " Bard Liao
2025-06-26 11:56 ` [PATCH 13/15] ASoC: rt1308: " Bard Liao
2025-06-26 11:56 ` [PATCH 14/15] ASoC: rt5682: " Bard Liao
2025-06-26 11:56 ` [PATCH 15/15] ASoC: rt1017: " Bard Liao
2025-06-26 12:19 ` [PATCH 00/15] ASoC/soundwire: Realtek codecs: " Pierre-Louis Bossart
2025-06-27  6:53   ` Liao, Bard
2025-07-01 10:13     ` Pierre-Louis Bossart
2025-07-01 10:33       ` Pierre-Louis Bossart
2025-07-01 11:42         ` Liao, Bard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250626115625.536423-2-yung-chuan.liao@linux.intel.com \
    --to=yung-chuan.liao@linux.intel.com \
    --cc=bard.liao@intel.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=tiwai@suse.de \
    --cc=vinod.koul@linaro.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®