All of lore.kernel.org
 help / color / mirror / Atom feed
* [Outreachy kernel] [PATCH] gpu: drm: nouveau: Use list_for_each_entry_from_reverse
@ 2018-03-27  9:11 ` Arushi Singhal
  0 siblings, 0 replies; 9+ messages in thread
From: Arushi Singhal @ 2018-03-27  9:11 UTC (permalink / raw)
  To: bskeggs; +Cc: David Airlie, dri-devel, nouveau, linux-kernel, outreachy-kernel

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 remove "cstate" variable as it is redundant in the code.

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
---
 drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
index 81c3567..5e56f74 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
@@ -113,7 +113,6 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
 {
 	struct nvkm_device *device = clk->subdev.device;
 	struct nvkm_volt *volt = device->volt;
-	struct nvkm_cstate *cstate;
 	int max_volt;
 
 	if (!pstate || !start)
@@ -133,13 +132,12 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
 		max_volt = min(max_volt,
 			       nvkm_volt_map(volt, volt->max2_id, clk->temp));
 
-	for (cstate = start; &cstate->head != &pstate->list;
-	     cstate = list_prev_entry(cstate, head)) {
-		if (nvkm_cstate_valid(clk, cstate, max_volt, clk->temp))
+	list_for_each_entry_from_reverse(start, &pstate->list, head) {
+		if (nvkm_cstate_valid(clk, start, max_volt, clk->temp))
 			break;
 	}
 
-	return cstate;
+	return start;
 }
 
 static struct nvkm_cstate *
-- 
2.7.4

-- 
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
To post to this group, send email to outreachy-kernel@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20180327091156.GA23787%40seema-Inspiron-15-3567.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH] gpu: drm: nouveau: Use list_for_each_entry_from_reverse
@ 2018-03-27  9:11 ` Arushi Singhal
  0 siblings, 0 replies; 9+ messages in thread
From: Arushi Singhal @ 2018-03-27  9:11 UTC (permalink / raw)
  To: bskeggs-H+wXaHxf7aLQT0dZR+AlfA
  Cc: David Airlie, nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, outreachy-kernel

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 remove "cstate" variable as it is redundant in the code.

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
---
 drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
index 81c3567..5e56f74 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
@@ -113,7 +113,6 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
 {
 	struct nvkm_device *device = clk->subdev.device;
 	struct nvkm_volt *volt = device->volt;
-	struct nvkm_cstate *cstate;
 	int max_volt;
 
 	if (!pstate || !start)
@@ -133,13 +132,12 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
 		max_volt = min(max_volt,
 			       nvkm_volt_map(volt, volt->max2_id, clk->temp));
 
-	for (cstate = start; &cstate->head != &pstate->list;
-	     cstate = list_prev_entry(cstate, head)) {
-		if (nvkm_cstate_valid(clk, cstate, max_volt, clk->temp))
+	list_for_each_entry_from_reverse(start, &pstate->list, head) {
+		if (nvkm_cstate_valid(clk, start, max_volt, clk->temp))
 			break;
 	}
 
-	return cstate;
+	return start;
 }
 
 static struct nvkm_cstate *
-- 
2.7.4

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH] gpu: drm: nouveau: Use list_for_each_entry_from_reverse
@ 2018-03-27  9:11 ` Arushi Singhal
  0 siblings, 0 replies; 9+ messages in thread
From: Arushi Singhal @ 2018-03-27  9:11 UTC (permalink / raw)
  To: bskeggs; +Cc: David Airlie, dri-devel, nouveau, linux-kernel, outreachy-kernel

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 remove "cstate" variable as it is redundant in the code.

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
---
 drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
index 81c3567..5e56f74 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
@@ -113,7 +113,6 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
 {
 	struct nvkm_device *device = clk->subdev.device;
 	struct nvkm_volt *volt = device->volt;
-	struct nvkm_cstate *cstate;
 	int max_volt;
 
 	if (!pstate || !start)
@@ -133,13 +132,12 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
 		max_volt = min(max_volt,
 			       nvkm_volt_map(volt, volt->max2_id, clk->temp));
 
-	for (cstate = start; &cstate->head != &pstate->list;
-	     cstate = list_prev_entry(cstate, head)) {
-		if (nvkm_cstate_valid(clk, cstate, max_volt, clk->temp))
+	list_for_each_entry_from_reverse(start, &pstate->list, head) {
+		if (nvkm_cstate_valid(clk, start, max_volt, clk->temp))
 			break;
 	}
 
-	return cstate;
+	return start;
 }
 
 static struct nvkm_cstate *
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Outreachy kernel] Re: [PATCH] gpu: drm: nouveau: Use list_for_each_entry_from_reverse
  2018-03-27  9:11 ` Arushi Singhal
  (?)
@ 2018-03-27  9:14   ` Ben Skeggs
  -1 siblings, 0 replies; 9+ messages in thread
From: Ben Skeggs @ 2018-03-27  9:14 UTC (permalink / raw)
  To: Arushi Singhal
  Cc: Ben Skeggs, David Airlie, nouveau, linux-kernel, dri-devel,
	outreachy-kernel

On 27 March 2018 at 19:11, Arushi Singhal
<arushisinghal19971997@gmail.com> wrote:
> 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 remove "cstate" variable as it is redundant in the code.
I would prefer to also see "start" renamed to "cstate" with this change.

Ben.

>
> Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
> ---
>  drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> index 81c3567..5e56f74 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> @@ -113,7 +113,6 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
>  {
>         struct nvkm_device *device = clk->subdev.device;
>         struct nvkm_volt *volt = device->volt;
> -       struct nvkm_cstate *cstate;
>         int max_volt;
>
>         if (!pstate || !start)
> @@ -133,13 +132,12 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
>                 max_volt = min(max_volt,
>                                nvkm_volt_map(volt, volt->max2_id, clk->temp));
>
> -       for (cstate = start; &cstate->head != &pstate->list;
> -            cstate = list_prev_entry(cstate, head)) {
> -               if (nvkm_cstate_valid(clk, cstate, max_volt, clk->temp))
> +       list_for_each_entry_from_reverse(start, &pstate->list, head) {
> +               if (nvkm_cstate_valid(clk, start, max_volt, clk->temp))
>                         break;
>         }
>
> -       return cstate;
> +       return start;
>  }
>
>  static struct nvkm_cstate *
> --
> 2.7.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
To post to this group, send email to outreachy-kernel@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/CACAvsv5Wzd6yFsweNXRNA93i5UeTX5qrb_xwPOeobqSjhLEMjg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] gpu: drm: nouveau: Use list_for_each_entry_from_reverse
@ 2018-03-27  9:14   ` Ben Skeggs
  0 siblings, 0 replies; 9+ messages in thread
From: Ben Skeggs @ 2018-03-27  9:14 UTC (permalink / raw)
  To: Arushi Singhal
  Cc: David Airlie, nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, outreachy-kernel,
	Ben Skeggs

On 27 March 2018 at 19:11, Arushi Singhal
<arushisinghal19971997@gmail.com> wrote:
> 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 remove "cstate" variable as it is redundant in the code.
I would prefer to also see "start" renamed to "cstate" with this change.

Ben.

>
> Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
> ---
>  drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> index 81c3567..5e56f74 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> @@ -113,7 +113,6 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
>  {
>         struct nvkm_device *device = clk->subdev.device;
>         struct nvkm_volt *volt = device->volt;
> -       struct nvkm_cstate *cstate;
>         int max_volt;
>
>         if (!pstate || !start)
> @@ -133,13 +132,12 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
>                 max_volt = min(max_volt,
>                                nvkm_volt_map(volt, volt->max2_id, clk->temp));
>
> -       for (cstate = start; &cstate->head != &pstate->list;
> -            cstate = list_prev_entry(cstate, head)) {
> -               if (nvkm_cstate_valid(clk, cstate, max_volt, clk->temp))
> +       list_for_each_entry_from_reverse(start, &pstate->list, head) {
> +               if (nvkm_cstate_valid(clk, start, max_volt, clk->temp))
>                         break;
>         }
>
> -       return cstate;
> +       return start;
>  }
>
>  static struct nvkm_cstate *
> --
> 2.7.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] gpu: drm: nouveau: Use list_for_each_entry_from_reverse
@ 2018-03-27  9:14   ` Ben Skeggs
  0 siblings, 0 replies; 9+ messages in thread
From: Ben Skeggs @ 2018-03-27  9:14 UTC (permalink / raw)
  To: Arushi Singhal
  Cc: Ben Skeggs, David Airlie, nouveau, linux-kernel, dri-devel,
	outreachy-kernel

On 27 March 2018 at 19:11, Arushi Singhal
<arushisinghal19971997@gmail.com> wrote:
> 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 remove "cstate" variable as it is redundant in the code.
I would prefer to also see "start" renamed to "cstate" with this change.

Ben.

>
> Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
> ---
>  drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> index 81c3567..5e56f74 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> @@ -113,7 +113,6 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
>  {
>         struct nvkm_device *device = clk->subdev.device;
>         struct nvkm_volt *volt = device->volt;
> -       struct nvkm_cstate *cstate;
>         int max_volt;
>
>         if (!pstate || !start)
> @@ -133,13 +132,12 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate,
>                 max_volt = min(max_volt,
>                                nvkm_volt_map(volt, volt->max2_id, clk->temp));
>
> -       for (cstate = start; &cstate->head != &pstate->list;
> -            cstate = list_prev_entry(cstate, head)) {
> -               if (nvkm_cstate_valid(clk, cstate, max_volt, clk->temp))
> +       list_for_each_entry_from_reverse(start, &pstate->list, head) {
> +               if (nvkm_cstate_valid(clk, start, max_volt, clk->temp))
>                         break;
>         }
>
> -       return cstate;
> +       return start;
>  }
>
>  static struct nvkm_cstate *
> --
> 2.7.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Outreachy kernel] Re: [PATCH] gpu: drm: nouveau: Use list_for_each_entry_from_reverse
@ 2018-03-27 11:29     ` Arushi Singhal
  0 siblings, 0 replies; 9+ messages in thread
From: Arushi Singhal @ 2018-03-27 11:29 UTC (permalink / raw)
  To: Ben Skeggs
  Cc: Ben Skeggs, David Airlie, nouveau, LKML, dri-devel, outreachy-kernel

[-- Attachment #1: Type: text/plain, Size: 2896 bytes --]

On Tue, Mar 27, 2018 at 2:44 PM, Ben Skeggs <skeggsb@gmail.com> wrote:

> On 27 March 2018 at 19:11, Arushi Singhal
> <arushisinghal19971997@gmail.com> wrote:
> > 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 remove "cstate" variable as it is redundant in the code.
> I would prefer to also see "start" renamed to "cstate" with this change.
>
Hello Ben

Yes, using cstate is more accurate, as most of the functions are using
"cstate" variable.

Best
Arushi

>
> Ben.
>
> >
> > Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
> > ---
> >  drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c | 8 +++-----
> >  1 file changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> > index 81c3567..5e56f74 100644
> > --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> > +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> > @@ -113,7 +113,6 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct
> nvkm_pstate *pstate,
> >  {
> >         struct nvkm_device *device = clk->subdev.device;
> >         struct nvkm_volt *volt = device->volt;
> > -       struct nvkm_cstate *cstate;
> >         int max_volt;
> >
> >         if (!pstate || !start)
> > @@ -133,13 +132,12 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct
> nvkm_pstate *pstate,
> >                 max_volt = min(max_volt,
> >                                nvkm_volt_map(volt, volt->max2_id,
> clk->temp));
> >
> > -       for (cstate = start; &cstate->head != &pstate->list;
> > -            cstate = list_prev_entry(cstate, head)) {
> > -               if (nvkm_cstate_valid(clk, cstate, max_volt, clk->temp))
> > +       list_for_each_entry_from_reverse(start, &pstate->list, head) {
> > +               if (nvkm_cstate_valid(clk, start, max_volt, clk->temp))
> >                         break;
> >         }
> >
> > -       return cstate;
> > +       return start;
> >  }
> >
> >  static struct nvkm_cstate *
> > --
> > 2.7.4
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
>

-- 
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
To post to this group, send email to outreachy-kernel@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/CA%2BXqjF_iDq1KXcKp2j_HYz3JBg%2BGgKvkVXQ8Y62r8jNiGhE8%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 4681 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] gpu: drm: nouveau: Use list_for_each_entry_from_reverse
@ 2018-03-27 11:29     ` Arushi Singhal
  0 siblings, 0 replies; 9+ messages in thread
From: Arushi Singhal @ 2018-03-27 11:29 UTC (permalink / raw)
  To: Ben Skeggs
  Cc: David Airlie, nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, LKML,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, outreachy-kernel,
	Ben Skeggs


[-- Attachment #1.1: Type: text/plain, Size: 2479 bytes --]

On Tue, Mar 27, 2018 at 2:44 PM, Ben Skeggs <skeggsb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> On 27 March 2018 at 19:11, Arushi Singhal
> <arushisinghal19971997-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > 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 remove "cstate" variable as it is redundant in the code.
> I would prefer to also see "start" renamed to "cstate" with this change.
>
Hello Ben

Yes, using cstate is more accurate, as most of the functions are using
"cstate" variable.

Best
Arushi

>
> Ben.
>
> >
> > Signed-off-by: Arushi Singhal <arushisinghal19971997-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > ---
> >  drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c | 8 +++-----
> >  1 file changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> > index 81c3567..5e56f74 100644
> > --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> > +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> > @@ -113,7 +113,6 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct
> nvkm_pstate *pstate,
> >  {
> >         struct nvkm_device *device = clk->subdev.device;
> >         struct nvkm_volt *volt = device->volt;
> > -       struct nvkm_cstate *cstate;
> >         int max_volt;
> >
> >         if (!pstate || !start)
> > @@ -133,13 +132,12 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct
> nvkm_pstate *pstate,
> >                 max_volt = min(max_volt,
> >                                nvkm_volt_map(volt, volt->max2_id,
> clk->temp));
> >
> > -       for (cstate = start; &cstate->head != &pstate->list;
> > -            cstate = list_prev_entry(cstate, head)) {
> > -               if (nvkm_cstate_valid(clk, cstate, max_volt, clk->temp))
> > +       list_for_each_entry_from_reverse(start, &pstate->list, head) {
> > +               if (nvkm_cstate_valid(clk, start, max_volt, clk->temp))
> >                         break;
> >         }
> >
> > -       return cstate;
> > +       return start;
> >  }
> >
> >  static struct nvkm_cstate *
> > --
> > 2.7.4
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
>

[-- Attachment #1.2: Type: text/html, Size: 3914 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] gpu: drm: nouveau: Use list_for_each_entry_from_reverse
@ 2018-03-27 11:29     ` Arushi Singhal
  0 siblings, 0 replies; 9+ messages in thread
From: Arushi Singhal @ 2018-03-27 11:29 UTC (permalink / raw)
  To: Ben Skeggs
  Cc: Ben Skeggs, David Airlie, nouveau, LKML, dri-devel, outreachy-kernel

[-- Attachment #1: Type: text/plain, Size: 2361 bytes --]

On Tue, Mar 27, 2018 at 2:44 PM, Ben Skeggs <skeggsb@gmail.com> wrote:

> On 27 March 2018 at 19:11, Arushi Singhal
> <arushisinghal19971997@gmail.com> wrote:
> > 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 remove "cstate" variable as it is redundant in the code.
> I would prefer to also see "start" renamed to "cstate" with this change.
>
Hello Ben

Yes, using cstate is more accurate, as most of the functions are using
"cstate" variable.

Best
Arushi

>
> Ben.
>
> >
> > Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
> > ---
> >  drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c | 8 +++-----
> >  1 file changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> > index 81c3567..5e56f74 100644
> > --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> > +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> > @@ -113,7 +113,6 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct
> nvkm_pstate *pstate,
> >  {
> >         struct nvkm_device *device = clk->subdev.device;
> >         struct nvkm_volt *volt = device->volt;
> > -       struct nvkm_cstate *cstate;
> >         int max_volt;
> >
> >         if (!pstate || !start)
> > @@ -133,13 +132,12 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct
> nvkm_pstate *pstate,
> >                 max_volt = min(max_volt,
> >                                nvkm_volt_map(volt, volt->max2_id,
> clk->temp));
> >
> > -       for (cstate = start; &cstate->head != &pstate->list;
> > -            cstate = list_prev_entry(cstate, head)) {
> > -               if (nvkm_cstate_valid(clk, cstate, max_volt, clk->temp))
> > +       list_for_each_entry_from_reverse(start, &pstate->list, head) {
> > +               if (nvkm_cstate_valid(clk, start, max_volt, clk->temp))
> >                         break;
> >         }
> >
> > -       return cstate;
> > +       return start;
> >  }
> >
> >  static struct nvkm_cstate *
> > --
> > 2.7.4
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
>

[-- Attachment #2: Type: text/html, Size: 3736 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-03-27 11:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-27  9:11 [Outreachy kernel] [PATCH] gpu: drm: nouveau: Use list_for_each_entry_from_reverse Arushi Singhal
2018-03-27  9:11 ` Arushi Singhal
2018-03-27  9:11 ` Arushi Singhal
2018-03-27  9:14 ` [Outreachy kernel] " Ben Skeggs
2018-03-27  9:14   ` Ben Skeggs
2018-03-27  9:14   ` Ben Skeggs
2018-03-27 11:29   ` [Outreachy kernel] " Arushi Singhal
2018-03-27 11:29     ` Arushi Singhal
2018-03-27 11:29     ` Arushi Singhal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.