]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
spi: sn-f-ospi: Fix division by zero
authorKunihiko Hayashi <hayashi.kunihiko@socionext.com>
Thu, 6 Feb 2025 08:57:47 +0000 (17:57 +0900)
committerMark Brown <broonie@kernel.org>
Thu, 6 Feb 2025 11:33:51 +0000 (11:33 +0000)
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: 1b74dd64c861 ("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>
drivers/spi/spi-sn-f-ospi.c

index 6ad4b729897e3909a5e22b33aa47b812219a6ee5..c4969f66a0ba95fd1bb0002ba3e9ec2dda2e6c3c 100644 (file)
@@ -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;
 }