Skip to content

Commit

Permalink
spi: sn-f-ospi: Fix division by zero
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
khayash1 authored and broonie committed Feb 6, 2025
1 parent aff2355 commit 3588b1c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/spi/spi-sn-f-ospi.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ struct f_ospi {

static u32 f_ospi_get_dummy_cycle(const struct spi_mem_op *op)
{
if (!op->dummy.nbytes)
return 0;

return (op->dummy.nbytes * 8) / op->dummy.buswidth;
}

Expand Down

0 comments on commit 3588b1c

Please sign in to comment.