Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb25f16c authored by Ricardo Ribalda Delgado's avatar Ricardo Ribalda Delgado Committed by Mark Brown
Browse files

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: default avatarRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 22417352
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,8 @@
#include <linux/spi/xilinx_spi.h>
#include <linux/spi/xilinx_spi.h>
#include <linux/io.h>
#include <linux/io.h>


#define XILINX_SPI_MAX_CS	32

#define XILINX_SPI_NAME "xilinx_spi"
#define XILINX_SPI_NAME "xilinx_spi"


/* Register definitions as per "OPB Serial Peripheral Interface (SPI) (v1.00e)
/* Register definitions as per "OPB Serial Peripheral Interface (SPI) (v1.00e)
@@ -347,6 +349,11 @@ static int xilinx_spi_probe(struct platform_device *pdev)
		return -EINVAL;
		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));
	master = spi_alloc_master(&pdev->dev, sizeof(struct xilinx_spi));
	if (!master)
	if (!master)
		return -ENODEV;
		return -ENODEV;