spi: cadence-qspi: assert each subnode flash CS is valid
authorThéo Lebrun <theo.lebrun@bootlin.com>
Fri, 9 Feb 2024 13:45:30 +0000 (14:45 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 21 Feb 2024 16:27:18 +0000 (16:27 +0000)
Check each flash CS against the num-cs property from devicetree.
Fallback to the driver max supported value (CQSPI_MAX_CHIPSELECT) if
num-cs isn't present.

cqspi->num_chipselect is set in cqspi_of_get_pdata() to the num-cs
devicetree property, or to CQSPI_MAX_CHIPSELECT if num-cs is not set.

Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>
Reviewed-by: Dhruva Gole <d-gole@ti.com>
Link: https://msgid.link/r/20240209-cdns-qspi-cs-v1-1-a4f9dfed9ab4@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-cadence-quadspi.c

index a5e2f7786b760f35a60d46ec4e76a3008a098367..a397f2c2b5fca82f7f8433a8d065b8f066d705f0 100644 (file)
@@ -1635,7 +1635,7 @@ static int cqspi_setup_flash(struct cqspi_st *cqspi)
                        return ret;
                }
 
-               if (cs >= CQSPI_MAX_CHIPSELECT) {
+               if (cs >= cqspi->num_chipselect) {
                        dev_err(dev, "Chip select %d out of range.\n", cs);
                        of_node_put(np);
                        return -EINVAL;