Unverified Commit 3588b1c0 authored by Kunihiko Hayashi's avatar Kunihiko Hayashi Committed by Mark Brown
Browse files

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: 1b74dd64 ("spi: Add Socionext F_OSPI SPI flash controller driver")
Co-developed-by: default avatarKohei Ito <ito.kohei@socionext.com>
Signed-off-by: default avatarKohei Ito <ito.kohei@socionext.com>
Signed-off-by: default avatarKunihiko Hayashi <hayashi.kunihiko@socionext.com>
Link: https://patch.msgid.link/20250206085747.3834148-1-hayashi.kunihiko@socionext.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent aff2355d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;
}