From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: broonie@kernel.org
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@opensource.cirrus.com
Subject: [PATCH 02/10] ASoC: wm_adsp: Add KUnit redirection stubs for firmware file search
Date: Tue, 10 Mar 2026 14:18:09 +0000 [thread overview]
Message-ID: <20260310141817.1871794-3-rf@opensource.cirrus.com> (raw)
In-Reply-To: <20260310141817.1871794-1-rf@opensource.cirrus.com>
Make some of the firmware file search functions redirectable for KUnit
testing.
- The call to firmware_request_nowarn() is factored out into a wrapper
function so that it can be redirected.
- wm_adsp_request_firmware_files() and wm_adsp_release_firmware_files()
are made visible and exported if KUNIT is enabled.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
sound/soc/codecs/wm_adsp.c | 38 ++++++++++++++++++++++++++++----------
sound/soc/codecs/wm_adsp.h | 15 +++++++++++++++
2 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 4b0c53d4f524..68e00970b8a2 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -7,6 +7,8 @@
* Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
*/
+#include <kunit/static_stub.h>
+#include <kunit/visibility.h>
#include <linux/array_size.h>
#include <linux/cleanup.h>
#include <linux/ctype.h>
@@ -704,17 +706,32 @@ int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name, int type,
}
EXPORT_SYMBOL_GPL(wm_adsp_read_ctl);
-static void wm_adsp_release_firmware_files(const struct firmware *wmfw_firmware,
- char *wmfw_filename,
- const struct firmware *coeff_firmware,
- char *coeff_filename)
+VISIBLE_IF_KUNIT void wm_adsp_release_firmware_files(const struct firmware *wmfw_firmware,
+ char *wmfw_filename,
+ const struct firmware *coeff_firmware,
+ char *coeff_filename)
{
+ KUNIT_STATIC_STUB_REDIRECT(wm_adsp_release_firmware_files,
+ wmfw_firmware, wmfw_filename,
+ coeff_firmware, coeff_filename);
+
release_firmware(wmfw_firmware);
kfree(wmfw_filename);
release_firmware(coeff_firmware);
kfree(coeff_filename);
}
+EXPORT_SYMBOL_IF_KUNIT(wm_adsp_release_firmware_files);
+
+VISIBLE_IF_KUNIT int wm_adsp_firmware_request(const struct firmware **firmware,
+ const char *filename,
+ struct device *dev)
+{
+ KUNIT_STATIC_STUB_REDIRECT(wm_adsp_firmware_request, firmware, filename, dev);
+
+ return firmware_request_nowarn(firmware, filename, dev);
+}
+EXPORT_SYMBOL_IF_KUNIT(wm_adsp_firmware_request);
static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
const struct firmware **firmware, char **filename,
@@ -762,7 +779,7 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
s++;
}
- ret = firmware_request_nowarn(firmware, *filename, cs_dsp->dev);
+ ret = wm_adsp_firmware_request(firmware, *filename, cs_dsp->dev);
if (ret != 0) {
adsp_dbg(dsp, "Failed to request '%s'\n", *filename);
kfree(*filename);
@@ -775,11 +792,11 @@ static int wm_adsp_request_firmware_file(struct wm_adsp *dsp,
}
static const char * const cirrus_dir = "cirrus/";
-static int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
- const struct firmware **wmfw_firmware,
- char **wmfw_filename,
- const struct firmware **coeff_firmware,
- char **coeff_filename)
+VISIBLE_IF_KUNIT int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
+ const struct firmware **wmfw_firmware,
+ char **wmfw_filename,
+ const struct firmware **coeff_firmware,
+ char **coeff_filename)
{
const char *system_name = dsp->system_name;
const char *suffix = dsp->component->name_prefix;
@@ -856,6 +873,7 @@ static int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
return -ENOENT;
}
+EXPORT_SYMBOL_IF_KUNIT(wm_adsp_request_firmware_files);
static int wm_adsp_common_init(struct wm_adsp *dsp)
{
diff --git a/sound/soc/codecs/wm_adsp.h b/sound/soc/codecs/wm_adsp.h
index a9118be793d7..599be409b669 100644
--- a/sound/soc/codecs/wm_adsp.h
+++ b/sound/soc/codecs/wm_adsp.h
@@ -143,4 +143,19 @@ int wm_adsp_write_ctl(struct wm_adsp *dsp, const char *name, int type,
int wm_adsp_read_ctl(struct wm_adsp *dsp, const char *name, int type,
unsigned int alg, void *buf, size_t len);
+#if IS_ENABLED(CONFIG_KUNIT)
+void wm_adsp_release_firmware_files(const struct firmware *wmfw_firmware,
+ char *wmfw_filename,
+ const struct firmware *coeff_firmware,
+ char *coeff_filename);
+int wm_adsp_firmware_request(const struct firmware **firmware,
+ const char *filename,
+ struct device *dev);
+int wm_adsp_request_firmware_files(struct wm_adsp *dsp,
+ const struct firmware **wmfw_firmware,
+ char **wmfw_filename,
+ const struct firmware **coeff_firmware,
+ char **coeff_filename);
+#endif
+
#endif
--
2.47.3
next prev parent reply other threads:[~2026-03-10 14:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 14:18 [PATCH 00/10] ASoC: wm_adsp: Some improvements to firmware file search Richard Fitzgerald
2026-03-10 14:18 ` [PATCH 01/10] ASoC: wm_adsp: Remove unused argument to wm_adsp_release_firmware_files() Richard Fitzgerald
2026-03-10 14:18 ` Richard Fitzgerald [this message]
2026-03-10 14:18 ` [PATCH 03/10] ASoC: wm_adsp: Export function for KUnit test to get firmware filenames Richard Fitzgerald
2026-03-10 14:18 ` [PATCH 04/10] ASoC: wm_adsp: Add kunit test for firmware file search Richard Fitzgerald
2026-03-10 14:18 ` [PATCH 05/10] ASoC: wm_adsp: Remove duplicated code to find firmware file Richard Fitzgerald
2026-03-10 14:18 ` [PATCH 06/10] ASoC: wm_adsp: Use consistent error checks in wm_adsp_request_firmware_files() Richard Fitzgerald
2026-03-10 14:18 ` [PATCH 07/10] ASoC: wm_adsp: Convert '/' to '-' when normalizing firmware filenames Richard Fitzgerald
2026-03-10 14:18 ` [PATCH 08/10] ASoC: wm_adsp: Add KUnit test cases for '/' in " Richard Fitzgerald
2026-03-10 14:18 ` [PATCH 09/10] ASoC: wm_adsp: Use a struct to pass around firmware struct and filename Richard Fitzgerald
2026-03-10 14:18 ` [PATCH 10/10] ASoC: wm_adsp: Combine some similar code in firmware file search Richard Fitzgerald
2026-03-12 17:34 ` [PATCH 00/10] ASoC: wm_adsp: Some improvements to " Mark Brown
2026-03-13 14:58 ` Mark Brown
2026-03-17 15:37 ` Mark Brown
2026-03-17 15:52 ` Charles Keepax
2026-03-17 17:47 ` Charles Keepax
2026-03-17 18:11 ` Mark Brown
2026-03-18 9:31 ` Charles Keepax
2026-03-18 10:27 ` Charles Keepax
2026-03-18 11:15 ` Mark Brown
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=20260310141817.1871794-3-rf@opensource.cirrus.com \
--to=rf@opensource.cirrus.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
/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