diff mbox

devfreq_cooling: no need to check state with negative number

Message ID 1471853286-10432-1-git-send-email-shawn.lin@rock-chips.com (mailing list archive)
State Accepted, archived
Delegated to: Zhang Rui
Headers show

Commit Message

Shawn Lin Aug. 22, 2016, 8:08 a.m. UTC
We could see that state is defined as unsigned type, so it
should never be less than zero. Let' remove this check.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/thermal/devfreq_cooling.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Chanwoo Choi Aug. 23, 2016, 5:08 a.m. UTC | #1
Hi,

On 2016년 08월 22일 17:08, Shawn Lin wrote:
> We could see that state is defined as unsigned type, so it
> should never be less than zero. Let' remove this check.
> 
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
> 
>  drivers/thermal/devfreq_cooling.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c
> index 01f0015..81631b1 100644
> --- a/drivers/thermal/devfreq_cooling.c
> +++ b/drivers/thermal/devfreq_cooling.c
> @@ -312,7 +312,7 @@ static int devfreq_cooling_state2power(struct thermal_cooling_device *cdev,
>  	unsigned long freq;
>  	u32 static_power;
>  
> -	if (state < 0 || state >= dfc->freq_table_size)
> +	if (state >= dfc->freq_table_size)
>  		return -EINVAL;
>  
>  	freq = dfc->freq_table[state];
> 

As the description, the 'state' variable is unsigned type.

Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Zhang Rui Aug. 24, 2016, 6:10 a.m. UTC | #2
On 二, 2016-08-23 at 14:08 +0900, Chanwoo Choi wrote:
> Hi,
> 
> On 2016년 08월 22일 17:08, Shawn Lin wrote:
> > 
> > We could see that state is defined as unsigned type, so it
> > should never be less than zero. Let' remove this check.
> > 
> > Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> > ---
> > 
> >  drivers/thermal/devfreq_cooling.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/thermal/devfreq_cooling.c
> > b/drivers/thermal/devfreq_cooling.c
> > index 01f0015..81631b1 100644
> > --- a/drivers/thermal/devfreq_cooling.c
> > +++ b/drivers/thermal/devfreq_cooling.c
> > @@ -312,7 +312,7 @@ static int devfreq_cooling_state2power(struct
> > thermal_cooling_device *cdev,
> >  	unsigned long freq;
> >  	u32 static_power;
> >  
> > -	if (state < 0 || state >= dfc->freq_table_size)
> > +	if (state >= dfc->freq_table_size)
> >  		return -EINVAL;
> >  
> >  	freq = dfc->freq_table[state];
> > 
> As the description, the 'state' variable is unsigned type.
> 
> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
> 
Patch applied.

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/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c
index 01f0015..81631b1 100644
--- a/drivers/thermal/devfreq_cooling.c
+++ b/drivers/thermal/devfreq_cooling.c
@@ -312,7 +312,7 @@  static int devfreq_cooling_state2power(struct thermal_cooling_device *cdev,
 	unsigned long freq;
 	u32 static_power;
 
-	if (state < 0 || state >= dfc->freq_table_size)
+	if (state >= dfc->freq_table_size)
 		return -EINVAL;
 
 	freq = dfc->freq_table[state];