linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] drivers: thermal: processor_thermal_device: fix missing bitwise-or operator
@ 2019-07-29 10:29 Colin King
  2019-07-29 11:24 ` walter harms
  0 siblings, 1 reply; 4+ messages in thread
From: Colin King @ 2019-07-29 10:29 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Srinivas Pandruvada,
	Rafael J . Wysocki, linux-pm
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The variable val is having the top 8 bits cleared and then the variable
is being re-assinged and setting just the top 8 bits.  I believe the
intention was bitwise-or in the top 8 bits.  Fix this by replacing
the = operator with |= instead.

Addresses-Coverity: ("Unused value")
Fixes: b0c74b08517e ("drivers: thermal: processor_thermal_device: Export sysfs inteface for TCC offset")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 .../thermal/intel/int340x_thermal/processor_thermal_device.c    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
index 6f6ac6a8e82d..cb22317911ef 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
@@ -164,7 +164,7 @@ static int tcc_offset_update(int tcc)
 		return err;
 
 	val = ~GENMASK_ULL(31, 24);
-	val = (tcc & 0xff) << 24;
+	val |= (tcc & 0xff) << 24;
 
 	err = wrmsrl_safe(MSR_IA32_TEMPERATURE_TARGET, val);
 	if (err)
-- 
2.20.1


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

* Re: [PATCH][next] drivers: thermal: processor_thermal_device: fix missing bitwise-or operator
  2019-07-29 10:29 [PATCH][next] drivers: thermal: processor_thermal_device: fix missing bitwise-or operator Colin King
@ 2019-07-29 11:24 ` walter harms
  2019-07-29 11:29   ` Colin Ian King
  0 siblings, 1 reply; 4+ messages in thread
From: walter harms @ 2019-07-29 11:24 UTC (permalink / raw)
  To: Colin King
  Cc: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Srinivas Pandruvada,
	Rafael J . Wysocki, linux-pm, kernel-janitors, linux-kernel



Am 29.07.2019 12:29, schrieb Colin King:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The variable val is having the top 8 bits cleared and then the variable
> is being re-assinged and setting just the top 8 bits.  I believe the
> intention was bitwise-or in the top 8 bits.  Fix this by replacing
> the = operator with |= instead.
> 
> Addresses-Coverity: ("Unused value")
> Fixes: b0c74b08517e ("drivers: thermal: processor_thermal_device: Export sysfs inteface for TCC offset")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  .../thermal/intel/int340x_thermal/processor_thermal_device.c    | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> index 6f6ac6a8e82d..cb22317911ef 100644
> --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> @@ -164,7 +164,7 @@ static int tcc_offset_update(int tcc)
>  		return err;
>  
>  	val = ~GENMASK_ULL(31, 24);
> -	val = (tcc & 0xff) << 24;
> +	val |= (tcc & 0xff) << 24;
>  

I do not think that GENMASK makes sence here.

re,
 wh

>  	err = wrmsrl_safe(MSR_IA32_TEMPERATURE_TARGET, val);
>  	if (err)

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

* Re: [PATCH][next] drivers: thermal: processor_thermal_device: fix missing bitwise-or operator
  2019-07-29 11:24 ` walter harms
@ 2019-07-29 11:29   ` Colin Ian King
  2019-07-29 11:50     ` Srinivas Pandruvada
  0 siblings, 1 reply; 4+ messages in thread
From: Colin Ian King @ 2019-07-29 11:29 UTC (permalink / raw)
  To: wharms
  Cc: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Srinivas Pandruvada,
	Rafael J . Wysocki, linux-pm, kernel-janitors, linux-kernel

On 29/07/2019 12:24, walter harms wrote:
> 
> 
> Am 29.07.2019 12:29, schrieb Colin King:
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> The variable val is having the top 8 bits cleared and then the variable
>> is being re-assinged and setting just the top 8 bits.  I believe the
>> intention was bitwise-or in the top 8 bits.  Fix this by replacing
>> the = operator with |= instead.
>>
>> Addresses-Coverity: ("Unused value")
>> Fixes: b0c74b08517e ("drivers: thermal: processor_thermal_device: Export sysfs inteface for TCC offset")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>  .../thermal/intel/int340x_thermal/processor_thermal_device.c    | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
>> index 6f6ac6a8e82d..cb22317911ef 100644
>> --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
>> +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
>> @@ -164,7 +164,7 @@ static int tcc_offset_update(int tcc)
>>  		return err;
>>  
>>  	val = ~GENMASK_ULL(31, 24);
>> -	val = (tcc & 0xff) << 24;
>> +	val |= (tcc & 0xff) << 24;
>>  
> 
> I do not think that GENMASK makes sence here.

Yeah, val &= ~GENMASK_ULL(31, 24)

I'll send a V2


> 
> re,
>  wh
> 
>>  	err = wrmsrl_safe(MSR_IA32_TEMPERATURE_TARGET, val);
>>  	if (err)


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

* Re: [PATCH][next] drivers: thermal: processor_thermal_device: fix missing bitwise-or operator
  2019-07-29 11:29   ` Colin Ian King
@ 2019-07-29 11:50     ` Srinivas Pandruvada
  0 siblings, 0 replies; 4+ messages in thread
From: Srinivas Pandruvada @ 2019-07-29 11:50 UTC (permalink / raw)
  To: Colin Ian King, wharms
  Cc: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Rafael J . Wysocki,
	linux-pm, kernel-janitors, linux-kernel

On Mon, 2019-07-29 at 12:29 +0100, Colin Ian King wrote:
> On 29/07/2019 12:24, walter harms wrote:
> > 
> > 
> > Am 29.07.2019 12:29, schrieb Colin King:
> > > From: Colin Ian King <colin.king@canonical.com>
> > > 
> > > The variable val is having the top 8 bits cleared and then the
> > > variable
> > > is being re-assinged and setting just the top 8 bits.  I believe
> > > the
> > > intention was bitwise-or in the top 8 bits.  Fix this by
> > > replacing
> > > the = operator with |= instead.
> > > 
> > > Addresses-Coverity: ("Unused value")
> > > Fixes: b0c74b08517e ("drivers: thermal: processor_thermal_device:
> > > Export sysfs inteface for TCC offset")
> > > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > > ---
> > >  .../thermal/intel/int340x_thermal/processor_thermal_device.c    
> > > | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git
> > > a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.
> > > c
> > > b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.
> > > c
> > > index 6f6ac6a8e82d..cb22317911ef 100644
> > > ---
> > > a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.
> > > c
> > > +++
> > > b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.
> > > c
> > > @@ -164,7 +164,7 @@ static int tcc_offset_update(int tcc)
> > >  		return err;
> > >  
> > >  	val = ~GENMASK_ULL(31, 24);
> > > -	val = (tcc & 0xff) << 24;
> > > +	val |= (tcc & 0xff) << 24;
> > >  
> > 
> > I do not think that GENMASK makes sence here.
> 
> Yeah, val &= ~GENMASK_ULL(31, 24)
> 
> I'll send a V2
> 
Thanks Colin for the fix.

-Srinivas
> 
> > 
> > re,
> >  wh
> > 
> > >  	err = wrmsrl_safe(MSR_IA32_TEMPERATURE_TARGET, val);
> > >  	if (err)
> 
> 


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

end of thread, other threads:[~2019-07-29 11:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29 10:29 [PATCH][next] drivers: thermal: processor_thermal_device: fix missing bitwise-or operator Colin King
2019-07-29 11:24 ` walter harms
2019-07-29 11:29   ` Colin Ian King
2019-07-29 11:50     ` Srinivas Pandruvada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).