[Nouveau] [RFC PATCH 28/29] clk: move the switch out of the loop in nvkm_cstate_valid

Karol Herbst
2017-09-15T17:11:28Z

drm/nouveau/nvkm/subdev/clk/base.c | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/drm/nouveau/nvkm/subdev/clk/base.c
b/drm/nouveau/nvkm/subdev/clk/base.c
index 2a51c078..994d32b9 100644
--- a/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drm/nouveau/nvkm/subdev/clk/base.c
@@ -83,28 +83,30 @@ nvkm_cstate_valid(struct nvkm_clk *clk, struct nvkm_cstate
*cstate,
 	const struct nvkm_domain *domain = clk->domains;
 	struct nvkm_volt *volt = clk->subdev.device->volt;
 	int voltage;
+	u32 limit;

-	while (domain && domain->name != nv_clk_src_max) {
-		if (domain->flags & NVKM_CLK_DOM_FLAG_VPSTATE) {
-			u32 freq = cstate->domain[domain->name];
-			u32 limit;
-			switch (clk->boost_mode) {
-			case NVKM_CLK_BOOST_NONE:
-				limit = clk->base_limit.max_khz;
-				if (limit)
-					break;
-			case NVKM_CLK_BOOST_BIOS:
-				limit = clk->boost_limit.max_khz;
-				break;
-			default:
-				limit = 0;
-				break;
-			}
+	switch (clk->boost_mode) {
+	case NVKM_CLK_BOOST_NONE:
+		limit = clk->base_limit.max_khz;
+		if (limit)
+			break;
+	case NVKM_CLK_BOOST_BIOS:
+		limit = clk->boost_limit.max_khz;
+		break;
+	default:
+		limit = 0;
+		break;
+	}

+	if (limit) {
+		for (; domain && domain->name != nv_clk_src_max; domain++) {
+			u32 freq;
+			if (!(domain->flags & NVKM_CLK_DOM_FLAG_VPSTATE))
+				continue;
+			freq = cstate->domain[domain->name];
 			if (limit && freq > limit)
 				return false;
 		}
-		domain++;
 	}

 	if (!volt)
--
2.14.1