Linux SPI subsystem development
 help / color / mirror / Atom feed
* [PATCH] spi: sn-f-ospi: Fix division by zero
@ 2025-02-06  8:27 Kunihiko Hayashi
  2025-02-06  8:36 ` Kunihiko Hayashi
  0 siblings, 1 reply; 2+ messages in thread
From: Kunihiko Hayashi @ 2025-02-06  8:27 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, linux-kernel, Kunihiko Hayashi

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")
Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
---
 drivers/spi/spi-sn-f-ospi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/spi/spi-sn-f-ospi.c b/drivers/spi/spi-sn-f-ospi.c
index adac645732fe..56ef114effc9 100644
--- a/drivers/spi/spi-sn-f-ospi.c
+++ b/drivers/spi/spi-sn-f-ospi.c
@@ -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;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-06  8:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-06  8:27 [PATCH] spi: sn-f-ospi: Fix division by zero Kunihiko Hayashi
2025-02-06  8:36 ` Kunihiko Hayashi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox