Skip to content

Commit 0f3841a

Browse files
tlebbroonie
authored andcommitted
spi: cadence-qspi: report correct number of chip-select
Set the ->num_chipselect field in struct cqspi_st and struct spi_controller to the current number of chip-select. The value is dependent on declared flashes in devicetree. Previously, the num-cs property from devicetree or the maximum value was being reported. Signed-off-by: Théo Lebrun <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 7cc3522 commit 0f3841a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/spi/spi-cadence-quadspi.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,7 @@ static const struct spi_controller_mem_caps cqspi_mem_caps = {
16211621

16221622
static int cqspi_setup_flash(struct cqspi_st *cqspi)
16231623
{
1624+
unsigned int max_cs = cqspi->num_chipselect - 1;
16241625
struct platform_device *pdev = cqspi->pdev;
16251626
struct device *dev = &pdev->dev;
16261627
struct device_node *np = dev->of_node;
@@ -1641,6 +1642,8 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi)
16411642
dev_err(dev, "Chip select %d out of range.\n", cs);
16421643
of_node_put(np);
16431644
return -EINVAL;
1645+
} else if (cs < max_cs) {
1646+
max_cs = cs;
16441647
}
16451648

16461649
f_pdata = &cqspi->f_pdata[cs];
@@ -1654,6 +1657,7 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi)
16541657
}
16551658
}
16561659

1660+
cqspi->num_chipselect = max_cs + 1;
16571661
return 0;
16581662
}
16591663

@@ -1864,14 +1868,14 @@ static int cqspi_probe(struct platform_device *pdev)
18641868
cqspi->current_cs = -1;
18651869
cqspi->sclk = 0;
18661870

1867-
host->num_chipselect = cqspi->num_chipselect;
1868-
18691871
ret = cqspi_setup_flash(cqspi);
18701872
if (ret) {
18711873
dev_err(dev, "failed to setup flash parameters %d\n", ret);
18721874
goto probe_setup_failed;
18731875
}
18741876

1877+
host->num_chipselect = cqspi->num_chipselect;
1878+
18751879
if (cqspi->use_direct_mode) {
18761880
ret = cqspi_request_mmap_dma(cqspi);
18771881
if (ret == -EPROBE_DEFER)

0 commit comments

Comments
 (0)