diff options
-rw-r--r-- | common/fan.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/common/fan.c b/common/fan.c index 398a149268..5c363ed124 100644 --- a/common/fan.c +++ b/common/fan.c @@ -275,6 +275,7 @@ DECLARE_CONSOLE_COMMAND(fanset, cc_fanset, static int cc_fanduty(int argc, char **argv) { + const char *percent_str; int percent = 0; char *e; int fan = 0; @@ -285,21 +286,24 @@ static int cc_fanduty(int argc, char **argv) } if (fan_count > 1) { - if (argc < 2) { + if (argc < 3) { ccprintf("fan number is required as the first arg\n"); return EC_ERROR_PARAM_COUNT; } + } + + if (argc == 3) { fan = strtoi(argv[1], &e, 0); if (*e || fan >= fan_count) return EC_ERROR_PARAM1; - argc--; - argv++; - } - - if (argc < 2) + percent_str = argv[2]; + } else if (argc == 2) { + percent_str = argv[1]; + } else { return EC_ERROR_PARAM_COUNT; + } - percent = strtoi(argv[1], &e, 0); + percent = strtoi(percent_str, &e, 0); if (*e) return EC_ERROR_PARAM1; @@ -309,7 +313,7 @@ static int cc_fanduty(int argc, char **argv) return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(fanduty, cc_fanduty, - "{fan} percent", + "[fan] percent", "Set fan duty cycle"); /*****************************************************************************/ |