dm: spi: Check cs number before accessing slaves
Add chip select number check in spi_find_chip_select().
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Jagan Teki <jagan@amarulasolutions.com> # SoPine
diff --git a/include/spi.h b/include/spi.h
index ba2c840..18a0312 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -561,7 +561,8 @@
* @bus: SPI bus to search
* @cs: Chip select to look for
* @devp: Returns the slave device if found
- * @return 0 if found, -ENODEV on error
+ * @return 0 if found, -EINVAL if cs is invalid, -ENODEV if no device attached,
+ * other -ve value on error
*/
int spi_find_chip_select(struct udevice *bus, int cs, struct udevice **devp);