From: Cédric Le Goater <clg@kaod.org>
To: linux-aspeed@lists.ozlabs.org
Subject: [PATCH v3 2/2] spi: aspeed: Fix division by zero
Date: Wed, 22 Jun 2022 18:16:17 +0200 [thread overview]
Message-ID: <20220622161617.3719096-3-clg@kaod.org> (raw)
In-Reply-To: <20220622161617.3719096-1-clg@kaod.org>
When using the normal read operation for data transfers, the dummy bus
width is zero. In that case, they are no dummy bytes to transfer and
setting the dummy field in the controller register becomes useless.
Issue was found on a custom "Bifrost" board based on the AST2500 SoC
and using a MX25L51245GMI-08G SPI Flash.
Reported-by: Ian Woloschin <ian.woloschin@akamai.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Tested-by: Ian Woloschin <iwolosch@akamai.com>
Fixes: 54613fc6659b ("spi: aspeed: Add support for direct mapping")
Signed-off-by: C?dric Le Goater <clg@kaod.org>
---
drivers/spi/spi-aspeed-smc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
index ac64be289e59..3e891bf22470 100644
--- a/drivers/spi/spi-aspeed-smc.c
+++ b/drivers/spi/spi-aspeed-smc.c
@@ -582,9 +582,11 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
ctl_val = readl(chip->ctl) & ~CTRL_IO_CMD_MASK;
ctl_val |= aspeed_spi_get_io_mode(op) |
op->cmd.opcode << CTRL_COMMAND_SHIFT |
- CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth) |
CTRL_IO_MODE_READ;
+ if (op->dummy.nbytes)
+ ctl_val |= CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth);
+
/* Tune 4BYTE address mode */
if (op->addr.nbytes) {
u32 addr_mode = readl(aspi->regs + CE_CTRL_REG);
--
2.35.3
next prev parent reply other threads:[~2022-06-22 16:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-22 16:16 [PATCH v3 0/2] spi: aspeed: Fix division by zero Cédric Le Goater
2022-06-22 16:16 ` [PATCH v3 1/2] spi: aspeed: Add dev_dbg() to dump the spi-mem direct mapping descriptor Cédric Le Goater
2022-06-23 5:15 ` Joel Stanley
2022-06-22 16:16 ` Cédric Le Goater [this message]
2022-06-29 17:09 ` [PATCH v3 2/2] spi: aspeed: Fix division by zero Mark Brown
2022-06-29 17:21 ` Cédric Le Goater
2022-06-29 17:27 ` Mark Brown
2022-06-29 18:07 ` Cédric Le Goater
2022-06-30 11:46 ` [PATCH v3 0/2] " Mark Brown
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=20220622161617.3719096-3-clg@kaod.org \
--to=clg@kaod.org \
--cc=linux-aspeed@lists.ozlabs.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