Skip to content

Commit 30554a1

Browse files
legoaterbroonie
authored andcommitted
spi: aspeed: Fix division by zero
When using the normal read operation for data transfers, the dummy bus width is zero. In that case, they are no dummy bytes to transfer and setting the dummy field in the controller register becomes useless. Issue was found on a custom "Bifrost" board based on the AST2500 SoC and using a MX25L51245GMI-08G SPI Flash. Reported-by: Ian Woloschin <ian.woloschin@akamai.com> Reviewed-by: Pratyush Yadav <p.yadav@ti.com> Tested-by: Ian Woloschin <iwolosch@akamai.com> Fixes: 9da06d7 ("spi: aspeed: Add support for direct mapping") Signed-off-by: Cédric Le Goater <clg@kaod.org> Link: https://lore.kernel.org/r/20220622161617.3719096-3-clg@kaod.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 8988ba7 commit 30554a1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/spi/spi-aspeed-smc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,9 +582,11 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
582582
ctl_val = readl(chip->ctl) & ~CTRL_IO_CMD_MASK;
583583
ctl_val |= aspeed_spi_get_io_mode(op) |
584584
op->cmd.opcode << CTRL_COMMAND_SHIFT |
585-
CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth) |
586585
CTRL_IO_MODE_READ;
587586

587+
if (op->dummy.nbytes)
588+
ctl_val |= CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth);
589+
588590
/* Tune 4BYTE address mode */
589591
if (op->addr.nbytes) {
590592
u32 addr_mode = readl(aspi->regs + CE_CTRL_REG);

0 commit comments

Comments
 (0)