Skip to content

Commit c8e7968

Browse files
Russ Weightbroonie
authored andcommitted
regmap: spi-avmm: Fix regmap_bus max_raw_write
The max_raw_write member of the regmap_spi_avmm_bus structure is defined as: .max_raw_write = SPI_AVMM_VAL_SIZE * MAX_WRITE_CNT SPI_AVMM_VAL_SIZE == 4 and MAX_WRITE_CNT == 1 so this results in a maximum write transfer size of 4 bytes which provides only enough space to transfer the address of the target register. It provides no space for the value to be transferred. This bug became an issue (divide-by-zero in _regmap_raw_write()) after the following was accepted into mainline: commit 3981514 ("regmap: Account for register length when chunking") Change max_raw_write to include space (4 additional bytes) for both the register address and value: .max_raw_write = SPI_AVMM_REG_SIZE + SPI_AVMM_VAL_SIZE * MAX_WRITE_CNT Fixes: 7f9fb67 ("regmap: add Intel SPI Slave to AVMM Bus Bridge support") Reviewed-by: Matthew Gerlach <[email protected]> Signed-off-by: Russ Weight <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 44e4657 commit c8e7968

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/base/regmap/regmap-spi-avmm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ static const struct regmap_bus regmap_spi_avmm_bus = {
660660
.reg_format_endian_default = REGMAP_ENDIAN_NATIVE,
661661
.val_format_endian_default = REGMAP_ENDIAN_NATIVE,
662662
.max_raw_read = SPI_AVMM_VAL_SIZE * MAX_READ_CNT,
663-
.max_raw_write = SPI_AVMM_VAL_SIZE * MAX_WRITE_CNT,
663+
.max_raw_write = SPI_AVMM_REG_SIZE + SPI_AVMM_VAL_SIZE * MAX_WRITE_CNT,
664664
.free_context = spi_avmm_bridge_ctx_free,
665665
};
666666

0 commit comments

Comments
 (0)