diff options
author | Ricardo Ribalda <ricardo.ribalda@gmail.com> | 2015-01-28 14:53:39 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-01-28 14:57:32 -0500 |
commit | eb25f16c6f446936932f41f3ff811fbdc285bbc4 (patch) | |
tree | bcab11daa1c12ed4a0b8b9719421937e7f95df2e /drivers/spi/spi-xilinx.c | |
parent | 22417352f6b7f623495cc426680de75d725197df (diff) |
spi/xilinx: Check number of slaves range
The core only supports up to 32 slaves, and the chipselect function
expects the same.
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-xilinx.c')
-rw-r--r-- | drivers/spi/spi-xilinx.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c index 337fda4e78a6..2ca55f6b5158 100644 --- a/drivers/spi/spi-xilinx.c +++ b/drivers/spi/spi-xilinx.c | |||
@@ -22,6 +22,8 @@ | |||
22 | #include <linux/spi/xilinx_spi.h> | 22 | #include <linux/spi/xilinx_spi.h> |
23 | #include <linux/io.h> | 23 | #include <linux/io.h> |
24 | 24 | ||
25 | #define XILINX_SPI_MAX_CS 32 | ||
26 | |||
25 | #define XILINX_SPI_NAME "xilinx_spi" | 27 | #define XILINX_SPI_NAME "xilinx_spi" |
26 | 28 | ||
27 | /* Register definitions as per "OPB Serial Peripheral Interface (SPI) (v1.00e) | 29 | /* Register definitions as per "OPB Serial Peripheral Interface (SPI) (v1.00e) |
@@ -347,6 +349,11 @@ static int xilinx_spi_probe(struct platform_device *pdev) | |||
347 | return -EINVAL; | 349 | return -EINVAL; |
348 | } | 350 | } |
349 | 351 | ||
352 | if (num_cs > XILINX_SPI_MAX_CS) { | ||
353 | dev_err(&pdev->dev, "Invalid number of spi slaves\n"); | ||
354 | return -EINVAL; | ||
355 | } | ||
356 | |||
350 | master = spi_alloc_master(&pdev->dev, sizeof(struct xilinx_spi)); | 357 | master = spi_alloc_master(&pdev->dev, sizeof(struct xilinx_spi)); |
351 | if (!master) | 358 | if (!master) |
352 | return -ENODEV; | 359 | return -ENODEV; |