diff mbox series

spi: spi-fsl-dspi: Use max_native_cs instead of num_chipselect to set SPI_MCR

Message ID 20201202142552.44385-1-fido_max@inbox.ru (mailing list archive)
State Accepted
Commit 2c2b3ad2c4c801bab1eec7264ea6991b1e4e8f2c
Headers show
Series spi: spi-fsl-dspi: Use max_native_cs instead of num_chipselect to set SPI_MCR | expand

Commit Message

Maxim Kochetkov Dec. 2, 2020, 2:25 p.m. UTC
If cs-gpios property is used in devicetree then ctlr->num_chipselect value
may be changed by spi_get_gpio_descs().
So use ctlr->max_native_cs instead of ctlr->num_chipselect to set SPI_MCR

Fixes: 4fcc7c2292de (spi: spi-fsl-dspi: Don't access reserved fields in SPI_MCR)
Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
---
 drivers/spi/spi-fsl-dspi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Vladimir Oltean Dec. 2, 2020, 11:57 p.m. UTC | #1
On Wed, Dec 02, 2020 at 05:25:52PM +0300, Maxim Kochetkov wrote:
> If cs-gpios property is used in devicetree then ctlr->num_chipselect value
> may be changed by spi_get_gpio_descs().
> So use ctlr->max_native_cs instead of ctlr->num_chipselect to set SPI_MCR
> 
> Fixes: 4fcc7c2292de (spi: spi-fsl-dspi: Don't access reserved fields in SPI_MCR)
> Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
> ---

In this case, it looks like Mark did really apply it, Maxim, I'm not
sure why you resent:
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git/commit/?h=for-5.10&id=2c2b3ad2c4c801bab1eec7264ea6991b1e4e8f2c
Maxim Kochetkov Dec. 3, 2020, 4:40 a.m. UTC | #2
I'm sorry for that.
I checked at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/ 
before resend and didn't find any updates.

03.12.2020 02:57, Vladimir Oltean пишет:
> On Wed, Dec 02, 2020 at 05:25:52PM +0300, Maxim Kochetkov wrote:
>> If cs-gpios property is used in devicetree then ctlr->num_chipselect value
>> may be changed by spi_get_gpio_descs().
>> So use ctlr->max_native_cs instead of ctlr->num_chipselect to set SPI_MCR
>>
>> Fixes: 4fcc7c2292de (spi: spi-fsl-dspi: Don't access reserved fields in SPI_MCR)
>> Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
>> ---
> 
> In this case, it looks like Mark did really apply it, Maxim, I'm not
> sure why you resent:
> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git/commit/?h=for-5.10&id=2c2b3ad2c4c801bab1eec7264ea6991b1e4e8f2c
>
diff mbox series

Patch

diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 1a08c1d584ab..028736687488 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -1165,7 +1165,7 @@  static int dspi_init(struct fsl_dspi *dspi)
 	unsigned int mcr;
 
 	/* Set idle states for all chip select signals to high */
-	mcr = SPI_MCR_PCSIS(GENMASK(dspi->ctlr->num_chipselect - 1, 0));
+	mcr = SPI_MCR_PCSIS(GENMASK(dspi->ctlr->max_native_cs - 1, 0));
 
 	if (dspi->devtype_data->trans_mode == DSPI_XSPI_MODE)
 		mcr |= SPI_MCR_XSPI;
@@ -1250,7 +1250,7 @@  static int dspi_probe(struct platform_device *pdev)
 
 	pdata = dev_get_platdata(&pdev->dev);
 	if (pdata) {
-		ctlr->num_chipselect = pdata->cs_num;
+		ctlr->num_chipselect = ctlr->max_native_cs = pdata->cs_num;
 		ctlr->bus_num = pdata->bus_num;
 
 		/* Only Coldfire uses platform data */
@@ -1263,7 +1263,7 @@  static int dspi_probe(struct platform_device *pdev)
 			dev_err(&pdev->dev, "can't get spi-num-chipselects\n");
 			goto out_ctlr_put;
 		}
-		ctlr->num_chipselect = cs_num;
+		ctlr->num_chipselect = ctlr->max_native_cs = cs_num;
 
 		of_property_read_u32(np, "bus-num", &bus_num);
 		ctlr->bus_num = bus_num;