Skip to content

Commit 0e85ee8

Browse files
yoikedabroonie
authored andcommitted
spi: spi-cadence-quadspi: Fix division by zero warning
Fix below division by zero warning: - The reason for dividing by zero is because the dummy bus width is zero, but if the dummy n bytes is zero, it indicates that there is no data transfer, so we can just return zero without doing any calculations. [ 0.795337] Division by zero in kernel. : [ 0.834051] [<807fd40c>] (__div0) from [<804e1acc>] (Ldiv0+0x8/0x10) [ 0.839097] [<805f0710>] (cqspi_exec_mem_op) from [<805edb4c>] (spi_mem_exec_op+0x3b0/0x3f8) Fixes: 7512eaf ("spi: cadence-quadspi: Fix dummy cycle calculation when buswidth > 1") Signed-off-by: Yoshitaka Ikeda <[email protected]> Reviewed-by: Pratyush Yadav <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 0ccfd1b commit 0e85ee8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/spi/spi-cadence-quadspi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@ static unsigned int cqspi_calc_dummy(const struct spi_mem_op *op, bool dtr)
309309
{
310310
unsigned int dummy_clk;
311311

312+
if (!op->dummy.nbytes)
313+
return 0;
314+
312315
dummy_clk = op->dummy.nbytes * (8 / op->dummy.buswidth);
313316
if (dtr)
314317
dummy_clk /= 2;

0 commit comments

Comments
 (0)