Corrected LED name match finding avoiding extraneous Usage printouts
authorJason Kridner <jkridner@beagleboard.org>
Wed, 9 Mar 2011 02:42:01 +0000 (20:42 -0600)
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>
Sun, 4 Sep 2011 09:36:21 +0000 (11:36 +0200)
Signed-off-by: Jason Kridner <jkridner@beagleboard.org>
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Signed-off-by: Joel A Fernandes <agnel.joel@gmail.com>
Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
common/cmd_led.c

index c53195f1a3605e74440922c1ac70e8b838b50852..8b468486e0f9538fc606c0b862cd0ec2ee73e978 100644 (file)
@@ -83,7 +83,7 @@ int str_onoff (char *var)
 
 int do_led (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       int state, i;
+       int state, i, match = 0;
 
        /* Validate arguments */
        if ((argc != 3)) {
@@ -98,6 +98,7 @@ int do_led (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        for (i = 0; led_commands[i].string; i++) {
                if ((strcmp("all", argv[1]) == 0) ||
                    (strcmp(led_commands[i].string, argv[1]) == 0)) {
+                       match = 1;
                        if (led_commands[i].on) {
                                if (state) {
                                        led_commands[i].on();
@@ -112,7 +113,7 @@ int do_led (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        }
 
        /* If we ran out of matches, print Usage */
-       if (!led_commands[i].string && !(strcmp("all", argv[1]) == 0)) {
+       if (!match) {
                return cmd_usage(cmdtp);
        }