diff mbox series

cpuidle: set poll_limit_ns out of if-else

Message ID 20210723182759.74491-1-pankaj.gupta.linux@gmail.com (mailing list archive)
State Rejected, archived
Headers show
Series cpuidle: set poll_limit_ns out of if-else | expand

Commit Message

Pankaj Gupta July 23, 2021, 6:27 p.m. UTC
From: Pankaj Gupta <pankaj.gupta@ionos.com>

 Since poll_limit_ns is being set at the end of both if and else statement.
 Moving and setting it out at one place.

Signed-off-by: Pankaj Gupta <pankaj.gupta@ionos.com>
---
 drivers/cpuidle/governors/haltpoll.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Rafael J. Wysocki Aug. 4, 2021, 5:22 p.m. UTC | #1
On Fri, Jul 23, 2021 at 8:28 PM Pankaj Gupta
<pankaj.gupta.linux@gmail.com> wrote:
>
> From: Pankaj Gupta <pankaj.gupta@ionos.com>
>
>  Since poll_limit_ns is being set at the end of both if and else statement.

But they are if () and else if (), so not really.

>  Moving and setting it out at one place.
>
> Signed-off-by: Pankaj Gupta <pankaj.gupta@ionos.com>
> ---
>  drivers/cpuidle/governors/haltpoll.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpuidle/governors/haltpoll.c b/drivers/cpuidle/governors/haltpoll.c
> index cb2a96eafc02..7d0e95bc94f3 100644
> --- a/drivers/cpuidle/governors/haltpoll.c
> +++ b/drivers/cpuidle/governors/haltpoll.c
> @@ -90,7 +90,6 @@ static void adjust_poll_limit(struct cpuidle_device *dev, u64 block_ns)
>                 if (val > guest_halt_poll_ns)
>                         val = guest_halt_poll_ns;
>
> -               dev->poll_limit_ns = val;
>         } else if (block_ns > guest_halt_poll_ns &&
>                    guest_halt_poll_allow_shrink) {
>                 unsigned int shrink = guest_halt_poll_shrink;
> @@ -100,8 +99,9 @@ static void adjust_poll_limit(struct cpuidle_device *dev, u64 block_ns)
>                         val = 0;
>                 else
>                         val /= shrink;
> -               dev->poll_limit_ns = val;
>         }
> +
> +       dev->poll_limit_ns = val;
>  }
>
>  /**
> --
> 2.25.1
>
Pankaj Gupta Aug. 4, 2021, 6:20 p.m. UTC | #2
> <pankaj.gupta.linux@gmail.com> wrote:
> >
> > From: Pankaj Gupta <pankaj.gupta@ionos.com>
> >
> >  Since poll_limit_ns is being set at the end of both if and else statement.
>
> But they are if () and else if (), so not really.

So sorry!

Thanks,
Pankaj
diff mbox series

Patch

diff --git a/drivers/cpuidle/governors/haltpoll.c b/drivers/cpuidle/governors/haltpoll.c
index cb2a96eafc02..7d0e95bc94f3 100644
--- a/drivers/cpuidle/governors/haltpoll.c
+++ b/drivers/cpuidle/governors/haltpoll.c
@@ -90,7 +90,6 @@  static void adjust_poll_limit(struct cpuidle_device *dev, u64 block_ns)
 		if (val > guest_halt_poll_ns)
 			val = guest_halt_poll_ns;
 
-		dev->poll_limit_ns = val;
 	} else if (block_ns > guest_halt_poll_ns &&
 		   guest_halt_poll_allow_shrink) {
 		unsigned int shrink = guest_halt_poll_shrink;
@@ -100,8 +99,9 @@  static void adjust_poll_limit(struct cpuidle_device *dev, u64 block_ns)
 			val = 0;
 		else
 			val /= shrink;
-		dev->poll_limit_ns = val;
 	}
+
+	dev->poll_limit_ns = val;
 }
 
 /**