diff mbox

PM: intel_powerclamp: off by one in start_power_clamp()

Message ID 20130124085122.GA3547@elgon.mountain (mailing list archive)
State Accepted, archived
Delegated to: Zhang Rui
Headers show

Commit Message

Dan Carpenter Jan. 24, 2013, 8:51 a.m. UTC
This value has already been clamped correctly to 0 through 49 in
powerclamp_set_cur_state() so this patch doesn't actually change
anything.  But we should fix it anyway for consistency.

set_target_ratio is used as an offset into an array with
MAX_TARGET_RATIO (50) elements.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
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

Comments

Zhang Rui Feb. 4, 2013, 1:44 a.m. UTC | #1
On Thu, 2013-01-24 at 11:51 +0300, Dan Carpenter wrote:
> This value has already been clamped correctly to 0 through 49 in
> powerclamp_set_cur_state() so this patch doesn't actually change
> anything.  But we should fix it anyway for consistency.
> 
> set_target_ratio is used as an offset into an array with
> MAX_TARGET_RATIO (50) elements.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

applied to thermal-next.

BTW, Jacob, it would be good to get your comments on this as you're the
author of this driver.

thanks,
rui
> 
> diff --git a/drivers/thermal/intel_powerclamp.c b/drivers/thermal/intel_powerclamp.c
> index a85ff38..ab3ed90 100644
> --- a/drivers/thermal/intel_powerclamp.c
> +++ b/drivers/thermal/intel_powerclamp.c
> @@ -504,7 +504,7 @@ static int start_power_clamp(void)
>  		return -EINVAL;
>  	}
>  
> -	set_target_ratio = clamp(set_target_ratio, 0U, MAX_TARGET_RATIO);
> +	set_target_ratio = clamp(set_target_ratio, 0U, MAX_TARGET_RATIO - 1);
>  	/* prevent cpu hotplug */
>  	get_online_cpus();
>  


--
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/intel_powerclamp.c b/drivers/thermal/intel_powerclamp.c
index a85ff38..ab3ed90 100644
--- a/drivers/thermal/intel_powerclamp.c
+++ b/drivers/thermal/intel_powerclamp.c
@@ -504,7 +504,7 @@  static int start_power_clamp(void)
 		return -EINVAL;
 	}
 
-	set_target_ratio = clamp(set_target_ratio, 0U, MAX_TARGET_RATIO);
+	set_target_ratio = clamp(set_target_ratio, 0U, MAX_TARGET_RATIO - 1);
 	/* prevent cpu hotplug */
 	get_online_cpus();