summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/cmd_i2c.c1
-rw-r--r--common/cmd_itest.c2
-rw-r--r--common/cmd_portio.c2
-rw-r--r--include/common.h5
-rw-r--r--lib_generic/misc.c24
5 files changed, 29 insertions, 5 deletions
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c
index b699b2cb47..19e0bc70e3 100644
--- a/common/cmd_i2c.c
+++ b/common/cmd_i2c.c
@@ -130,7 +130,6 @@ static uchar i2c_no_probes[] = CFG_I2C_NOPROBES;
static int
mod_i2c_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char *argv[]);
-extern int cmd_get_data_size(char* arg, int default_size);
/*
* Syntax:
diff --git a/common/cmd_itest.c b/common/cmd_itest.c
index 8ad134f4a6..0aeef5a4ef 100644
--- a/common/cmd_itest.c
+++ b/common/cmd_itest.c
@@ -66,8 +66,6 @@ op_tbl_t op_table [] = {
#define op_tbl_size (sizeof(op_table)/sizeof(op_table[0]))
-extern int cmd_get_data_size(char* arg, int default_size);
-
static long evalexp(char *s, int w)
{
long l, *p;
diff --git a/common/cmd_portio.c b/common/cmd_portio.c
index d2e4c4b504..206a3f9a67 100644
--- a/common/cmd_portio.c
+++ b/common/cmd_portio.c
@@ -32,8 +32,6 @@
#if (CONFIG_COMMANDS & CFG_CMD_PORTIO)
-extern int cmd_get_data_size (char *arg, int default_size);
-
/* Display values from last command.
* Memory modify remembered values are different from display memory.
*/
diff --git a/include/common.h b/include/common.h
index c95573869c..531f6700fb 100644
--- a/include/common.h
+++ b/include/common.h
@@ -630,4 +630,9 @@ void show_boot_progress (int status);
#error Read section CONFIG_SKIP_LOWLEVEL_INIT in README.
#endif
+/* Reservoir for several functions in the code where
+ * previously no header file existed
+ */
+int cmd_get_data_size(char* arg, int default_size);
+
#endif /* __COMMON_H_ */
diff --git a/lib_generic/misc.c b/lib_generic/misc.c
new file mode 100644
index 0000000000..f1c85b2e75
--- /dev/null
+++ b/lib_generic/misc.c
@@ -0,0 +1,24 @@
+
+#include <common.h>
+
+int cmd_get_data_size(char* arg, int default_size)
+{
+ /* Check for a size specification .b, .w or .l.
+ */
+ int len = strlen(arg);
+ if (len > 2 && arg[len-2] == '.') {
+ switch(arg[len-1]) {
+ case 'b':
+ return 1;
+ case 'w':
+ return 2;
+ case 'l':
+ return 4;
+ case 's':
+ return -2;
+ default:
+ return -1;
+ }
+ }
+ return default_size;
+}