]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: cs35l56-shared-test: Subtract reg_base offset in dummy regmap
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Tue, 19 May 2026 13:54:33 +0000 (14:54 +0100)
committerMark Brown <broonie@kernel.org>
Tue, 19 May 2026 13:59:52 +0000 (14:59 +0100)
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@opensource.cirrus.com>
Link: https://patch.msgid.link/20260519135435.479949-2-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/cs35l56-shared-test.c

index cfe7938065f90e27371a2c0e08bcf8a1325a4096..8060a275d32bd48e4e46fad52a3fc6b71dfa6e74 100644 (file)
@@ -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);
@@ -657,6 +662,7 @@ static int cs35l56_shared_test_case_base_init(struct kunit *test, u8 type, u8 re
 
        test->priv = priv;
        priv->test = test;
+       priv->reg_offset = regmap_config->reg_base;
 
        /* Create dummy amp driver dev */
        priv->amp_dev = faux_device_create("cs35l56_shared_test_drv", NULL, NULL);