diff options
author | Randall Spangler <rspangler@chromium.org> | 2012-05-18 16:59:26 -0700 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2012-05-21 09:17:51 -0700 |
commit | 01e94792e7436e89e55f043982e9446e0759bf25 (patch) | |
tree | 8e8dc705a825391449041b81ec061d767231fb91 /chip | |
parent | b1bb8314bd852dea40bc7514486ce4e781e14f88 (diff) | |
download | chrome-ec-01e94792e7436e89e55f043982e9446e0759bf25.tar.gz |
Clean up debug commands to use less space
BUG=none
TEST=(run the commands)
Change-Id: I6ed4aee169311825190bcc386b86cdc32ba0866a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r-- | chip/lm4/adc.c | 2 | ||||
-rw-r--r-- | chip/lm4/clock.c | 2 | ||||
-rw-r--r-- | chip/lm4/eeprom.c | 80 | ||||
-rw-r--r-- | chip/lm4/i2c.c | 25 | ||||
-rw-r--r-- | chip/lm4/peci.c | 5 |
5 files changed, 43 insertions, 71 deletions
diff --git a/chip/lm4/adc.c b/chip/lm4/adc.c index d265d0f283..fa1d06e2b8 100644 --- a/chip/lm4/adc.c +++ b/chip/lm4/adc.c @@ -177,6 +177,7 @@ DECLARE_IRQ(LM4_IRQ_ADC0_SS3, ss3_interrupt, 2); /*****************************************************************************/ /* Console commands */ +#ifdef CONSOLE_COMMAND_ECTEMP static int command_ectemp(int argc, char **argv) { int t = adc_read_channel(ADC_CH_EC_TEMP); @@ -184,6 +185,7 @@ static int command_ectemp(int argc, char **argv) return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(ectemp, command_ectemp); +#endif static int command_adc(int argc, char **argv) diff --git a/chip/lm4/clock.c b/chip/lm4/clock.c index aaa2e9403c..e709fa0b62 100644 --- a/chip/lm4/clock.c +++ b/chip/lm4/clock.c @@ -214,7 +214,7 @@ static int command_pll(int argc, char **argv) /* Disable PLL and set extra divider */ char *e; div = strtoi(argv[1], &e, 10); - if (e && *e) + if (*e) return EC_ERROR_INVAL; LM4_SYSTEM_RCC = LM4_SYSTEM_RCC_SYSDIV(div - 1) | diff --git a/chip/lm4/eeprom.c b/chip/lm4/eeprom.c index f5783ad664..3490e6d183 100644 --- a/chip/lm4/eeprom.c +++ b/chip/lm4/eeprom.c @@ -119,9 +119,9 @@ int eeprom_hide(int block) static int command_eeprom_info(int argc, char **argv) { - ccprintf("EEPROM: %d blocks of %d bytes\n", - eeprom_get_block_count(), eeprom_get_block_size()); - ccprintf(" Block-hide flags: 0x%08x\n", LM4_EEPROM_EEHIDE); + ccprintf("%d blocks @ %d bytes, hide=0x%08x\n", + eeprom_get_block_count(), eeprom_get_block_size(), + LM4_EEPROM_EEHIDE); return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(eeinfo, command_eeprom_info); @@ -135,28 +135,22 @@ static int command_eeprom_read(int argc, char **argv) int rv; uint32_t d; - if (argc < 2) { - ccputs("Usage: eeread <block> [offset]\n"); - return EC_ERROR_UNKNOWN; - } + if (argc < 2) + return EC_ERROR_INVAL; block = strtoi(argv[1], &e, 0); - if (*e) { - ccputs("Invalid block\n"); - return EC_ERROR_UNKNOWN; - } + if (*e) + return EC_ERROR_INVAL; if (argc > 2) { offset = strtoi(argv[2], &e, 0); - if (*e) { - ccputs("Invalid offset\n"); - return EC_ERROR_UNKNOWN; - } + if (*e) + return EC_ERROR_INVAL; } rv = eeprom_read(block, offset, sizeof(d), (char *)&d); if (rv == EC_SUCCESS) - ccprintf("Block %d offset %d = 0x%08x\n", block, offset, d); + ccprintf("%d:%d = 0x%08x\n", block, offset, d); return rv; } DECLARE_CONSOLE_COMMAND(eeread, command_eeprom_read); @@ -167,63 +161,45 @@ static int command_eeprom_write(int argc, char **argv) int block = 0; int offset = 0; char *e; - int rv; uint32_t d; - if (argc < 4) { - ccputs("Usage: eeread <block> <offset> <data>\n"); - return EC_ERROR_UNKNOWN; - } + if (argc < 4) + return EC_ERROR_INVAL; block = strtoi(argv[1], &e, 0); - if (*e) { - ccputs("Invalid block\n"); - return EC_ERROR_UNKNOWN; - } + if (*e) + return EC_ERROR_INVAL; offset = strtoi(argv[2], &e, 0); - if (*e) { - ccputs("Invalid offset\n"); - return EC_ERROR_UNKNOWN; - } + if (*e) + return EC_ERROR_INVAL; d = strtoi(argv[3], &e, 0); - if (*e) { - ccputs("Invalid data\n"); - return EC_ERROR_UNKNOWN; - } + if (*e) + return EC_ERROR_INVAL; - ccprintf("Writing 0x%08x to block %d offset %d...\n", d, block, offset); - rv = eeprom_write(block, offset, sizeof(d), (char *)&d); - if (rv == EC_SUCCESS) - ccputs("done.\n"); - return rv; + ccprintf("Writing 0x%08x to %d:%d...\n", d, block, offset); + return eeprom_write(block, offset, sizeof(d), (char *)&d); } DECLARE_CONSOLE_COMMAND(eewrite, command_eeprom_write); +#ifdef CONSOLE_COMMAND_EEHIDE static int command_eeprom_hide(int argc, char **argv) { int block = 0; char *e; - int rv; - if (argc < 2) { - ccputs("Usage: eehide <block>\n"); - return EC_ERROR_UNKNOWN; - } + if (argc < 2) + return EC_ERROR_INVAL; block = strtoi(argv[1], &e, 0); - if (*e) { - ccputs("Invalid block\n"); - return EC_ERROR_UNKNOWN; - } + if (*e) + return EC_ERROR_INVAL; - ccprintf("Hiding EEPROM block %d...\n", block); - rv = eeprom_hide(block); - if (rv == EC_SUCCESS) - ccprintf("Done.\n"); - return rv; + ccprintf("Hiding block %d\n", block); + return eeprom_hide(block); } DECLARE_CONSOLE_COMMAND(eehide, command_eeprom_hide); +#endif /*****************************************************************************/ diff --git a/chip/lm4/i2c.c b/chip/lm4/i2c.c index 06ccb07f59..1ebab481e8 100644 --- a/chip/lm4/i2c.c +++ b/chip/lm4/i2c.c @@ -34,6 +34,7 @@ static task_id_t task_waiting_on_port[NUM_PORTS]; static struct mutex port_mutex[NUM_PORTS]; extern const struct i2c_port_t i2c_ports[I2C_PORTS_USED]; + static int wait_idle(int port) { int i; @@ -241,10 +242,9 @@ int i2c_read_string(int port, int slave_addr, int offset, uint8_t *data, reg = offset; /* Send device reg space offset, and read back block length. - * Keep this session open without a stop - */ + * Keep this session open without a stop */ rv = i2c_transmit_receive(port, slave_addr, ®, 1, &block_length, 1, - START, NO_STOP); + START, NO_STOP); if (rv) goto exit; @@ -252,7 +252,7 @@ int i2c_read_string(int port, int slave_addr, int offset, uint8_t *data, block_length = len - 1; rv = i2c_transmit_receive(port, slave_addr, 0, 0, data, block_length, - NO_START, STOP); + NO_START, STOP); data[block_length] = 0; exit: @@ -313,7 +313,7 @@ static void scan_bus(int port, const char *desc) int rv; int a; - ccprintf("Scanning %s I2C bus (%d)...\n", desc, port); + ccprintf("Scanning %d %s\n", desc, port); mutex_lock(port_mutex + port); @@ -325,11 +325,10 @@ static void scan_bus(int port, const char *desc) LM4_I2C_MCS(port) = 0x07; rv = wait_idle(port); if (rv == EC_SUCCESS) - ccprintf("\nFound device at 8-bit addr 0x%02x\n", a); -} + ccprintf("0x%02x\n", a); + } mutex_unlock(port_mutex + port); - ccputs("\n"); } @@ -341,16 +340,12 @@ static int command_i2cread(int argc, char **argv) int rv; int d, i; - if (argc < 3) { - ccputs("Usage: i2cread <port> <addr> [count]\n"); - return EC_ERROR_UNKNOWN; - } + if (argc < 3) + return EC_ERROR_INVAL; port = strtoi(argv[1], &e, 0); - if (*e) { - ccputs("Invalid port\n"); + if (*e) return EC_ERROR_INVAL; - } for (i = 0; i < I2C_PORTS_USED && port != i2c_ports[i].port; i++) ; diff --git a/chip/lm4/peci.c b/chip/lm4/peci.c index 6bbdaa832c..88f3f95b6e 100644 --- a/chip/lm4/peci.c +++ b/chip/lm4/peci.c @@ -101,11 +101,10 @@ static int command_peci_temp(int argc, char **argv) { int t = peci_get_cpu_temp(); if (t == -1) { - ccputs("Error reading CPU temperature via PECI\n"); - ccprintf("Error code = 0x%04x\n", LM4_PECI_M0D0 & 0xffff); + ccprintf("PECI error 0x%04x\n", LM4_PECI_M0D0 & 0xffff); return EC_ERROR_UNKNOWN; } - ccprintf("Current CPU temperature = %d K = %d C\n", t, t - 273); + ccprintf("CPU temp = %d K = %d C\n", t, t - 273); return EC_SUCCESS; } DECLARE_CONSOLE_COMMAND(pecitemp, command_peci_temp); |