Linux SPI subsystem development
 help / color / mirror / Atom feed
From: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
To: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] spi: sn-f-ospi: Fix division by zero
Date: Thu, 6 Feb 2025 17:36:07 +0900	[thread overview]
Message-ID: <e606acef-adff-4e19-beb0-b587f8c269c6@socionext.com> (raw)
In-Reply-To: <20250206082717.3833004-1-hayashi.kunihiko@socionext.com>

On 2025/02/06 17:27, 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.
> 
> 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;
>   }
>   

Sorry, I missed a tag. I'll resend the patch.

Thank you,

---
Best Regards
Kunihiko Hayashi

      reply	other threads:[~2025-02-06  8:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-06  8:27 [PATCH] spi: sn-f-ospi: Fix division by zero Kunihiko Hayashi
2025-02-06  8:36 ` Kunihiko Hayashi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e606acef-adff-4e19-beb0-b587f8c269c6@socionext.com \
    --to=hayashi.kunihiko@socionext.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox