gpu: ion: Make ion heap error handling consistent

If an error occurs during heap creation the behavior is different
depending on the error condition. If memory cannot be allocated
for the heap the rest of the heaps will be created. However, if
the ion heap cannot be created heap creation stops and all the heaps
are destroyed. Make the error handling consistent for both error
conditions by logging an error message and continuing creation
of the rest of the heaps.

General cleanup: Change global variables to be local to this
translation unit.

Change-Id: Ia8d2fb2f3257b91d6423b6722e12e9b3d7792e86
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
diff --git a/drivers/gpu/ion/msm/msm_ion.c b/drivers/gpu/ion/msm/msm_ion.c
index 8b45b3a..54dd056 100644
--- a/drivers/gpu/ion/msm/msm_ion.c
+++ b/drivers/gpu/ion/msm/msm_ion.c
@@ -19,9 +19,9 @@
 #include <mach/msm_memtypes.h>
 #include "../ion_priv.h"
 
-struct ion_device *idev;
-int num_heaps;
-struct ion_heap **heaps;
+static struct ion_device *idev;
+static int num_heaps;
+static struct ion_heap **heaps;
 
 struct ion_client *msm_ion_client_create(unsigned int heap_mask,
 					const char *name)
@@ -83,19 +83,17 @@
 
 		heaps[i] = ion_heap_create(heap_data);
 		if (IS_ERR_OR_NULL(heaps[i])) {
-			err = PTR_ERR(heaps[i]);
-			goto heapdestroy;
+			pr_err("%s: could not create ion heap %s"
+				" (id %x)\n", __func__, heap_data->name,
+				heap_data->id);
+			heaps[i] = 0;
+			continue;
 		}
 		ion_device_add_heap(idev, heaps[i]);
 	}
 	platform_set_drvdata(pdev, idev);
 	return 0;
 
-heapdestroy:
-	for (i = 0; i < num_heaps; i++) {
-		if (!IS_ERR_OR_NULL(heaps[i]))
-			ion_heap_destroy(heaps[i]);
-	}
 freeheaps:
 	kfree(heaps);
 out: