From e158bd5422d9f506d094bf77c65644187fae3ab9 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Thu, 25 Oct 2012 12:16:33 -0700 Subject: Clean up a few modules in common/ Just code cleanup; no functional changes BUG=chrome-os-partner:15579 BRANCH=none TEST=build link and snow Change-Id: Ib62f805777994b39cd9f47a721f52529bb9399c5 Signed-off-by: Randall Spangler Reviewed-on: https://gerrit.chromium.org/gerrit/36573 Reviewed-by: Simon Glass --- common/eoption.c | 41 ++++++++++++++++++++++------------------- common/memory_commands.c | 2 -- common/port80.c | 8 +++----- include/eoption.h | 22 ++++++++++++++++++---- 4 files changed, 43 insertions(+), 30 deletions(-) diff --git a/common/eoption.c b/common/eoption.c index b4ecb457e2..38c329342e 100644 --- a/common/eoption.c +++ b/common/eoption.c @@ -27,16 +27,18 @@ enum block_offsets { OFFSET_BOOL0, }; - -/* Boolean options. Must be in the same order as enum eoption_bool, and must - * be terminated by an entry with a NULL name. */ +/* + * Boolean options. Must be in the same order as enum eoption_bool, and must + * be terminated by an entry with a NULL name. + */ static const struct eoption_bool_data bool_opts[] = { {OFFSET_BOOL0, (1 << 0), "bool_test"}, {0, 0, NULL}, }; - -/* Read a uint32_t from the specified EEPROM *word* offset. */ +/** + * Read a uint32_t from the specified EEPROM word offset. + */ static int read32(int offset, uint32_t *dest) { return eeprom_read(EEPROM_BLOCK_EOPTION, offset * 4, sizeof(uint32_t), @@ -44,14 +46,15 @@ static int read32(int offset, uint32_t *dest) } -/* Write a uint32_t to the specified EEPROM *word* offset. */ +/** + * Write a uint32_t to the specified EEPROM word offset. + */ static int write32(int offset, uint32_t v) { return eeprom_write(EEPROM_BLOCK_EOPTION, offset * 4, sizeof(v), (char *)&v); } - int eoption_get_bool(enum eoption_bool opt) { const struct eoption_bool_data *d = bool_opts + opt; @@ -61,7 +64,6 @@ int eoption_get_bool(enum eoption_bool opt) return v & d->mask ? 1 : 0; } - int eoption_set_bool(enum eoption_bool opt, int value) { const struct eoption_bool_data *d = bool_opts + opt; @@ -80,8 +82,11 @@ int eoption_set_bool(enum eoption_bool opt, int value) return write32(d->offset, v); } - -/* Find an option by name. Returns the option index, or -1 if no match. */ +/** + * Find an option by name. + * + * @return The option index, or -1 if no match. + */ static int find_option_by_name(const char *name, const struct eoption_bool_data *d) { @@ -98,10 +103,7 @@ static int find_option_by_name(const char *name, return -1; } -/*****************************************************************************/ -/* Initialization */ - -int eoption_init(void) +void eoption_init(void) { uint32_t v; int version; @@ -115,10 +117,12 @@ int eoption_init(void) version = (v >> 8) & 0xff; if (version == EOPTION_VERSION_CURRENT) - return EC_SUCCESS; + return; - /* TODO: should have a CRC if we start using this for real - * (non-debugging) options. */ + /* + * TODO: should have a CRC if we start using this for real + * (non-debugging) options. + */ /* Initialize fields which weren't set in previous versions */ if (version < 1) @@ -126,7 +130,7 @@ int eoption_init(void) /* Update the header */ v = (v & ~0xff00) | (EOPTION_VERSION_CURRENT << 8); - return write32(OFFSET_HEADER, v); + write32(OFFSET_HEADER, v); } /*****************************************************************************/ @@ -162,7 +166,6 @@ DECLARE_CONSOLE_COMMAND(optget, command_eoption_get, "Print EC option(s)", NULL); - static int command_eoption_set(int argc, char **argv) { char *e; diff --git a/common/memory_commands.c b/common/memory_commands.c index 46df50e74d..dae18777fd 100644 --- a/common/memory_commands.c +++ b/common/memory_commands.c @@ -8,7 +8,6 @@ #include "console.h" #include "util.h" - static int command_write_word(int argc, char **argv) { volatile uint32_t *address; @@ -38,7 +37,6 @@ DECLARE_CONSOLE_COMMAND(ww, command_write_word, "Write a word to memory", NULL); - static int command_read_word(int argc, char **argv) { volatile uint32_t *address; diff --git a/common/port80.c b/common/port80.c index 72b8ccde11..c23dc419b3 100644 --- a/common/port80.c +++ b/common/port80.c @@ -5,7 +5,7 @@ /* Port 80 module for Chrome EC */ -#include "board.h" +#include "common.h" #include "console.h" #include "host_command.h" #include "port80.h" @@ -16,7 +16,7 @@ #define HISTORY_LEN 256 static uint16_t history[HISTORY_LEN]; -static int writes; /* Number of port 80 writes so far */ +static int writes; /* Number of port 80 writes so far */ static int last_boot; /* Last code from previous boot */ static int scroll; static int print_in_int = 1; @@ -25,9 +25,7 @@ void port_80_write(int data) { /* * Note that this currently prints from inside the LPC interrupt - * itself. Probably not worth the system overhead to buffer the data - * and print it from a task, because we're printing a small amount of - * data and cprintf() doesn't block. + * itself. If you're dropping events, turn print_in_int off. */ if (print_in_int) CPRINTF("%c[%T Port 80: 0x%02x]", scroll ? '\n' : '\r', data); diff --git a/include/eoption.h b/include/eoption.h index 76b765505d..e1810f3f60 100644 --- a/include/eoption.h +++ b/include/eoption.h @@ -15,13 +15,27 @@ enum eoption_bool { EOPTION_BOOL_TEST = 0, /* Test option */ }; -/* Initialize the module. */ -int eoption_init(void); +/** + * Initialize the module. + */ +void eoption_init(void); -/* Return the current value of a boolean option. */ +/** + * Return the current value of a boolean option. + * + * @param opt Option to return + * @return 0 if option is false, 1 if true. + */ int eoption_get_bool(enum eoption_bool opt); -/* Set the value of a boolean option (0 = clear, non-zero=set). */ +/** + * Set the value of a boolean option + * + * @param opt Option to set + * @param value New value for option + * + * @return EC_SUCCESS, or non-zero if error. + */ int eoption_set_bool(enum eoption_bool opt, int value); #endif /* __CROS_EC_EOPTION_H */ -- cgit v1.2.1