ASoC: cs42xx8: fix regmap SPI flag masks to target high byte
Subsystems (3)
PATCH 1/1 ASoC: cs42xx8: fix regmap SPI flag masks to target high byte
From: Surendra Singh Chouhan <[email protected]>
cs42xx8_spi_probe() configures reg_bits=16 so regmap sends a 2-byte address field over SPI big-endian. The SPI frame format requires the chip address byte (0x9E for write, 0x9F for read) to be in the high byte of the 16-bit address field and the register address in the low byte:
write: [0x9E, MAP_addr, data]
read: [0x9F, MAP_addr] -> [data]
However, write_flag_mask was set to 0x9E and read_flag_mask to 0x9F. Because 0x9E is a 16-bit value of 0x009E, regmap OR'd 0x9E into the low byte (bits 7..0) of the address instead of the high byte (bits 15..8), corrupting the register address on the wire.
Fix this by setting write_flag_mask to 0x9E00 and read_flag_mask to 0x9F00.
--- sound/soc/codecs/cs42xx8-spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/cs42xx8-spi.c +2 -2
@@ -52,8 +52,8 @@ static int cs42xx8_spi_probe(struct spi_device *spi)* write_flag_mask/read_flag_mask are OR'd into that address field: */ config.reg_bits =16 ; - config.write_flag_mask =0x9E ; - config.read_flag_mask =0x9F ; + config.write_flag_mask =0x9E00 ; + config.read_flag_mask =0x9F00 ; ret =cs42xx8_probe (&spi->dev,devm_regmap_init_spi (spi, &config), drvdata);
Signature · 1 line
2.55.0
Mark Brown
maintainersound/soc/codecs/cs42xx8-spi.c static int cs42xx8_spi_probe(struct spi_device *spi) · line 56
Quoted 5 lines · On Fri, Jul 24, 2026 at 06:31:28PM +0530, [email protected] wrote:
sound/soc/codecs/cs42xx8-spi.c +2
-2config.reg_bits =16 ; - config.write_flag_mask =0x9E ; - config.read_flag_mask =0x9F ; + config.write_flag_mask =0x9E00 ; + config.read_flag_mask =0x9F00 ;
Have you tested this or did you do this purely by inspection? I'm a bit concerned about how well the regmap core deals with the endianness issues for multi-byte masks here.