mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mtd: spi-nor: cadence: fix csqpi corruption in cqspi_set_protocol
@ 2020-09-16 16:23 Ian Abbott
  2020-09-18  9:46 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Abbott @ 2020-09-16 16:23 UTC (permalink / raw)
  To: barebox; +Cc: Ian Abbott

cqspi_set_protocol() sets `inst_width`, `addr_width` and `data_width`
for the previous chip-select in `cqspi->current_cs`, but that is
initially set to -1, leading to corruption of other `cqspi->` members.
Change it to set `inst_width`, `addr_width` and `data_width` for the
chip-select associated with the `nor` parameter.

Fixes: 5085d2ef3fbf ("mtd: spi-nor: cadence: add cqspi_set_protocol")
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
 drivers/mtd/spi-nor/cadence-quadspi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c b/drivers/mtd/spi-nor/cadence-quadspi.c
index 11e4d236d..2372482ac 100644
--- a/drivers/mtd/spi-nor/cadence-quadspi.c
+++ b/drivers/mtd/spi-nor/cadence-quadspi.c
@@ -896,8 +896,12 @@ static int cqspi_set_protocol(struct spi_nor *nor, const int read)
 {
 	struct cqspi_st *cqspi = nor->priv;
 	struct cqspi_flash_pdata *f_pdata;
+	int cs = cqspi_find_chipselect(nor);
 
-	f_pdata = &cqspi->f_pdata[cqspi->current_cs];
+	if (cs < 0)
+		return -EINVAL;
+
+	f_pdata = &cqspi->f_pdata[cs];
 
 	f_pdata->inst_width = CQSPI_INST_TYPE_SINGLE;
 	f_pdata->addr_width = CQSPI_INST_TYPE_SINGLE;
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2020-09-18  9:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-16 16:23 [PATCH] mtd: spi-nor: cadence: fix csqpi corruption in cqspi_set_protocol Ian Abbott
2020-09-18  9:46 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox