Skip to content

Commit

Permalink
spi/xilinx: Check number of slaves range
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ricardo Ribalda authored and Mark Brown committed Jan 28, 2015
1 parent 2241735 commit eb25f16
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/spi/spi-xilinx.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <linux/spi/xilinx_spi.h>
#include <linux/io.h>

#define XILINX_SPI_MAX_CS 32

#define XILINX_SPI_NAME "xilinx_spi"

/* Register definitions as per "OPB Serial Peripheral Interface (SPI) (v1.00e)
Expand Down Expand Up @@ -347,6 +349,11 @@ static int xilinx_spi_probe(struct platform_device *pdev)
return -EINVAL;
}

if (num_cs > XILINX_SPI_MAX_CS) {
dev_err(&pdev->dev, "Invalid number of spi slaves\n");
return -EINVAL;
}

master = spi_alloc_master(&pdev->dev, sizeof(struct xilinx_spi));
if (!master)
return -ENODEV;
Expand Down

0 comments on commit eb25f16

Please sign in to comment.