[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250626115625.536423-2-yung-chuan.liao@linux.intel.com>
Date: Thu, 26 Jun 2025 19:56:11 +0800
From: Bard Liao <yung-chuan.liao@...ux.intel.com>
To: broonie@...nel.org,
tiwai@...e.de,
linux-sound@...r.kernel.org,
vkoul@...nel.org
Cc: vinod.koul@...aro.org,
linux-kernel@...r.kernel.org,
pierre-louis.bossart@...ux.dev,
bard.liao@...el.com
Subject: [PATCH 01/15] soundwire: add sdw_slave_wait_for_initialization helper
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@...ux.intel.com>
Reviewed-by: Shuming Fan <shumingf@...ltek.com>
Reviewed-by: Charles Keepax <ckeepax@...nsource.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
Powered by blists - more mailing lists