CHROMIUM: MALI: More properly handle missing regulators

The mali code makes some attempt to work without regulators but it's
definitely wonky.  Let's clean it up.  Specifically:

1. We'll use regulator_get() instead of regulator_get_optional().
   This causes the regulator framework to create a dummy regulator for
   us that we can safely enable/disable and is there specifically to
   avoid the need for special cases like this.  When the framework
   creates a dummy it nicely prints to the logs so you're aware of it,
   like: "ffa30000.gpu supply bogus not found, using dummy regulator"
2. We know regulator_get() won't return NULL so don't check for it.
   The old code wouldn't have worked right if regulator_get_optional()
   had returned NULL since the PTR_ERR() call below wouldn't have made
   sense.
3. In general we don't want to print about EPROBE_DEFER errors, so
   let's not do that.  ...and, in fact, now that we're using
   regulator_get() we no longer _expect_ any errors, so we end up
   totally inverting the old "if" test for when to print errors.
4. If a regulator is missing (or was replaced with a dummy) then
   dev_opp_table will fail to init.  When that happened we didn't
   crash but we'd keep spewing "core: dev_pm_opp_get_voltage_supply:
   Invalid supply index" all the time.  Let's fix it to just not init
   devfreq in this case since (I believe) devfreq makes no real sense
   without a regulator.

BUG=chromium:941638
TEST=devfreq works OK on veyron still
TEST=Add 'supply-names = "mali", "bogus";' to veyron and look at dmesg

Change-Id: Ie9b8b4d4281efaf738989a931e93abb513f37800
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1544030
diff --git a/drivers/gpu/arm/midgard/backend/gpu/mali_kbase_devfreq.c b/drivers/gpu/arm/midgard/backend/gpu/mali_kbase_devfreq.c
index 7fc4c5f..36147cd 100644
--- a/drivers/gpu/arm/midgard/backend/gpu/mali_kbase_devfreq.c
+++ b/drivers/gpu/arm/midgard/backend/gpu/mali_kbase_devfreq.c
@@ -385,6 +385,12 @@
 		return -ENODEV;
 	}
 
+	/* Can't do devfreq without this table */
+	if (!kbdev->dev_opp_table) {
+		dev_err(kbdev->dev, "Uninitialized devfreq opp table\n");
+		return -ENODEV;
+	}
+
 	kbdev->current_freq = clk_get_rate(kbdev->clock);
 	kbdev->current_nominal_freq = kbdev->current_freq;
 
diff --git a/drivers/gpu/arm/midgard/mali_kbase_core_linux.c b/drivers/gpu/arm/midgard/mali_kbase_core_linux.c
index 948a4a8..b25e70c 100644
--- a/drivers/gpu/arm/midgard/mali_kbase_core_linux.c
+++ b/drivers/gpu/arm/midgard/mali_kbase_core_linux.c
@@ -3175,17 +3175,13 @@
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 12, 0)) && defined(CONFIG_OF) \
 			&& defined(CONFIG_REGULATOR)
 	for (i = 0; i < kbdev->regulator_num; i++) {
-		kbdev->regulator[i] = regulator_get_optional(kbdev->dev, reg_names[i]);
-		if (IS_ERR_OR_NULL(kbdev->regulator[i])) {
+		kbdev->regulator[i] = regulator_get(kbdev->dev, reg_names[i]);
+		if (IS_ERR(kbdev->regulator[i])) {
 			err = PTR_ERR(kbdev->regulator[i]);
 			kbdev->regulator[i] = NULL;
-			if (err == -EPROBE_DEFER) {
+			if (err != -EPROBE_DEFER)
 				dev_err(&pdev->dev, "Failed to get regulator\n");
-				goto fail;
-			}
-			dev_info(kbdev->dev,
-				"Continuing without %s regulator control\n", reg_names[i]);
-			/* Allow probe to continue without regulator */
+			goto fail;
 		}
 	}
 #endif /* LINUX_VERSION_CODE >= 3, 12, 0 */
@@ -3212,7 +3208,7 @@
 	if (IS_ERR(kbdev->dev_opp_table)) {
 		err = PTR_ERR(kbdev->dev_opp_table);
 		kbdev->dev_opp_table = NULL;
-		dev_err(kbdev->dev, "Failed to set regulators for GPU err: %d\n",
+		dev_err(kbdev->dev, "Failed to init devfreq opp table: %d\n",
 			err);
 	}
 #endif /* CONFIG_REGULATOR */