diff mbox series

[RESEND,v1] spi: sn-f-ospi: Fix division by zero

Message ID 20250206085747.3834148-1-hayashi.kunihiko@socionext.com
State Superseded
Headers show
Series [RESEND,v1] spi: sn-f-ospi: Fix division by zero | expand

Commit Message

Kunihiko Hayashi Feb. 6, 2025, 8:57 a.m. UTC
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>
---
 drivers/spi/spi-sn-f-ospi.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Mark Brown Feb. 6, 2025, 2:39 p.m. UTC | #1
On Thu, 06 Feb 2025 17:57:47 +0900, Kunihiko Hayashi wrote:
> 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.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: sn-f-ospi: Fix division by zero
      commit: 3588b1c0fde2f58d166e3f94a5a58d64b893526c

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

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;
 }