Create a single cmd_call() function to handle command execution
[oweals/u-boot.git] / common / command.c
index 2c0bf534492e2eaaa967a50079fac5fcd18483f5..fe290759cd06d871bd6779585e4c4d2c7ecadd45 100644 (file)
@@ -479,10 +479,32 @@ void fixup_cmdtable(cmd_tbl_t *cmdtp, int size)
 #ifdef CONFIG_AUTO_COMPLETE
                if (cmdtp->complete) {
                        addr = (ulong)(cmdtp->complete) + gd->reloc_off;
-                       cmdtp->complete = (char *)addr;
+                       cmdtp->complete =
+                               (int (*)(int, char * const [], char, int, char * []))addr;
                }
 #endif
                cmdtp++;
        }
 }
 #endif
+
+/**
+ * Call a command function. This should be the only route in U-Boot to call
+ * a command, so that we can track whether we are waiting for input or
+ * executing a command.
+ *
+ * @param cmdtp                Pointer to the command to execute
+ * @param flag         Some flags normally 0 (see CMD_FLAG_.. above)
+ * @param argc         Number of arguments (arg 0 must be the command text)
+ * @param argv         Arguments
+ * @return 0 if command succeeded, else non-zero (CMD_RET_...)
+ */
+int cmd_call(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       int result;
+
+       result = (cmdtp->cmd)(cmdtp, flag, argc, argv);
+       if (result)
+               debug("Command failed, result=%d", result);
+       return result;
+}