binman: Move problem-checking code into a function

This has become quite long, so move it into a separate function.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/binman/control.py b/tools/binman/control.py
index 2f00279..a233c77 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -617,6 +617,50 @@
         dtb_item.Flush()
     return images
 
+def CheckForProblems(image):
+    """Check for problems with image generation
+
+    Shows warning about missing, faked or optional external blobs, as well as
+    missing bintools.
+
+    Args:
+        image (Image): Image to process
+
+    Returns:
+        bool: True if there are any problems which result in a non-functional
+            image
+    """
+    missing_list = []
+    image.CheckMissing(missing_list)
+    if missing_list:
+        tout.error("Image '%s' is missing external blobs and is non-functional: %s\n" %
+                   (image.name, ' '.join([e.name for e in missing_list])))
+        _ShowHelpForMissingBlobs(tout.ERROR, missing_list)
+
+    faked_list = []
+    image.CheckFakedBlobs(faked_list)
+    if faked_list:
+        tout.warning(
+            "Image '%s' has faked external blobs and is non-functional: %s\n" %
+            (image.name, ' '.join([os.path.basename(e.GetDefaultFilename())
+                                   for e in faked_list])))
+
+    optional_list = []
+    image.CheckOptional(optional_list)
+    if optional_list:
+        tout.warning(
+            "Image '%s' is missing optional external blobs but is still functional: %s\n" %
+            (image.name, ' '.join([e.name for e in optional_list])))
+        _ShowHelpForMissingBlobs(tout.WARNING, optional_list)
+
+    missing_bintool_list = []
+    image.check_missing_bintools(missing_bintool_list)
+    if missing_bintool_list:
+        tout.warning(
+            "Image '%s' has missing bintools and is non-functional: %s\n" %
+            (image.name, ' '.join([os.path.basename(bintool.name)
+                                   for bintool in missing_bintool_list])))
+    return any([missing_list, faked_list, missing_bintool_list])
 
 def ProcessImage(image, update_fdt, write_map, get_contents=True,
                  allow_resize=True, allow_missing=False,
@@ -689,38 +733,8 @@
     if write_map:
         image.WriteMap()
 
-    missing_list = []
-    image.CheckMissing(missing_list)
-    if missing_list:
-        tout.error("Image '%s' is missing external blobs and is non-functional: %s\n" %
-                   (image.name, ' '.join([e.name for e in missing_list])))
-        _ShowHelpForMissingBlobs(tout.ERROR, missing_list)
-
-    faked_list = []
-    image.CheckFakedBlobs(faked_list)
-    if faked_list:
-        tout.warning(
-            "Image '%s' has faked external blobs and is non-functional: %s\n" %
-            (image.name, ' '.join([os.path.basename(e.GetDefaultFilename())
-                                   for e in faked_list])))
-
-    optional_list = []
-    image.CheckOptional(optional_list)
-    if optional_list:
-        tout.warning(
-            "Image '%s' is missing optional external blobs but is still functional: %s\n" %
-            (image.name, ' '.join([e.name for e in optional_list])))
-        _ShowHelpForMissingBlobs(tout.WARNING, optional_list)
-
-    missing_bintool_list = []
-    image.check_missing_bintools(missing_bintool_list)
-    if missing_bintool_list:
-        tout.warning(
-            "Image '%s' has missing bintools and is non-functional: %s\n" %
-            (image.name, ' '.join([os.path.basename(bintool.name)
-                                   for bintool in missing_bintool_list])))
-    return any([missing_list, faked_list, missing_bintool_list])
-
+    has_problems = CheckForProblems(image)
+    return has_problems
 
 def Binman(args):
     """The main control code for binman