diff mbox

[RFC,6/6] Thermal: step_wise: set next cooling target explicitly

Message ID 1371475468-5351-7-git-send-email-rui.zhang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Zhang Rui
Headers show

Commit Message

Zhang, Rui June 17, 2013, 1:24 p.m. UTC
Set the next target state explicitly for each thermal trend,
in step_wise governor, to provide more readability, and to
follow the cooling algorithm description strictly.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
 drivers/thermal/step_wise.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Eduardo Valentin July 2, 2013, 9:03 p.m. UTC | #1
On 17-06-2013 09:24, Zhang Rui wrote:
> Set the next target state explicitly for each thermal trend,
> in step_wise governor, to provide more readability, and to
> follow the cooling algorithm description strictly.


How about merging this one with patch 05?

> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> ---
>  drivers/thermal/step_wise.c |    9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
> index 53b56e6..ffa553f 100644
> --- a/drivers/thermal/step_wise.c
> +++ b/drivers/thermal/step_wise.c
> @@ -60,7 +60,6 @@ static unsigned long get_target_state(struct thermal_instance *instance,
>  	 * cdev in use to determine the next_target.
>  	 */
>  	cdev->ops->get_cur_state(cdev, &cur_state);
> -	next_target = instance->target;
>  
>  	switch (trend) {
>  	case THERMAL_TREND_RAISING:
> @@ -69,11 +68,14 @@ static unsigned long get_target_state(struct thermal_instance *instance,
>  				    (cur_state + 1) : instance->upper;
>  			if (next_target < instance->lower)
>  				next_target = instance->lower;
> -		}
> +		} else
> +			next_target = instance->target;
>  		break;
>  	case THERMAL_TREND_RAISE_FULL:
>  		if (throttle)
>  			next_target = instance->upper;
> +		else
> +			next_target = instance->target;
>  		break;
>  	case THERMAL_TREND_DROPPING:
>  		if (throttle) {
> @@ -99,7 +101,10 @@ static unsigned long get_target_state(struct thermal_instance *instance,
>  		break;
>  	case THERMAL_TREND_STABLE:
>  		/* Do nothing */
> +		next_target = instance->target;
> +		break;
>  	default:
> +		next_target = instance->target;
>  		break;


The above could be rewritten like this:
  	case THERMAL_TREND_STABLE:
  		/* Do nothing */
  	default:
 		next_target = instance->target;
  		break;

>  	}
>  
>
Eduardo Valentin July 2, 2013, 9:05 p.m. UTC | #2
On 17-06-2013 09:24, Zhang Rui wrote:
> Set the next target state explicitly for each thermal trend,
> in step_wise governor, to provide more readability, and to
> follow the cooling algorithm description strictly.


How about merging this one with patch 05?

> 
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> ---
>  drivers/thermal/step_wise.c |    9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
> index 53b56e6..ffa553f 100644
> --- a/drivers/thermal/step_wise.c
> +++ b/drivers/thermal/step_wise.c
> @@ -60,7 +60,6 @@ static unsigned long get_target_state(struct thermal_instance *instance,
>  	 * cdev in use to determine the next_target.
>  	 */
>  	cdev->ops->get_cur_state(cdev, &cur_state);
> -	next_target = instance->target;
>  
>  	switch (trend) {
>  	case THERMAL_TREND_RAISING:
> @@ -69,11 +68,14 @@ static unsigned long get_target_state(struct thermal_instance *instance,
>  				    (cur_state + 1) : instance->upper;
>  			if (next_target < instance->lower)
>  				next_target = instance->lower;
> -		}
> +		} else
> +			next_target = instance->target;
>  		break;
>  	case THERMAL_TREND_RAISE_FULL:
>  		if (throttle)
>  			next_target = instance->upper;
> +		else
> +			next_target = instance->target;
>  		break;
>  	case THERMAL_TREND_DROPPING:
>  		if (throttle) {
> @@ -99,7 +101,10 @@ static unsigned long get_target_state(struct thermal_instance *instance,
>  		break;
>  	case THERMAL_TREND_STABLE:
>  		/* Do nothing */
> +		next_target = instance->target;
> +		break;
>  	default:
> +		next_target = instance->target;
>  		break;


The above could be rewritten like this:
  	case THERMAL_TREND_STABLE:
  		/* Do nothing */
  	default:
 		next_target = instance->target;
  		break;

>  	}
>  
>
Zhang, Rui July 8, 2013, 2:34 a.m. UTC | #3
On Tue, 2013-07-02 at 17:03 -0400, Eduardo Valentin wrote:
> On 17-06-2013 09:24, Zhang Rui wrote:
> > Set the next target state explicitly for each thermal trend,
> > in step_wise governor, to provide more readability, and to
> > follow the cooling algorithm description strictly.
> 
> 
> How about merging this one with patch 05?
> 
> > 
> > Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> > ---
> >  drivers/thermal/step_wise.c |    9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
> > index 53b56e6..ffa553f 100644
> > --- a/drivers/thermal/step_wise.c
> > +++ b/drivers/thermal/step_wise.c
> > @@ -60,7 +60,6 @@ static unsigned long get_target_state(struct thermal_instance *instance,
> >  	 * cdev in use to determine the next_target.
> >  	 */
> >  	cdev->ops->get_cur_state(cdev, &cur_state);
> > -	next_target = instance->target;
> >  
> >  	switch (trend) {
> >  	case THERMAL_TREND_RAISING:
> > @@ -69,11 +68,14 @@ static unsigned long get_target_state(struct thermal_instance *instance,
> >  				    (cur_state + 1) : instance->upper;
> >  			if (next_target < instance->lower)
> >  				next_target = instance->lower;
> > -		}
> > +		} else
> > +			next_target = instance->target;
> >  		break;
> >  	case THERMAL_TREND_RAISE_FULL:
> >  		if (throttle)
> >  			next_target = instance->upper;
> > +		else
> > +			next_target = instance->target;
> >  		break;
> >  	case THERMAL_TREND_DROPPING:
> >  		if (throttle) {
> > @@ -99,7 +101,10 @@ static unsigned long get_target_state(struct thermal_instance *instance,
> >  		break;
> >  	case THERMAL_TREND_STABLE:
> >  		/* Do nothing */
> > +		next_target = instance->target;
> > +		break;
> >  	default:
> > +		next_target = instance->target;
> >  		break;
> 
> 
> The above could be rewritten like this:
>   	case THERMAL_TREND_STABLE:
>   		/* Do nothing */
>   	default:
>  		next_target = instance->target;
>   		break;
> 

sure I'm okay with your suggestion.
I wrote the code in this way because I want to keep the code follows the
description explicitly.

thanks,
rui
> >  	}
> >  
> > 
> 
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
index 53b56e6..ffa553f 100644
--- a/drivers/thermal/step_wise.c
+++ b/drivers/thermal/step_wise.c
@@ -60,7 +60,6 @@  static unsigned long get_target_state(struct thermal_instance *instance,
 	 * cdev in use to determine the next_target.
 	 */
 	cdev->ops->get_cur_state(cdev, &cur_state);
-	next_target = instance->target;
 
 	switch (trend) {
 	case THERMAL_TREND_RAISING:
@@ -69,11 +68,14 @@  static unsigned long get_target_state(struct thermal_instance *instance,
 				    (cur_state + 1) : instance->upper;
 			if (next_target < instance->lower)
 				next_target = instance->lower;
-		}
+		} else
+			next_target = instance->target;
 		break;
 	case THERMAL_TREND_RAISE_FULL:
 		if (throttle)
 			next_target = instance->upper;
+		else
+			next_target = instance->target;
 		break;
 	case THERMAL_TREND_DROPPING:
 		if (throttle) {
@@ -99,7 +101,10 @@  static unsigned long get_target_state(struct thermal_instance *instance,
 		break;
 	case THERMAL_TREND_STABLE:
 		/* Do nothing */
+		next_target = instance->target;
+		break;
 	default:
+		next_target = instance->target;
 		break;
 	}