Signed-off-by: Eric Nelson <eric.nel...@boundarydevices.com>
---
 common/cmd_sf.c |   34 +++++++++++++++++++++++-----------
 1 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index 7225656..97fce16 100644
--- a/common/cmd_sf.c
+++ b/common/cmd_sf.c
@@ -70,20 +70,28 @@ static int do_spi_flash_probe(int argc, char * const argv[])
        char *endp;
        struct spi_flash *new;
 
-       if (argc < 2)
-               return -1;
-
-       cs = simple_strtoul(argv[1], &endp, 0);
-       if (*argv[1] == 0 || (*endp != 0 && *endp != ':'))
+#ifndef CONFIG_SPI_FLASH_CS
+       if (argc < 2) {
+               printf("%s: missing arguments\n", __func__);
                return -1;
-       if (*endp == ':') {
-               if (endp[1] == 0)
-                       return -1;
+       }
+#else
+       cs = CONFIG_SPI_FLASH_CS ;
+#endif
 
-               bus = cs;
-               cs = simple_strtoul(endp + 1, &endp, 0);
-               if (*endp != 0)
+       if (argc >= 2) {
+               cs = simple_strtoul(argv[1], &endp, 0);
+               if (*argv[1] == 0 || (*endp != 0 && *endp != ':'))
                        return -1;
+               if (*endp == ':') {
+                       if (endp[1] == 0)
+                               return -1;
+
+                       bus = cs;
+                       cs = simple_strtoul(endp + 1, &endp, 0);
+                       if (*endp != 0)
+                               return -1;
+               }
        }
 
        if (argc >= 3) {
@@ -299,7 +307,11 @@ usage:
 U_BOOT_CMD(
        sf,     5,      1,      do_spi_flash,
        "SPI flash sub-system",
+#ifndef CONFIG_SPI_FLASH_CS
        "probe [bus:]cs [hz] [mode]     - init flash device on given SPI bus\n"
+#else
+       "probe [[bus:]cs] [hz] [mode]   - init flash device on given SPI bus\n"
+#endif
        "                                 and chip select\n"
        "sf read addr offset len        - read `len' bytes starting at\n"
        "                                 `offset' to memory at `addr'\n"
-- 
1.7.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to