From patchwork Wed Aug 26 03:48:33 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Chiu X-Patchwork-Id: 2292339 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hV9cv5k4Xz1xtN for ; Wed, 26 Aug 2026 13:49:19 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1wz4dV-0002Hb-6Q; Wed, 26 Aug 2026 03:49:13 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1wz4dS-0002Fx-GU for kernel-team@lists.ubuntu.com; Wed, 26 Aug 2026 03:49:10 +0000 Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 553103F72E for ; Wed, 26 Aug 2026 03:49:10 +0000 (UTC) Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-845f687dfa2so16275547b3.2 for ; Tue, 25 Aug 2026 20:49:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787716149; x=1788320949; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=vhXYq1pqC96VypRtQmXzqq/nmyBm4K/kmpy+dVzhZl4=; b=D4xk0aqU4ZWRd2fYmcsrkrP55VVzxPIU5PKAHQtJ6iPB3Te3AEOv7NUTrZ1UH9ntaS FgD28TJ/sN53cXBB/QFD4hkOCl3sN0IVl5qpi7BrXJ7a2KNSrxTzdKPB+2j19dIzKSnZ zD5K48RpxnGBfIK38fHNUXp8MxM/n6G0LrRPGzEPg6ho1meLFCj07yOXmu4ABtev0qxo 8zpzVMDac9o+gbTgGp0mW4NY9JMdwDRk4hxFSqDpWR8DMPtSRZpTPSXB7wq6REzlx8Qj HOB8q5BzTLGi8bpIegJ1/VRIJLjoyVw8g9VwWXsf6097dj/cnFYHk6S7Lr3neq2BDOHZ hEfQ== X-Gm-Message-State: AFuF++l54UYonT6qtdBXbS2V9dGww1wDVWgRdjifIacpnfiMCaGQftjR uiUfckeHarQ4UfbTEITLKlxVydZTbc3RxyNUTz2iewmZ5tOAzOdNs2g1HNaU0lDMnzV7ZGUwYOX 8Nj8JNPJvC54/fZFP8siec/ScMWgpjgY2VtNWSwUe9v3/+DO5nE+1RszXNrQtOlz3wYdoW3t2ql VcjOMeFZrfukhuLySJ X-Gm-Gg: AR+sD13VgKIztU7qlcdO+VtCCrZx4uJXO+zQjtzEwE6nRXXauLBV06z7Hkc7zkGkilA E8MJVLrsXlmymNutqr019Jktf7GwdSB46ph5LRHNXZW2uurkoNtj+NJlBe20BBAI33SSntn1sYP N/VKCbYSc+KDO83M4SjBYvSuA0Kj9y8NJzCuKKryvX+VOPr0mN0T1EvMZdnKxpQe+XhV8BHcGpY nQUX99mrm7s2ksuTNShc3IaQSwIM4ks8lftqX4c5vWRng312tf9NYE6J+Sh4vPwFHDWEcFJQ3jy Vkt8wQ21oJbDPS7N2S7up69Dq39KPPN1cfRkk/+O7Wlce7ziNpLQl2riP7hJ0Dsk6lez7Omle0T idMhJsvjcmg== X-Received: by 2002:a05:690c:e68f:10b0:833:968e:c223 with SMTP id 00721157ae682-8573f3ef2fcmr14627387b3.21.1787716149107; Tue, 25 Aug 2026 20:49:09 -0700 (PDT) X-Received: by 2002:a05:690c:e68f:10b0:833:968e:c223 with SMTP id 00721157ae682-8573f3ef2fcmr14627297b3.21.1787716148638; Tue, 25 Aug 2026 20:49:08 -0700 (PDT) Received: from localhost.localdomain ([2001:67c:1560:8007::aac:c1a2]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8570cd697f4sm9679887b3.33.2026.08.25.20.49.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 20:49:08 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][R][PATCH v2 3/5] soundwire: Move wait for initialisation helper to header Date: Wed, 26 Aug 2026 11:48:33 +0800 Message-ID: <20260826034835.661988-4-chris.chiu@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260826034835.661988-1-chris.chiu@canonical.com> References: <20260826034835.661988-1-chris.chiu@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Chris Chiu via kernel-team From: Chris Chiu Reply-To: Chris Chiu Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Charles Keepax BugLink: https://bugs.launchpad.net/bugs/2164967 As SoundWire devices tend to enumerate on the bus after probe, drivers frequently need to wait for the device to initialise from common driver code. The common system is to split drivers into a core module and then a module for each communication bus. These two facts tend to cause Kconfig issues, the issue tends to be when SOUNDWIRE=m and DRIVER_I2C=y, this usually selects DRIVER=y. The driver code then wants to call sdw_slave_wait_for_init(), but this results in calling a module function from built in code. A depends on SOUNDWIRE | !SOUNDWIRE could be added to the end driver but this seems slightly off as it adds a lot of counter intuitive depends. A simpler solution is to make sdw_slave_wait_for_init() a static inline function. As part of doing this add a check for the slave device being NULL acknowledging that this is likely called from code that is shared between control buses. It does require dropping the call to sdw_show_ping_status() but this can be added back in end drivers that used it originally. Currently this is causing rand config issues on RT5682 and will soon also cause similar problems on cs42l43. Acked-by: Vinod Koul Acked-by: Arnd Bergmann Signed-off-by: Charles Keepax Link: https://patch.msgid.link/20260623101814.24044-2-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown (cherry picked from commit 5714c8359f4fc171ab8e0bd0dfc4c61fb36e1db6) Signed-off-by: Chris Chiu --- drivers/soundwire/bus.c | 30 --------------------------- include/linux/soundwire/sdw.h | 38 +++++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 38 deletions(-) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index ea3a24f805c0..e6029a4b6c6f 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -1372,36 +1372,6 @@ int sdw_slave_get_current_bank(struct sdw_slave *slave) } EXPORT_SYMBOL_GPL(sdw_slave_get_current_bank); -/** - * sdw_slave_wait_for_init - Wait for device initialisation - * @slave: Pointer to the SoundWire peripheral. - * @timeout_ms: Timeout in milliseconds. - * - * Wait for a peripheral device to enumerate and be initialised by the - * SoundWire core. - * - * Return: Zero on success, and a negative error code on failure. - */ -int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout_ms) -{ - unsigned long time; - - if (!slave->unattach_request) - return 0; - - time = wait_for_completion_timeout(&slave->initialization_complete, - msecs_to_jiffies(timeout_ms)); - 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) { diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index e2180afa7f98..ef0d983fc492 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -1093,8 +1094,6 @@ 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_ms); - /* messaging and data APIs */ int sdw_read(struct sdw_slave *slave, u32 addr); int sdw_write(struct sdw_slave *slave, u32 addr, u8 value); @@ -1138,12 +1137,6 @@ static inline int sdw_slave_get_current_bank(struct sdw_slave *sdev) return -EINVAL; } -static inline int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout_ms) -{ - WARN_ONCE(1, "SoundWire API is disabled"); - return -EINVAL; -} - /* messaging and data APIs */ static inline int sdw_read(struct sdw_slave *slave, u32 addr) { @@ -1207,4 +1200,33 @@ static inline int sdw_update_no_pm(struct sdw_slave *slave, u32 addr, u8 mask, u #endif /* CONFIG_SOUNDWIRE */ +/** + * sdw_slave_wait_for_init - Wait for device initialisation + * @slave: Pointer to the SoundWire peripheral. + * @timeout_ms: Timeout in milliseconds. + * + * Wait for a peripheral device to enumerate and be initialised by the + * SoundWire core. + * + * Return: Zero on success, and a negative error code on failure. + */ +static inline int sdw_slave_wait_for_init(struct sdw_slave *slave, int timeout_ms) +{ + unsigned long time; + + if (!slave) + return 0; + + time = wait_for_completion_timeout(&slave->initialization_complete, + msecs_to_jiffies(timeout_ms)); + if (!time) { + dev_err(&slave->dev, "Initialization not complete\n"); + return -ETIMEDOUT; + } + + slave->unattach_request = 0; + + return 0; +} + #endif /* __SOUNDWIRE_H */