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

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] 7+ messages in thread

* [PATCH v4 1/2] spi: spi-cadence-quadspi: Revert "Fix division by zero warning"
  2021-07-16  3:05 [PATCH v4 0/2] spi: spi-cadence-quadspi: Fix division by zero warning Yoshitaka Ikeda
@ 2021-07-16  3:07 ` Yoshitaka Ikeda
  2021-07-16  7:27   ` Pratyush Yadav
  2021-07-16 12:23   ` Mark Brown
  2021-07-16  3:08 ` [PATCH v4 2/2] spi: spi-cadence-quadspi: Fix division by zero warning Yoshitaka Ikeda
  1 sibling, 2 replies; 7+ messages in thread
From: Yoshitaka Ikeda @ 2021-07-16  3:07 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.
---
 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] 7+ messages in thread

* [PATCH v4 2/2] spi: spi-cadence-quadspi: Fix division by zero warning
  2021-07-16  3:05 [PATCH v4 0/2] spi: spi-cadence-quadspi: Fix division by zero warning Yoshitaka Ikeda
  2021-07-16  3:07 ` [PATCH v4 1/2] spi: spi-cadence-quadspi: Revert "Fix division by zero warning" Yoshitaka Ikeda
@ 2021-07-16  3:08 ` Yoshitaka Ikeda
  2021-07-16  7:26   ` Pratyush Yadav
  1 sibling, 1 reply; 7+ messages in thread
From: Yoshitaka Ikeda @ 2021-07-16  3:08 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>
---
 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] 7+ messages in thread

* Re: [PATCH v4 2/2] spi: spi-cadence-quadspi: Fix division by zero warning
  2021-07-16  3:08 ` [PATCH v4 2/2] spi: spi-cadence-quadspi: Fix division by zero warning Yoshitaka Ikeda
@ 2021-07-16  7:26   ` Pratyush Yadav
  0 siblings, 0 replies; 7+ messages in thread
From: Pratyush Yadav @ 2021-07-16  7:26 UTC (permalink / raw)
  To: Yoshitaka Ikeda
  Cc: Mark Brown, Philipp Zabel, linux-spi, Masahiro Mizutani, Ken Kurematsu

On 16/07/21 03:08AM, Yoshitaka Ikeda wrote:
> 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>

Thanks.

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

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

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

* Re: [PATCH v4 1/2] spi: spi-cadence-quadspi: Revert "Fix division by zero warning"
  2021-07-16  3:07 ` [PATCH v4 1/2] spi: spi-cadence-quadspi: Revert "Fix division by zero warning" Yoshitaka Ikeda
@ 2021-07-16  7:27   ` Pratyush Yadav
  2021-07-16 12:23   ` Mark Brown
  1 sibling, 0 replies; 7+ messages in thread
From: Pratyush Yadav @ 2021-07-16  7:27 UTC (permalink / raw)
  To: Yoshitaka Ikeda
  Cc: Mark Brown, Philipp Zabel, linux-spi, Masahiro Mizutani, Ken Kurematsu

On 16/07/21 03:07AM, Yoshitaka Ikeda wrote:
> Revert to change to a better code.
> 
> This reverts commit 55cef88bbf12f3bfbe5c2379a8868a034707e755.

I don't think this is needed since your earlier version was not applied 
to the SPI tree in the first place. Patch 2 alone should be enough.

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

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

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

* Re: [PATCH v4 1/2] spi: spi-cadence-quadspi: Revert "Fix division by zero warning"
  2021-07-16  3:07 ` [PATCH v4 1/2] spi: spi-cadence-quadspi: Revert "Fix division by zero warning" Yoshitaka Ikeda
  2021-07-16  7:27   ` Pratyush Yadav
@ 2021-07-16 12:23   ` Mark Brown
  2021-07-16 14:26     ` Yoshitaka Ikeda
  1 sibling, 1 reply; 7+ messages in thread
From: Mark Brown @ 2021-07-16 12:23 UTC (permalink / raw)
  To: Yoshitaka Ikeda
  Cc: Philipp Zabel, Pratyush Yadav, linux-spi, Masahiro Mizutani,
	Ken Kurematsu

[-- Attachment #1: Type: text/plain, Size: 424 bytes --]

On Fri, Jul 16, 2021 at 03:07:21AM +0000, Yoshitaka Ikeda wrote:
> Revert to change to a better code.
> 
> This reverts commit 55cef88bbf12f3bfbe5c2379a8868a034707e755.
> ---
>  drivers/spi/spi-cadence-quadspi.c | 10 ++++------

You've not provided a Signed-off-by for this so I can't do anything with
it, please see Documentation/process/submitting-patches.rst for details
on what this is and why it's important.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

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

On 2021/07/16 21:23, Mark Brown wrote:
> You've not provided a Signed-off-by for this so I can't do anything with
> it, please see Documentation/process/submitting-patches.rst for details
> on what this is and why it's important.

I'm sorry, I was wrong.
I will resubmit the patch separately.


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

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

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16  3:05 [PATCH v4 0/2] spi: spi-cadence-quadspi: Fix division by zero warning Yoshitaka Ikeda
2021-07-16  3:07 ` [PATCH v4 1/2] spi: spi-cadence-quadspi: Revert "Fix division by zero warning" Yoshitaka Ikeda
2021-07-16  7:27   ` Pratyush Yadav
2021-07-16 12:23   ` Mark Brown
2021-07-16 14:26     ` Yoshitaka Ikeda
2021-07-16  3:08 ` [PATCH v4 2/2] spi: spi-cadence-quadspi: Fix division by zero warning Yoshitaka Ikeda
2021-07-16  7:26   ` Pratyush Yadav

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.