[PATCH 1/4] ASoC: cs35l56: KUnit tests for setting dsp.system_name

From: Richard Fitzgerald

Date: Wed Mar 04 2026 - 11:31:49 EST


Add KUnit tests for setting the dsp.system_name string.

There are two sources of the string:

1. PCI SSID from struct snd_soc_card.
2. "cirrus,firmware-uid" property.

Either of these can then be qualified by a speaker ID integer.

Signed-off-by: Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx>
---
sound/soc/codecs/cs35l56-test.c | 80 +++++++++++++++++++++++++++++++++
sound/soc/codecs/cs35l56.c | 3 +-
sound/soc/codecs/cs35l56.h | 1 +
3 files changed, 83 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/cs35l56-test.c b/sound/soc/codecs/cs35l56-test.c
index decedf76847d..ac3f34bf8adc 100644
--- a/sound/soc/codecs/cs35l56-test.c
+++ b/sound/soc/codecs/cs35l56-test.c
@@ -74,6 +74,78 @@ static const char *cs35l56_test_devm_get_vendor_specific_variant_id_none(struct
return ERR_PTR(-ENOENT);
}

+static void cs35l56_test_system_name_from_ssid(struct kunit *test)
+{
+ struct cs35l56_test_priv *priv = test->priv;
+ struct cs35l56_private *cs35l56 = priv->cs35l56_priv;
+
+ cs35l56->speaker_id = -1;
+ snd_soc_card_set_pci_ssid(cs35l56->component->card, 0x12b4, 0xa7c8);
+
+ KUNIT_EXPECT_EQ(test, cs35l56_get_firmware_uid(cs35l56), 0);
+ KUNIT_EXPECT_EQ(test, cs35l56_set_fw_name(cs35l56->component), 0);
+ KUNIT_EXPECT_STREQ(test, cs35l56->dsp.system_name, "12b4a7c8");
+}
+
+static void cs35l56_test_system_name_from_ssid_and_spkid(struct kunit *test)
+{
+ struct cs35l56_test_priv *priv = test->priv;
+ struct cs35l56_private *cs35l56 = priv->cs35l56_priv;
+
+ cs35l56->speaker_id = 1;
+ snd_soc_card_set_pci_ssid(cs35l56->component->card, 0x12b4, 0xa7c8);
+
+ KUNIT_EXPECT_EQ(test, cs35l56_get_firmware_uid(cs35l56), 0);
+ KUNIT_EXPECT_EQ(test, cs35l56_set_fw_name(cs35l56->component), 0);
+ KUNIT_EXPECT_STREQ(test, cs35l56->dsp.system_name, "12b4a7c8-spkid1");
+}
+
+static void cs35l56_test_system_name_from_property(struct kunit *test)
+{
+ struct cs35l56_test_priv *priv = test->priv;
+ struct cs35l56_private *cs35l56 = priv->cs35l56_priv;
+ const struct property_entry dev_props[] = {
+ PROPERTY_ENTRY_STRING("cirrus,firmware-uid", "acme"),
+ { }
+ };
+ const struct software_node dev_node = SOFTWARE_NODE("SPK1", dev_props, NULL);
+
+ cs35l56->speaker_id = -1;
+
+ KUNIT_ASSERT_EQ(test, device_add_software_node(cs35l56->base.dev, &dev_node), 0);
+ KUNIT_ASSERT_EQ(test, 0,
+ kunit_add_action_or_reset(test,
+ device_remove_software_node_wrapper,
+ cs35l56->base.dev));
+
+ KUNIT_EXPECT_EQ(test, cs35l56_get_firmware_uid(cs35l56), 0);
+ KUNIT_EXPECT_EQ(test, cs35l56_set_fw_name(cs35l56->component), 0);
+ KUNIT_EXPECT_STREQ(test, cs35l56->dsp.system_name, "acme");
+}
+
+static void cs35l56_test_system_name_from_property_and_spkid(struct kunit *test)
+{
+ struct cs35l56_test_priv *priv = test->priv;
+ struct cs35l56_private *cs35l56 = priv->cs35l56_priv;
+ const struct property_entry dev_props[] = {
+ PROPERTY_ENTRY_STRING("cirrus,firmware-uid", "acme"),
+ { }
+ };
+ const struct software_node dev_node = SOFTWARE_NODE("SPK1", dev_props, NULL);
+
+ cs35l56->speaker_id = 1;
+
+ KUNIT_ASSERT_EQ(test, device_add_software_node(cs35l56->base.dev, &dev_node), 0);
+ KUNIT_ASSERT_EQ(test, 0,
+ kunit_add_action_or_reset(test,
+ device_remove_software_node_wrapper,
+ cs35l56->base.dev));
+
+ KUNIT_EXPECT_EQ(test, cs35l56_get_firmware_uid(cs35l56), 0);
+ KUNIT_EXPECT_EQ(test, cs35l56_set_fw_name(cs35l56->component), 0);
+ KUNIT_EXPECT_STREQ(test, cs35l56->dsp.system_name, "acme-spkid1");
+}
+
static void cs35l56_test_l56_b0_suffix_sdw(struct kunit *test)
{
struct cs35l56_test_priv *priv = test->priv;
@@ -596,6 +668,10 @@ KUNIT_ARRAY_PARAM(cs35l56_test_type_rev_all, cs35l56_test_type_rev_all_param_cas
cs35l56_test_type_rev_param_desc);

static struct kunit_case cs35l56_test_cases_soundwire[] = {
+ KUNIT_CASE(cs35l56_test_system_name_from_ssid),
+ KUNIT_CASE(cs35l56_test_system_name_from_ssid_and_spkid),
+ KUNIT_CASE(cs35l56_test_system_name_from_property),
+ KUNIT_CASE(cs35l56_test_system_name_from_property_and_spkid),
KUNIT_CASE(cs35l56_test_l56_b0_suffix_sdw),
KUNIT_CASE_PARAM(cs35l56_test_suffix_sdw, cs35l56_test_type_rev_ex_b0_gen_params),
KUNIT_CASE_PARAM(cs35l56_test_ssidexv2_suffix_sdw,
@@ -613,6 +689,10 @@ static struct kunit_case cs35l56_test_cases_soundwire[] = {
};

static struct kunit_case cs35l56_test_cases_not_soundwire[] = {
+ KUNIT_CASE(cs35l56_test_system_name_from_ssid),
+ KUNIT_CASE(cs35l56_test_system_name_from_ssid_and_spkid),
+ KUNIT_CASE(cs35l56_test_system_name_from_property),
+ KUNIT_CASE(cs35l56_test_system_name_from_property_and_spkid),
KUNIT_CASE_PARAM(cs35l56_test_suffix_i2cspi, cs35l56_test_type_rev_all_gen_params),
KUNIT_CASE_PARAM(cs35l56_test_ssidexv2_suffix_i2cspi,
cs35l56_test_type_rev_all_gen_params),
diff --git a/sound/soc/codecs/cs35l56.c b/sound/soc/codecs/cs35l56.c
index 37909a319f88..9d35797e000a 100644
--- a/sound/soc/codecs/cs35l56.c
+++ b/sound/soc/codecs/cs35l56.c
@@ -1669,7 +1669,7 @@ VISIBLE_IF_KUNIT int cs35l56_process_xu_properties(struct cs35l56_private *cs35l
}
EXPORT_SYMBOL_IF_KUNIT(cs35l56_process_xu_properties);

-static int cs35l56_get_firmware_uid(struct cs35l56_private *cs35l56)
+VISIBLE_IF_KUNIT int cs35l56_get_firmware_uid(struct cs35l56_private *cs35l56)
{
struct device *dev = cs35l56->base.dev;
const char *prop;
@@ -1694,6 +1694,7 @@ static int cs35l56_get_firmware_uid(struct cs35l56_private *cs35l56)

return 0;
}
+EXPORT_SYMBOL_IF_KUNIT(cs35l56_get_firmware_uid);

/*
* Some SoundWire laptops have a spk-id-gpios property but it points to
diff --git a/sound/soc/codecs/cs35l56.h b/sound/soc/codecs/cs35l56.h
index 691f857d0bd8..747529be3e2e 100644
--- a/sound/soc/codecs/cs35l56.h
+++ b/sound/soc/codecs/cs35l56.h
@@ -78,6 +78,7 @@ void cs35l56_remove(struct cs35l56_private *cs35l56);
int cs35l56_set_fw_suffix(struct cs35l56_private *cs35l56);
int cs35l56_set_fw_name(struct snd_soc_component *component);
int cs35l56_process_xu_properties(struct cs35l56_private *cs35l56);
+int cs35l56_get_firmware_uid(struct cs35l56_private *cs35l56);
#endif

#endif /* ifndef CS35L56_H */
--
2.47.3