* [PATCH] ASoC: cs35l56: Add KUnit tests for regmap defaults table
@ 2026-09-15 10:31 Richard Fitzgerald
2026-09-15 14:48 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Richard Fitzgerald @ 2026-09-15 10:31 UTC (permalink / raw)
To: broonie; +Cc: linux-sound, linux-kernel, patches
Add test cases to cs35l56-shared-test to sanity-check the regmap defaults
table:
- Table is sorted in order of increasing address (which also means there
cannot be duplicate entries).
- Volatile registers don't have a default.
- Defaulted registers are readable.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
sound/soc/codecs/cs35l56-shared-test.c | 56 ++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/sound/soc/codecs/cs35l56-shared-test.c b/sound/soc/codecs/cs35l56-shared-test.c
index 4f52c8a192e55..34bb3d44b51f1 100644
--- a/sound/soc/codecs/cs35l56-shared-test.c
+++ b/sound/soc/codecs/cs35l56-shared-test.c
@@ -29,6 +29,7 @@ struct cs35l56_shared_test_priv {
struct faux_device *gpio_dev;
struct cs35l56_shared_test_mock_gpio *gpio_priv;
struct regmap *registers;
+ const struct regmap_config *regmap_config;
unsigned int reg_offset;
struct cs35l56_base *cs35l56_base;
u8 applied_pad_pull_state[CS35L56_MAX_GPIO];
@@ -614,6 +615,55 @@ static void cs35l56_shared_test_get_speaker_id_from_host_gpio(struct kunit *test
KUNIT_EXPECT_EQ(test, cs35l56_get_speaker_id(priv->cs35l56_base), param->spkid);
}
+static void cs35l56_shared_test_sorted_regmap_defaults(struct kunit *test)
+{
+ struct cs35l56_shared_test_priv *priv = test->priv;
+ const struct reg_default *defaults;
+ int i;
+
+ KUNIT_ASSERT_NOT_NULL(test, priv->regmap_config);
+ defaults = priv->regmap_config->reg_defaults;
+ KUNIT_ASSERT_NOT_NULL(test, defaults);
+ KUNIT_ASSERT_NE(test, priv->regmap_config->num_reg_defaults, 0);
+
+ for (i = 1; i < priv->regmap_config->num_reg_defaults; i++)
+ KUNIT_EXPECT_LT(test, defaults[i - 1].reg, defaults[i].reg);
+}
+
+static void cs35l56_shared_test_regmap_defaults_not_volatile(struct kunit *test)
+{
+ struct cs35l56_shared_test_priv *priv = test->priv;
+ struct cs35l56_base *cs35l56_base = priv->cs35l56_base;
+ const struct regmap_config *config = priv->regmap_config;
+ int i;
+
+ KUNIT_ASSERT_NOT_NULL(test, config);
+ KUNIT_ASSERT_NOT_NULL(test, config->volatile_reg);
+
+ for (i = 0; i < config->num_reg_defaults; i++) {
+ KUNIT_EXPECT_FALSE(test,
+ config->volatile_reg(cs35l56_base->dev,
+ config->reg_defaults[i].reg));
+ }
+}
+
+static void cs35l56_shared_test_regmap_defaults_readable(struct kunit *test)
+{
+ struct cs35l56_shared_test_priv *priv = test->priv;
+ struct cs35l56_base *cs35l56_base = priv->cs35l56_base;
+ const struct regmap_config *config = priv->regmap_config;
+ int i;
+
+ KUNIT_ASSERT_NOT_NULL(test, config);
+ KUNIT_ASSERT_NOT_NULL(test, config->readable_reg);
+
+ for (i = 0; i < config->num_reg_defaults; i++) {
+ KUNIT_EXPECT_TRUE(test,
+ config->readable_reg(cs35l56_base->dev,
+ config->reg_defaults[i].reg));
+ }
+}
+
static int cs35l56_shared_test_case_regmap_init(struct kunit *test,
const struct regmap_config *regmap_config)
{
@@ -645,6 +695,8 @@ static int cs35l56_shared_test_case_regmap_init(struct kunit *test,
kunit_add_action_or_reset(test, regmap_exit_wrapper,
cs35l56_base->regmap));
+ priv->regmap_config = regmap_config;
+
return 0;
}
@@ -862,6 +914,10 @@ static struct kunit_case cs35l56_shared_test_cases[] = {
cs35l56_shared_test_host_gpio_spkid_gen_params,
{ KUNIT_SPEED_SLOW }),
+ KUNIT_CASE(cs35l56_shared_test_sorted_regmap_defaults),
+ KUNIT_CASE(cs35l56_shared_test_regmap_defaults_not_volatile),
+ KUNIT_CASE(cs35l56_shared_test_regmap_defaults_readable),
+
{ }
};
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] ASoC: cs35l56: Add KUnit tests for regmap defaults table
2026-09-15 10:31 [PATCH] ASoC: cs35l56: Add KUnit tests for regmap defaults table Richard Fitzgerald
@ 2026-09-15 14:48 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2026-09-15 14:48 UTC (permalink / raw)
To: Richard Fitzgerald; +Cc: linux-sound, linux-kernel, patches
On Tue, 15 Sep 2026 11:31:21 +0100, Richard Fitzgerald wrote:
> ASoC: cs35l56: Add KUnit tests for regmap defaults table
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.4
Thanks!
[1/1] ASoC: cs35l56: Add KUnit tests for regmap defaults table
https://git.kernel.org/broonie/sound/c/f4c49ebff706
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-15 17:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15 10:31 [PATCH] ASoC: cs35l56: Add KUnit tests for regmap defaults table Richard Fitzgerald
2026-09-15 14:48 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®