From c3fbb1e6771dabb14571552c036a049ffa470eb1 Mon Sep 17 00:00:00 2001 From: Phil Elwell Date: Fri, 30 Apr 2021 08:34:36 +0100 Subject: [PATCH] spi: bcm2835: Increase the CS limit to 24 Increase the maximum number of CS lines to 24, and ensure this limit is not exceeded. See: https://github.com/raspberrypi/linux/pull/4281 Suggested-by: Joe Burmeister Signed-off-by: Phil Elwell --- drivers/spi/spi-bcm2835.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/spi/spi-bcm2835.c +++ b/drivers/spi/spi-bcm2835.c @@ -28,6 +28,7 @@ #include #include /* FIXME: using chip internals */ #include /* FIXME: using chip internals */ +#include #include #include @@ -1299,6 +1300,11 @@ static int bcm2835_spi_probe(struct plat struct bcm2835_spi *bs; int err; + if (of_gpio_named_count(pdev->dev.of_node, "cs-gpios") > + BCM2835_SPI_NUM_CS) + return dev_err_probe(&pdev->dev, -EINVAL, + "too many chip selects\n"); + ctlr = devm_spi_alloc_master(&pdev->dev, ALIGN(sizeof(*bs), dma_get_cache_alignment())); if (!ctlr)