From: Fabio Estevam Date: Mon, 23 Apr 2012 08:30:49 +0000 (+0000) Subject: spi: mxs: Introduce spi_cs_is_valid() X-Git-Tag: v2012.07-rc1~144^2~60 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=79cb14ab39f970b85204ab1b2f796b02bb65335d;p=oweals%2Fu-boot.git spi: mxs: Introduce spi_cs_is_valid() Introduce spi_cs_is_valid() for validating spi bus and chip select numbers. Signed-off-by: Fabio Estevam Acked-by: Marek Vasut Acked-by: Mike Frysinger --- diff --git a/drivers/spi/mxs_spi.c b/drivers/spi/mxs_spi.c index 4e6f14ee07..e7237e720a 100644 --- a/drivers/spi/mxs_spi.c +++ b/drivers/spi/mxs_spi.c @@ -51,14 +51,23 @@ void spi_init(void) { } +int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{ + /* MXS SPI: 4 ports and 3 chip selects maximum */ + if (bus > 3 || cs > 2) + return 0; + else + return 1; +} + struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, unsigned int max_hz, unsigned int mode) { struct mxs_spi_slave *mxs_slave; uint32_t addr; - if (bus > 3) { - printf("MXS SPI: Max bus number is 3\n"); + if (!spi_cs_is_valid(bus, cs)) { + printf("mxs_spi: invalid bus %d / chip select %d\n", bus, cs); return NULL; }