Merge tag 'dm-pull-8aug21' of https://source.denx.de/u-boot/custodians/u-boot-dm

Use log subsystem for dm_warn()
Various minor bug fixes
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c
index 117d35a..3146dfd 100644
--- a/drivers/core/uclass.c
+++ b/drivers/core/uclass.c
@@ -146,6 +146,9 @@
 {
 	struct uclass *uc;
 
+	/* Immediately fail if driver model is not set up */
+	if (!gd->uclass_root)
+		return -EDEADLK;
 	*ucp = NULL;
 	uc = uclass_find(id);
 	if (!uc) {
diff --git a/drivers/core/util.c b/drivers/core/util.c
index 91e93b0..5be4ee7 100644
--- a/drivers/core/util.c
+++ b/drivers/core/util.c
@@ -11,17 +11,6 @@
 #include <linux/libfdt.h>
 #include <vsprintf.h>
 
-#if CONFIG_IS_ENABLED(DM_WARN)
-void dm_warn(const char *fmt, ...)
-{
-	va_list args;
-
-	va_start(args, fmt);
-	vprintf(fmt, args);
-	va_end(args);
-}
-#endif
-
 int list_count_items(struct list_head *head)
 {
 	struct list_head *node;
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index 2778818..da0c1bf 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -159,7 +159,8 @@
  *
  * @key: ID to look up
  * @ucp: Returns pointer to uclass (there is only one per ID)
- * @return 0 if OK, -ve on error
+ * @return 0 if OK, -EDEADLK if driver model is not yet inited, other -ve on
+ *	other error
  */
 int uclass_get(enum uclass_id key, struct uclass **ucp);
 
diff --git a/include/dm/util.h b/include/dm/util.h
index 138893c..c634e47 100644
--- a/include/dm/util.h
+++ b/include/dm/util.h
@@ -7,7 +7,7 @@
 #define __DM_UTIL_H
 
 #if CONFIG_IS_ENABLED(DM_WARN)
-void dm_warn(const char *fmt, ...);
+#define dm_warn(fmt...) log(LOGC_DM, LOGL_WARNING, ##fmt)
 #else
 static inline void dm_warn(const char *fmt, ...)
 {
diff --git a/test/dm/core.c b/test/dm/core.c
index 48e66b7..c9a7606 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -994,6 +994,7 @@
 	memset(&gd->uclass_root, '\0', sizeof(gd->uclass_root));
 
 	ut_asserteq_ptr(NULL, uclass_find(UCLASS_TEST));
+	ut_asserteq(-EDEADLK, uclass_get(UCLASS_TEST, &uc));
 
 	return 0;
 }
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index 1119e6b..d104f3c 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -425,7 +425,7 @@
 
         # Widen an array of ints with an int (should do nothing)
         prop = self.node.props['intarray']
-        prop2 = node2.props['intarray']
+        prop2 = node2.props['intval']
         self.assertEqual(Type.INT, prop.type)
         self.assertEqual(3, len(prop.value))
         prop.Widen(prop2)
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index 9871bb5..2493e52 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -136,7 +136,7 @@
             Commit-changes: 2
             - Changes only for this commit
 
-            Cover-changes: 4
+'            Cover-changes: 4
             - Some notes for the cover letter
 
             Cover-letter:
@@ -1293,3 +1293,24 @@
         self.assertEqual(terminal.PrintLine(
             '4 new responses available in patchwork (use -d to write them to a new branch)',
             None), next(lines))
+
+    def testInsertTags(self):
+        """Test inserting of review tags"""
+        msg = '''first line
+second line.'''
+        tags = [
+            'Reviewed-by: Bin Meng <bmeng.cn@gmail.com>',
+            'Tested-by: Bin Meng <bmeng.cn@gmail.com>'
+            ]
+        signoff = 'Signed-off-by: Simon Glass <sjg@chromium.com>'
+        tag_str = '\n'.join(tags)
+
+        new_msg = patchstream.insert_tags(msg, tags)
+        self.assertEqual(msg + '\n\n' + tag_str, new_msg)
+
+        new_msg = patchstream.insert_tags(msg + '\n', tags)
+        self.assertEqual(msg + '\n\n' + tag_str, new_msg)
+
+        msg += '\n\n' + signoff
+        new_msg = patchstream.insert_tags(msg, tags)
+        self.assertEqual(msg + '\n' + tag_str, new_msg)
diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index b960292..2439fb1 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -662,6 +662,7 @@
     out = []
     done = False
     emit_tags = False
+    emit_blank = False
     for line in msg.splitlines():
         if not done:
             signoff_match = RE_SIGNOFF.match(line)
@@ -672,9 +673,13 @@
                 out += tags_to_emit
                 emit_tags = False
                 done = True
+            emit_blank = not (signoff_match or tag_match)
+        else:
+            emit_blank = line
         out.append(line)
     if not done:
-        out.append('')
+        if emit_blank:
+            out.append('')
         out += tags_to_emit
     return '\n'.join(out)