All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/2] spi: spi-cadence-quadspi: Fix division by zero warning
@ 2021-07-16 14:31 Yoshitaka Ikeda
  2021-07-16 14:33 ` [PATCH v5 1/2] spi: spi-cadence-quadspi: Revert "Fix division by zero warning" Yoshitaka Ikeda
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yoshitaka Ikeda @ 2021-07-16 14:31 UTC (permalink / raw)
  To: Mark Brown
  Cc: Yoshitaka Ikeda, Philipp Zabel, Pratyush Yadav, linux-spi,
	Masahiro Mizutani, Ken Kurematsu

v5:
- Added Signed-off-by and Reviewed-by.

v4:
- Changed to better code.

v3:
- repost.

v2:
- Fix commit message.

Yoshitaka Ikeda (2):
  spi: spi-cadence-quadspi: Revert "Fix division by zero warning"
  spi: spi-cadence-quadspi: Fix division by zero warning

 drivers/spi/spi-cadence-quadspi.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)


base-commit: f77d261b522e1202ef1a0925b8ebe0d73ae79e1e
-- 
2.32.0

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

* [PATCH v5 1/2] spi: spi-cadence-quadspi: Revert "Fix division by zero warning"
  2021-07-16 14:31 [PATCH v5 0/2] spi: spi-cadence-quadspi: Fix division by zero warning Yoshitaka Ikeda
@ 2021-07-16 14:33 ` Yoshitaka Ikeda
  2021-07-16 14:35 ` [PATCH v5 2/2] spi: spi-cadence-quadspi: Fix division by zero warning Yoshitaka Ikeda
  2021-07-16 17:32 ` [PATCH v5 0/2] " Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Yoshitaka Ikeda @ 2021-07-16 14:33 UTC (permalink / raw)
  To: Mark Brown
  Cc: Yoshitaka Ikeda, Philipp Zabel, Pratyush Yadav, linux-spi,
	Masahiro Mizutani, Ken Kurematsu

Revert to change to a better code.

This reverts commit 55cef88bbf12f3bfbe5c2379a8868a034707e755.

Signed-off-by: Yoshitaka Ikeda <ikeda@nskint.co.jp>
---
 drivers/spi/spi-cadence-quadspi.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index 13d1f0ce618e..7a00346ff9b9 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -307,13 +307,11 @@ static unsigned int cqspi_calc_rdreg(struct cqspi_flash_pdata *f_pdata)
 
 static unsigned int cqspi_calc_dummy(const struct spi_mem_op *op, bool dtr)
 {
-	unsigned int dummy_clk = 0;
+	unsigned int dummy_clk;
 
-	if (op->dummy.buswidth && op->dummy.nbytes) {
-		dummy_clk = op->dummy.nbytes * (8 / op->dummy.buswidth);
-		if (dtr)
-			dummy_clk /= 2;
-	}
+	dummy_clk = op->dummy.nbytes * (8 / op->dummy.buswidth);
+	if (dtr)
+		dummy_clk /= 2;
 
 	return dummy_clk;
 }
-- 
2.32.0

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

* [PATCH v5 2/2] spi: spi-cadence-quadspi: Fix division by zero warning
  2021-07-16 14:31 [PATCH v5 0/2] spi: spi-cadence-quadspi: Fix division by zero warning Yoshitaka Ikeda
  2021-07-16 14:33 ` [PATCH v5 1/2] spi: spi-cadence-quadspi: Revert "Fix division by zero warning" Yoshitaka Ikeda
@ 2021-07-16 14:35 ` Yoshitaka Ikeda
  2021-07-16 17:32 ` [PATCH v5 0/2] " Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Yoshitaka Ikeda @ 2021-07-16 14:35 UTC (permalink / raw)
  To: Mark Brown
  Cc: Yoshitaka Ikeda, Philipp Zabel, Pratyush Yadav, linux-spi,
	Masahiro Mizutani, Ken Kurematsu

Fix below division by zero warning:
- The reason for dividing by zero is because the dummy bus width is zero,
  but if the dummy n bytes is zero, it indicates that there is no data transfer,
  so we can just return zero without doing any calculations.

[    0.795337] Division by zero in kernel.
   :
[    0.834051] [<807fd40c>] (__div0) from [<804e1acc>] (Ldiv0+0x8/0x10)
[    0.839097] [<805f0710>] (cqspi_exec_mem_op) from [<805edb4c>] (spi_mem_exec_op+0x3b0/0x3f8)

Fixes: 7512eaf54190 ("spi: cadence-quadspi: Fix dummy cycle calculation when buswidth > 1")
Signed-off-by: Yoshitaka Ikeda <ikeda@nskint.co.jp>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
---
 drivers/spi/spi-cadence-quadspi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index 7a00346ff9b9..d62d69dd72b9 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -309,6 +309,9 @@ static unsigned int cqspi_calc_dummy(const struct spi_mem_op *op, bool dtr)
 {
 	unsigned int dummy_clk;
 
+	if (!op->dummy.nbytes)
+		return 0;
+
 	dummy_clk = op->dummy.nbytes * (8 / op->dummy.buswidth);
 	if (dtr)
 		dummy_clk /= 2;
-- 
2.32.0

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

* Re: [PATCH v5 0/2] spi: spi-cadence-quadspi: Fix division by zero warning
  2021-07-16 14:31 [PATCH v5 0/2] spi: spi-cadence-quadspi: Fix division by zero warning Yoshitaka Ikeda
  2021-07-16 14:33 ` [PATCH v5 1/2] spi: spi-cadence-quadspi: Revert "Fix division by zero warning" Yoshitaka Ikeda
  2021-07-16 14:35 ` [PATCH v5 2/2] spi: spi-cadence-quadspi: Fix division by zero warning Yoshitaka Ikeda
@ 2021-07-16 17:32 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2021-07-16 17:32 UTC (permalink / raw)
  To: Yoshitaka Ikeda
  Cc: Mark Brown, Masahiro Mizutani, Pratyush Yadav, Philipp Zabel,
	linux-spi, Ken Kurematsu

On Fri, 16 Jul 2021 14:31:24 +0000, Yoshitaka Ikeda wrote:
> v5:
> - Added Signed-off-by and Reviewed-by.
> 
> v4:
> - Changed to better code.
> 
> v3:
> - repost.
> 
> [...]

Applied to

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

Thanks!

[1/2] spi: spi-cadence-quadspi: Revert "Fix division by zero warning"
      commit: 0ccfd1ba84a4503b509250941af149e9ebd605ca
[2/2] spi: spi-cadence-quadspi: Fix division by zero warning
      commit: 0e85ee897858b1c7a5de53f496d016899d9639c5

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

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

end of thread, other threads:[~2021-07-16 17:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16 14:31 [PATCH v5 0/2] spi: spi-cadence-quadspi: Fix division by zero warning Yoshitaka Ikeda
2021-07-16 14:33 ` [PATCH v5 1/2] spi: spi-cadence-quadspi: Revert "Fix division by zero warning" Yoshitaka Ikeda
2021-07-16 14:35 ` [PATCH v5 2/2] spi: spi-cadence-quadspi: Fix division by zero warning Yoshitaka Ikeda
2021-07-16 17:32 ` [PATCH v5 0/2] " Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.