[Nouveau] [PATCH 06/32] clk: Add NVKM_CLK_PSTATE_BOOT

Karol Herbst karolherbst at gmail.com
Fri Nov 17 00:04:10 UTC 2017


From: Karol Herbst <kherbst at redhat.com>

It is better using a constant than -1.

Signed-off-by: Karol Herbst <kherbst at redhat.com>
---
 drm/nouveau/include/nvkm/subdev/clk.h |  2 ++
 drm/nouveau/nvkm/subdev/clk/base.c    | 10 +++++-----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drm/nouveau/include/nvkm/subdev/clk.h b/drm/nouveau/include/nvkm/subdev/clk.h
index 1f4fa5f5..d77843f5 100644
--- a/drm/nouveau/include/nvkm/subdev/clk.h
+++ b/drm/nouveau/include/nvkm/subdev/clk.h
@@ -6,6 +6,8 @@
 struct nvbios_pll;
 struct nvkm_pll_vals;
 
+#define NVKM_CLK_PSTATE_BOOT    -1 /* POSTed default */
+
 #define NVKM_CLK_CSTATE_DEFAULT -1 /* POSTed default */
 #define NVKM_CLK_CSTATE_BASE    -2 /* pstate base */
 #define NVKM_CLK_CSTATE_HIGHEST -3 /* highest possible */
diff --git a/drm/nouveau/nvkm/subdev/clk/base.c b/drm/nouveau/nvkm/subdev/clk/base.c
index 77a0624a..96a09575 100644
--- a/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drm/nouveau/nvkm/subdev/clk/base.c
@@ -313,12 +313,12 @@ nvkm_pstate_work(struct work_struct *work)
 		   clk->astate, clk->temp, clk->dstate);
 
 	pstate_idx = clk->pwrsrc ? clk->ustate_ac : clk->ustate_dc;
-	if (clk->state_nr && pstate_idx != -1) {
+	if (clk->state_nr && pstate_idx != NVKM_CLK_PSTATE_BOOT) {
 		pstate_idx = (pstate_idx < 0) ? clk->astate : pstate_idx;
 		pstate_idx = min(pstate_idx, clk->state_nr - 1);
 		pstate_idx = max(pstate_idx, clk->dstate);
 	} else {
-		pstate_idx = clk->pstate_idx = -1;
+		pstate_idx = clk->pstate_idx = NVKM_CLK_PSTATE_BOOT;
 	}
 
 	nvkm_trace(subdev, "-> %d\n", pstate_idx);
@@ -618,7 +618,7 @@ nvkm_clk_init(struct nvkm_subdev *subdev)
 
 	clk->astate = clk->state_nr - 1;
 	clk->dstate = 0;
-	clk->pstate_idx = -1;
+	clk->pstate_idx = NVKM_CLK_PSTATE_BOOT;
 	clk->temp = 90; /* reasonable default value */
 	nvkm_pstate_calc(clk, true);
 	return 0;
@@ -673,8 +673,8 @@ nvkm_clk_ctor(const struct nvkm_clk_func *func, struct nvkm_device *device,
 	clk->func = func;
 	INIT_LIST_HEAD(&clk->states);
 	clk->domains = func->domains;
-	clk->ustate_ac = -1;
-	clk->ustate_dc = -1;
+	clk->ustate_ac = NVKM_CLK_PSTATE_BOOT;
+	clk->ustate_dc = NVKM_CLK_PSTATE_BOOT;
 	clk->allow_reclock = allow_reclock;
 
 	INIT_WORK(&clk->work, nvkm_pstate_work);
-- 
2.15.0



More information about the Nouveau mailing list