Commit dd3b89be authored by Arushi Singhal's avatar Arushi Singhal Committed by Ben Skeggs

drm/nouveau/clk: Use list_for_each_entry_from_reverse

It's better to use "list_for_each_entry_from_reverse" for iterating list
than "for loop" as it makes the code more clear to read.
This patch replace "for loop" with "list_for_each_entry_from_reverse"
and "start" variable with "cstate" which helps in refactoring
the code and also "cstate" variable is more commonly used in the other
functions.

changes in v2:
"start" variable is removed, before "cstate" variable was removed
but "cstate" is more common so preferred "cstate" over "start".
Signed-off-by: default avatarArushi Singhal <arushisinghal19971997@gmail.com>
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 7a22c737
...@@ -109,18 +109,17 @@ nvkm_cstate_valid(struct nvkm_clk *clk, struct nvkm_cstate *cstate, ...@@ -109,18 +109,17 @@ nvkm_cstate_valid(struct nvkm_clk *clk, struct nvkm_cstate *cstate,
static struct nvkm_cstate * static struct nvkm_cstate *
nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate, nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
struct nvkm_cstate *start) struct nvkm_cstate *cstate)
{ {
struct nvkm_device *device = clk->subdev.device; struct nvkm_device *device = clk->subdev.device;
struct nvkm_volt *volt = device->volt; struct nvkm_volt *volt = device->volt;
struct nvkm_cstate *cstate;
int max_volt; int max_volt;
if (!pstate || !start) if (!pstate || !cstate)
return NULL; return NULL;
if (!volt) if (!volt)
return start; return cstate;
max_volt = volt->max_uv; max_volt = volt->max_uv;
if (volt->max0_id != 0xff) if (volt->max0_id != 0xff)
...@@ -133,8 +132,7 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate, ...@@ -133,8 +132,7 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
max_volt = min(max_volt, max_volt = min(max_volt,
nvkm_volt_map(volt, volt->max2_id, clk->temp)); nvkm_volt_map(volt, volt->max2_id, clk->temp));
for (cstate = start; &cstate->head != &pstate->list; list_for_each_entry_from_reverse(cstate, &pstate->list, head) {
cstate = list_prev_entry(cstate, head)) {
if (nvkm_cstate_valid(clk, cstate, max_volt, clk->temp)) if (nvkm_cstate_valid(clk, cstate, max_volt, clk->temp))
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment