[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220127185359.27322-1-kdasu.kdev@gmail.com>
Date: Thu, 27 Jan 2022 13:53:59 -0500
From: Kamal Dasu <kdasu.kdev@...il.com>
To: broonie@...nel.org, linux-spi@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: f.fainelli@...il.com, bcm-kernel-feedback-list@...adcom.com,
Kamal Dasu <kdasu.kdev@...il.com>
Subject: [PATCH] spi: bcm-qspi: check for valid cs before applying chip select
Apply only valid chip select value. This change fixes case where chip
select is set to initial value of '-1' during probe and PM supend and
subsequent resume can try to use the value with undefined behaviour.
Also in case where gpio based chip select, the check in
bcm_qspi_chip_select() shall prevent undefined behaviour on resume.
Fixes: fa236a7ef240 ("spi: bcm-qspi: Add Broadcom MSPI driver")
Signed-off-by: Kamal Dasu <kdasu.kdev@...il.com>
---
drivers/spi/spi-bcm-qspi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/spi/spi-bcm-qspi.c b/drivers/spi/spi-bcm-qspi.c
index c9a769b8594b..86c76211b3d3 100644
--- a/drivers/spi/spi-bcm-qspi.c
+++ b/drivers/spi/spi-bcm-qspi.c
@@ -585,7 +585,7 @@ static void bcm_qspi_chip_select(struct bcm_qspi *qspi, int cs)
u32 rd = 0;
u32 wr = 0;
- if (qspi->base[CHIP_SELECT]) {
+ if (cs >= 0 && qspi->base[CHIP_SELECT]) {
rd = bcm_qspi_read(qspi, CHIP_SELECT, 0);
wr = (rd & ~0xff) | (1 << cs);
if (rd == wr)
--
2.17.1
Powered by blists - more mailing lists