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>
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 331eae2..577c60e 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -565,9 +565,11 @@
 {
 	if (!gd->fdt_blob || ((uintptr_t)gd->fdt_blob & 3) ||
 	    fdt_check_header(gd->fdt_blob)) {
-		printf("No valid FDT found - please append one to U-Boot "
-			"binary, use u-boot-dtb.bin or define "
-			"CONFIG_OF_EMBED. For sandbox, use -d <file.dtb>\n");
+#ifdef CONFIG_SPL_BUILD
+		puts("Missing DTB\n");
+#else
+		puts("No valid device tree binary found - please append one to U-Boot binary, use u-boot-dtb.bin or define CONFIG_OF_EMBED. For sandbox, use -d <file.dtb>\n");
+#endif
 		return -1;
 	}
 	return 0;
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index e0f2648..bedc865 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -842,13 +842,11 @@
 	return i;
 }
 
-void panic(const char *fmt, ...)
+static void panic_finish(void) __attribute__ ((noreturn));
+
+static void panic_finish(void)
 {
-	va_list args;
-	va_start(args, fmt);
-	vprintf(fmt, args);
 	putc('\n');
-	va_end(args);
 #if defined(CONFIG_PANIC_HANG)
 	hang();
 #else
@@ -859,6 +857,21 @@
 		;
 }
 
+void panic_str(const char *str)
+{
+	puts(str);
+	panic_finish();
+}
+
+void panic(const char *fmt, ...)
+{
+	va_list args;
+	va_start(args, fmt);
+	vprintf(fmt, args);
+	va_end(args);
+	panic_finish();
+}
+
 void __assert_fail(const char *assertion, const char *file, unsigned line,
 		   const char *function)
 {