From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Raju Rangoju <Raju.Rangoju@amd.com>
Cc: <broonie@kernel.org>, <linux-spi@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
Krishnamoorthi M <krishnamoorthi.m@amd.com>,
Akshata MukundShetty <akshata.mukundshetty@amd.com>
Subject: Re: [PATCH] spi: spi-mem: Add fix to avoid divide error
Date: Thu, 24 Apr 2025 16:25:21 +0200 [thread overview]
Message-ID: <87msc5hc1a.fsf@bootlin.com> (raw)
In-Reply-To: <20250424121333.417372-1-Raju.Rangoju@amd.com> (Raju Rangoju's message of "Thu, 24 Apr 2025 17:43:33 +0530")
> --- a/drivers/spi/spi-mem.c
> +++ b/drivers/spi/spi-mem.c
> @@ -596,7 +596,11 @@ u64 spi_mem_calc_op_duration(struct spi_mem_op *op)
> ns_per_cycles = 1000000000 / op->max_freq;
> ncycles += ((op->cmd.nbytes * 8) / op->cmd.buswidth) / (op->cmd.dtr ? 2 : 1);
> ncycles += ((op->addr.nbytes * 8) / op->addr.buswidth) / (op->addr.dtr ? 2 : 1);
> - ncycles += ((op->dummy.nbytes * 8) / op->dummy.buswidth) / (op->dummy.dtr ? 2 : 1);
> +
> + /* Dummy bytes are optional for some SPI flash memory operations */
> + if (op->dummy.nbytes)
> + ncycles += ((op->dummy.nbytes * 8) / op->dummy.buswidth) / (op->dummy.dtr ? 2 : 1);
> +
> ncycles += ((op->data.nbytes * 8) / op->data.buswidth) / (op->data.dtr ? 2 : 1);
>
> return ncycles * ns_per_cycles;
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Actually even address bytes sometimes may be skipped (eg. status reads). But there is no
reason for using spi_mem_calc_op_duration() in this case.
Thanks,
Miquèl
next prev parent reply other threads:[~2025-04-24 14:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-24 12:13 [PATCH] spi: spi-mem: Add fix to avoid divide error Raju Rangoju
2025-04-24 12:15 ` Mark Brown
2025-04-24 12:27 ` Rangoju, Raju
2025-04-24 12:44 ` Mark Brown
2025-04-24 14:25 ` Miquel Raynal [this message]
2025-04-25 16:03 ` Mark Brown
2025-06-02 9:45 ` Dan Carpenter
2025-06-09 10:40 ` Rangoju, Raju
2025-06-10 8:03 ` Dan Carpenter
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=87msc5hc1a.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=Raju.Rangoju@amd.com \
--cc=akshata.mukundshetty@amd.com \
--cc=broonie@kernel.org \
--cc=krishnamoorthi.m@amd.com \
--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 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.