sound/soc/codecs/wm_adsp_fw_find_test.c
Source file repositories/reference/linux-study-clean/sound/soc/codecs/wm_adsp_fw_find_test.c
File Facts
- System
- Linux kernel
- Corpus path
sound/soc/codecs/wm_adsp_fw_find_test.c- Extension
.c- Size
- 47166 bytes
- Lines
- 1261
- Domain
- Driver Families
- Bucket
- sound/soc
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/device.hkunit/static_stub.hkunit/test.hlinux/slab.hwm_adsp.h
Detected Declarations
struct wm_adsp_fw_find_teststruct wm_adsp_fw_find_test_paramsfunction wm_adsp_fw_find_test_release_firmware_files_stubfunction wm_adsp_free_found_fwfunction wm_adsp_fw_find_test_firmware_request_simple_stubfunction wm_adsp_fw_find_test_pick_filefunction wm_adsp_fw_find_test_firmware_request_stubfunction wm_adsp_fw_find_test_search_orderfunction wm_adsp_fw_find_test_find_firmware_byindexfunction wm_adsp_fw_find_test_case_initfunction wm_adsp_fw_find_test_case_exitfunction wm_adsp_fw_find_test_param_desc
Annotated Snippet
struct wm_adsp_fw_find_test {
struct wm_adsp dsp;
struct wm_adsp_fw_files found_fw;
char searched_fw_files[768];
};
struct wm_adsp_fw_find_test_params {
const char *part;
const char *dsp_name;
const char *fwf_name;
const char *system_name;
const char *alsa_name;
bool wmfw_optional;
bool bin_mandatory;
/* If non-NULL this file should be returned as "found" */
const char *expect_wmfw;
/* If non-NULL this file should be returned as "found" */
const char *expect_bin;
/* Space-separated list of filenames in expected order of searching */
const char *expected_searches;
/* NULL-terminated array of pointers to filenames to simulate directory content */
const char * const *dir_files;
};
/* Dummy struct firmware to return from wm_adsp_request_firmware_files */
static const struct firmware wm_adsp_find_test_dummy_firmware;
static void wm_adsp_fw_find_test_release_firmware_files_stub(struct wm_adsp_fw_files *fw)
{
/*
* fw->wmfw.firmware and fw->coeff.firmware allocated by this KUnit
* test are dummies not allocated by the real request_firmware() call
* so they must not be passed to release_firmware().
* This function replaces wm_adsp_release_firmware_files().
*/
if (!fw)
return;
kfree(fw->wmfw.filename);
kfree(fw->coeff.filename);
fw->wmfw.firmware = NULL;
fw->coeff.firmware = NULL;
fw->wmfw.filename = NULL;
fw->coeff.filename = NULL;
}
static void wm_adsp_free_found_fw(struct kunit *test)
{
struct wm_adsp_fw_find_test *priv = test->priv;
wm_adsp_fw_find_test_release_firmware_files_stub(&priv->found_fw);
}
/* Simple lookup of a filename in a list of names */
static int wm_adsp_fw_find_test_firmware_request_simple_stub(const struct firmware **firmware,
const char *filename,
struct device *dev)
{
struct kunit *test = kunit_get_current_test();
const struct wm_adsp_fw_find_test_params *params = test->param_value;
int i;
/* Non-parameterized test? */
if (!params)
return -ENOENT;
if (!params->dir_files)
return -ENOENT;
for (i = 0; params->dir_files[i]; i++) {
if (strcmp(params->dir_files[i], filename) == 0) {
*firmware = &wm_adsp_find_test_dummy_firmware;
return 0;
}
}
return -ENOENT;
}
static void wm_adsp_fw_find_test_pick_file(struct kunit *test)
{
struct wm_adsp_fw_find_test *priv = test->priv;
const struct wm_adsp_fw_find_test_params *params = test->param_value;
Annotation
- Immediate include surface: `kunit/device.h`, `kunit/static_stub.h`, `kunit/test.h`, `linux/slab.h`, `wm_adsp.h`.
- Detected declarations: `struct wm_adsp_fw_find_test`, `struct wm_adsp_fw_find_test_params`, `function wm_adsp_fw_find_test_release_firmware_files_stub`, `function wm_adsp_free_found_fw`, `function wm_adsp_fw_find_test_firmware_request_simple_stub`, `function wm_adsp_fw_find_test_pick_file`, `function wm_adsp_fw_find_test_firmware_request_stub`, `function wm_adsp_fw_find_test_search_order`, `function wm_adsp_fw_find_test_find_firmware_byindex`, `function wm_adsp_fw_find_test_case_init`.
- Atlas domain: Driver Families / sound/soc.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.