[PATCH v4 1/3] ASoC: cs35l56-shared-test: Subtract reg_base offset in dummy regmap
From: Richard Fitzgerald
Date: Thu May 21 2026 - 08:00:13 EST
Subtract the value of cs35l56 regmap_config->reg_base from addresses
passed into the mock regmap bus.
Chip register addresses transferred over SoundWire are offset by 0x8000
to move them after the address range reserved in the SoundWire spec.
This commit prepares for changing the cs35l56-sdw driver to use
regmap_config->reg_base to add this offset. When that is done the
addresses passed into the mock regmap_bus will include this offset.
Signed-off-by: Richard Fitzgerald <rf@xxxxxxxxxxxxxxxxxxxxx>
---
Changes in V4:
- Move the dereference of regmap_config->reg_base inside the check that
regmap_config is not NULL.
(Reported by Dan Carpenter <error27@xxxxxxxxx>)
New in V3
sound/soc/codecs/cs35l56-shared-test.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/sound/soc/codecs/cs35l56-shared-test.c b/sound/soc/codecs/cs35l56-shared-test.c
index cfe7938065f9..4f52c8a192e5 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;
+ unsigned int reg_offset;
struct cs35l56_base *cs35l56_base;
u8 applied_pad_pull_state[CS35L56_MAX_GPIO];
};
@@ -194,6 +195,8 @@ static int cs35l56_shared_test_reg_read(void *context, unsigned int reg, unsigne
{
struct cs35l56_shared_test_priv *priv = context;
+ reg -= priv->reg_offset;
+
switch (reg) {
case CS35L56_SYNC_GPIO1_CFG ... CS35L56_ASP2_DIO_GPIO13_CFG:
case CS35L56_GPIO1_CTRL1 ... CS35L56_GPIO13_CTRL1:
@@ -214,6 +217,8 @@ static int cs35l56_shared_test_reg_write(void *context, unsigned int reg, unsign
{
struct cs35l56_shared_test_priv *priv = context;
+ reg -= priv->reg_offset;
+
switch (reg) {
case CS35L56_UPDATE_REGS:
return cs35l56_shared_test_updt_gpio_pres(priv, reg, val);
@@ -673,6 +678,7 @@ static int cs35l56_shared_test_case_base_init(struct kunit *test, u8 type, u8 re
priv->cs35l56_base->rev = rev;
if (regmap_config) {
+ priv->reg_offset = regmap_config->reg_base;
ret = cs35l56_shared_test_case_regmap_init(test, regmap_config);
if (ret)
return ret;
--
2.47.3