diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-05-25 13:17:21 -0700 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2012-05-25 13:34:06 -0700 |
commit | e704c712ad473160e97717f139ab3929bcd249c1 (patch) | |
tree | 1b87c7ad05a1e97bd04326adc7f6b6239407b10e /common/thermal.c | |
parent | 89e1d5a1219c87d90e1362716f799b16aad5c921 (diff) | |
download | chrome-ec-e704c712ad473160e97717f139ab3929bcd249c1.tar.gz |
Better help for console commands
Additional help messages and usage are gated by
CONFIG_CONSOLE_CMDHELP, so we can turn it on if there's space (adds
about 3KB to image size) and turn it off when there isn't.
Signed-off-by: Randall Spangler <rspangler@chromium.org>
BUG=none
TEST=manual
1) help
2) help list
3) help gpioset
4) gpioset -> wrong number of params
5) gpioset fred 0 -> param1 bad
6) gpioset cpu_prochot fred -> param2 bad
Change-Id: Ibe99f37212020f763ebe65a068e6aa83a809a370
Diffstat (limited to 'common/thermal.c')
-rw-r--r-- | common/thermal.c | 66 |
1 files changed, 28 insertions, 38 deletions
diff --git a/common/thermal.c b/common/thermal.c index 72709cd8ec..4f14ca3f50 100644 --- a/common/thermal.c +++ b/common/thermal.c @@ -241,18 +241,12 @@ static int command_thermal_config(int argc, char **argv) char *e; int sensor_type, threshold_id, value; - if (argc != 2 && argc != 4) { - ccputs("Usage: thermalconf <sensor_type> " - "[<threshold_id> <value>]\n"); - return EC_ERROR_UNKNOWN; - } + if (argc != 2 && argc != 4) + return EC_ERROR_PARAM_COUNT; sensor_type = strtoi(argv[1], &e, 0); - if ((e && *e) || sensor_type < 0 || - sensor_type >= TEMP_SENSOR_TYPE_COUNT) { - ccputs("Bad sensor type ID.\n"); - return EC_ERROR_UNKNOWN; - } + if (*e || sensor_type < 0 || sensor_type >= TEMP_SENSOR_TYPE_COUNT) + return EC_ERROR_PARAM1; if (argc == 2) { print_thermal_config(sensor_type); @@ -260,16 +254,12 @@ static int command_thermal_config(int argc, char **argv) } threshold_id = strtoi(argv[2], &e, 0); - if ((e && *e) || threshold_id < 0 || threshold_id >= THRESHOLD_COUNT) { - ccputs("Bad threshold ID.\n"); - return EC_ERROR_UNKNOWN; - } + if (*e || threshold_id < 0 || threshold_id >= THRESHOLD_COUNT) + return EC_ERROR_PARAM2; value = strtoi(argv[3], &e, 0); - if ((e && *e) || value < 0) { - ccputs("Bad threshold value.\n"); - return EC_ERROR_UNKNOWN; - } + if (*e || value < 0) + return EC_ERROR_PARAM3; thermal_config[sensor_type].thresholds[threshold_id] = value; ccprintf("Setting threshold %d of sensor type %d to %d\n", @@ -277,7 +267,10 @@ static int command_thermal_config(int argc, char **argv) return EC_SUCCESS; } -DECLARE_CONSOLE_COMMAND(thermalconf, command_thermal_config); +DECLARE_CONSOLE_COMMAND(thermalconf, command_thermal_config, + "sensortype [threshold_id temp]", + "Get/set thermal threshold temp", + NULL); static int command_fan_config(int argc, char **argv) @@ -285,18 +278,13 @@ static int command_fan_config(int argc, char **argv) char *e; int sensor_type, stepping_id, value; - if (argc != 2 && argc != 4) { - ccputs("Usage: thermalfan <sensor_type> " - "[<stepping_id> <value>]\n"); - return EC_ERROR_UNKNOWN; - } + if (argc != 2 && argc != 4) + return EC_ERROR_PARAM_COUNT; sensor_type = strtoi(argv[1], &e, 0); if ((e && *e) || sensor_type < 0 || - sensor_type >= TEMP_SENSOR_TYPE_COUNT) { - ccputs("Bad sensor type ID.\n"); - return EC_ERROR_UNKNOWN; - } + sensor_type >= TEMP_SENSOR_TYPE_COUNT) + return EC_ERROR_PARAM1; if (argc == 2) { print_fan_stepping(sensor_type); @@ -304,16 +292,12 @@ static int command_fan_config(int argc, char **argv) } stepping_id = strtoi(argv[2], &e, 0); - if ((e && *e) || stepping_id < 0 || stepping_id >= THERMAL_FAN_STEPS) { - ccputs("Bad stepping ID.\n"); - return EC_ERROR_UNKNOWN; - } + if ((e && *e) || stepping_id < 0 || stepping_id >= THERMAL_FAN_STEPS) + return EC_ERROR_PARAM2; value = strtoi(argv[3], &e, 0); - if ((e && *e) || value < 0) { - ccputs("Bad threshold value.\n"); - return EC_ERROR_UNKNOWN; - } + if (*e || value < 0) + return EC_ERROR_PARAM3; thermal_config[sensor_type].thresholds[THRESHOLD_COUNT + stepping_id] = value; @@ -322,11 +306,17 @@ static int command_fan_config(int argc, char **argv) return EC_SUCCESS; } -DECLARE_CONSOLE_COMMAND(thermalfan, command_fan_config); +DECLARE_CONSOLE_COMMAND(thermalfan, command_fan_config, + "sensortype [threshold_id rpm]", + "Get/set thermal threshold fan rpm", + NULL); static int command_thermal_auto_fan_ctrl(int argc, char **argv) { return thermal_toggle_auto_fan_ctrl(1); } -DECLARE_CONSOLE_COMMAND(autofan, command_thermal_auto_fan_ctrl); +DECLARE_CONSOLE_COMMAND(autofan, command_thermal_auto_fan_ctrl, + NULL, + "Enable thermal fan control", + NULL); |