* [PATCH][V2] drivers: thermal: processor_thermal_device: fix missing bitwise-or operators
@ 2019-07-29 12:03 Colin King
2019-07-29 12:34 ` walter harms
2019-07-29 21:09 ` Srinivas Pandruvada
0 siblings, 2 replies; 4+ messages in thread
From: Colin King @ 2019-07-29 12:03 UTC (permalink / raw)
To: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Srinivas Pandruvada,
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 = operators with &= and |= 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>
---
V2: Add in &= operator missing from V1. Doh.
---
.../thermal/intel/int340x_thermal/processor_thermal_device.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
index 6f6ac6a8e82d..97333fc4be42 100644
--- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
+++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
@@ -163,8 +163,8 @@ static int tcc_offset_update(int tcc)
if (err)
return err;
- val = ~GENMASK_ULL(31, 24);
- val = (tcc & 0xff) << 24;
+ val &= ~GENMASK_ULL(31, 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][V2] drivers: thermal: processor_thermal_device: fix missing bitwise-or operators
2019-07-29 12:03 [PATCH][V2] drivers: thermal: processor_thermal_device: fix missing bitwise-or operators Colin King
@ 2019-07-29 12:34 ` walter harms
2019-07-29 21:09 ` Srinivas Pandruvada
1 sibling, 0 replies; 4+ messages in thread
From: walter harms @ 2019-07-29 12:34 UTC (permalink / raw)
To: Colin King
Cc: Zhang Rui, Eduardo Valentin, Daniel Lezcano, Srinivas Pandruvada,
linux-pm, kernel-janitors, linux-kernel
Am 29.07.2019 14:03, 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 = operators with &= and |= 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>
> ---
>
> V2: Add in &= operator missing from V1. Doh.
>
> ---
> .../thermal/intel/int340x_thermal/processor_thermal_device.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> index 6f6ac6a8e82d..97333fc4be42 100644
> --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> @@ -163,8 +163,8 @@ static int tcc_offset_update(int tcc)
> if (err)
> return err;
>
> - val = ~GENMASK_ULL(31, 24);
> - val = (tcc & 0xff) << 24;
> + val &= ~GENMASK_ULL(31, 24);
> + val |= (tcc & 0xff) << 24;
>
IMHO GENMASK_ULL(31, 24) is a complicated way to say 0xFF000000
In this special case it would be better to use that (or 0xff<<24).
just my 2 cents,
re,
wh
> err = wrmsrl_safe(MSR_IA32_TEMPERATURE_TARGET, val);
> if (err)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][V2] drivers: thermal: processor_thermal_device: fix missing bitwise-or operators
2019-07-29 12:03 [PATCH][V2] drivers: thermal: processor_thermal_device: fix missing bitwise-or operators Colin King
2019-07-29 12:34 ` walter harms
@ 2019-07-29 21:09 ` Srinivas Pandruvada
2019-08-19 6:32 ` Zhang Rui
1 sibling, 1 reply; 4+ messages in thread
From: Srinivas Pandruvada @ 2019-07-29 21:09 UTC (permalink / raw)
To: Colin King, Zhang Rui, Eduardo Valentin, Daniel Lezcano, linux-pm
Cc: kernel-janitors, linux-kernel
On Mon, 2019-07-29 at 13:03 +0100, Colin King wrote:
> 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 = operators with &= and
> |= 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>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> ---
>
> V2: Add in &= operator missing from V1. Doh.
>
> ---
> .../thermal/intel/int340x_thermal/processor_thermal_device.c | 4
> ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git
> a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> index 6f6ac6a8e82d..97333fc4be42 100644
> ---
> a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> +++
> b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> @@ -163,8 +163,8 @@ static int tcc_offset_update(int tcc)
> if (err)
> return err;
>
> - val = ~GENMASK_ULL(31, 24);
> - val = (tcc & 0xff) << 24;
> + val &= ~GENMASK_ULL(31, 24);
> + val |= (tcc & 0xff) << 24;
>
> err = wrmsrl_safe(MSR_IA32_TEMPERATURE_TARGET, val);
> if (err)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][V2] drivers: thermal: processor_thermal_device: fix missing bitwise-or operators
2019-07-29 21:09 ` Srinivas Pandruvada
@ 2019-08-19 6:32 ` Zhang Rui
0 siblings, 0 replies; 4+ messages in thread
From: Zhang Rui @ 2019-08-19 6:32 UTC (permalink / raw)
To: Srinivas Pandruvada, Colin King, Eduardo Valentin,
Daniel Lezcano, linux-pm
Cc: kernel-janitors, linux-kernel
On Mon, 2019-07-29 at 14:09 -0700, Srinivas Pandruvada wrote:
> On Mon, 2019-07-29 at 13:03 +0100, Colin King wrote:
> > 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 = operators with &=
> > and
> > > = 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>
>
> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com
> >
Hi, Colin,
thanks for the fix, as b0c74b08517e ("drivers: thermal:
processor_thermal_device: Export sysfs inteface for TCC offset") has
not been shipped in upstream yet, I will fold this fix into the
original patch directly.
thanks,
rui
>
> > ---
> >
> > V2: Add in &= operator missing from V1. Doh.
> >
> > ---
> > .../thermal/intel/int340x_thermal/processor_thermal_device.c | 4
> > ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git
> > a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> > b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> > index 6f6ac6a8e82d..97333fc4be42 100644
> > ---
> > a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> > +++
> > b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
> > @@ -163,8 +163,8 @@ static int tcc_offset_update(int tcc)
> > if (err)
> > return err;
> >
> > - val = ~GENMASK_ULL(31, 24);
> > - val = (tcc & 0xff) << 24;
> > + val &= ~GENMASK_ULL(31, 24);
> > + val |= (tcc & 0xff) << 24;
> >
> > 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-08-19 6:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29 12:03 [PATCH][V2] drivers: thermal: processor_thermal_device: fix missing bitwise-or operators Colin King
2019-07-29 12:34 ` walter harms
2019-07-29 21:09 ` Srinivas Pandruvada
2019-08-19 6:32 ` Zhang Rui
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).