Skip to content

Commit 3588b1c

Browse files
khayash1broonie
authored andcommitted
spi: sn-f-ospi: Fix division by zero
When there is no dummy cycle in the spi-nor commands, both dummy bus cycle bytes and width are zero. Because of the cpu's warning when divided by zero, the warning should be avoided. Return just zero to avoid such calculations. Fixes: 1b74dd6 ("spi: Add Socionext F_OSPI SPI flash controller driver") Co-developed-by: Kohei Ito <[email protected]> Signed-off-by: Kohei Ito <[email protected]> Signed-off-by: Kunihiko Hayashi <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent aff2355 commit 3588b1c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/spi/spi-sn-f-ospi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ struct f_ospi {
116116

117117
static u32 f_ospi_get_dummy_cycle(const struct spi_mem_op *op)
118118
{
119+
if (!op->dummy.nbytes)
120+
return 0;
121+
119122
return (op->dummy.nbytes * 8) / op->dummy.buswidth;
120123
}
121124

0 commit comments

Comments
 (0)