Skip to content

Commit 8468f79

Browse files
khayash1opsiff
authored andcommitted
spi: sn-f-ospi: Fix division by zero
[ Upstream commit 3588b1c ] 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 <ito.kohei@socionext.com> Signed-off-by: Kohei Ito <ito.kohei@socionext.com> Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> Link: https://patch.msgid.link/20250206085747.3834148-1-hayashi.kunihiko@socionext.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit 9663281)
1 parent cca4d33 commit 8468f79

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

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)