dm: Add a panic_str() function to reduce code size

The printf() in panic() adds about 1.5KB of code size to SPL when compiled
with Thumb-2. Provide a smaller version that does not support printf()-style
arguments and use it in two commonly compiled places.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2015-02-27 22:06:32 -07:00
parent 7f9875e733
commit 66312374dc
4 changed files with 47 additions and 9 deletions

View file

@ -39,9 +39,32 @@ int strict_strtoul(const char *cp, unsigned int base, unsigned long *res);
unsigned long long simple_strtoull(const char *cp, char **endp,
unsigned int base);
long simple_strtol(const char *cp, char **endp, unsigned int base);
/**
* panic() - Print a message and reset/hang
*
* Prints a message on the console(s) and then resets. If CONFIG_PANIC_HANG is
* defined, then it will hang instead of reseting.
*
* @param fmt: printf() format string for message, which should not include
* \n, followed by arguments
*/
void panic(const char *fmt, ...)
__attribute__ ((format (__printf__, 1, 2), noreturn));
/**
* panic_str() - Print a message and reset/hang
*
* Prints a message on the console(s) and then resets. If CONFIG_PANIC_HANG is
* defined, then it will hang instead of reseting.
*
* This function can be used instead of panic() when your board does not
* already use printf(), * to keep code size small.
*
* @param fmt: string to display, which should not include \n
*/
void panic_str(const char *str) __attribute__ ((noreturn));
/**
* Format a string and place it in a buffer
*