[10/13] cpufreq: powernow-k8: Make use of known set but not used variables

Message ID 20200714145049.2496163-11-lee.jones@linaro.org
State New
Headers show
Series
  • Rid W=1 warnings in CPUFreq
Related show

Commit Message

Lee Jones July 14, 2020, 2:50 p.m.
If we fail to use a variable, even a 'dummy' one, then the compiler
complains that it is set but not used.  We know this is fine, so we
set it to its own value here.

Fixes the following W=1 kernel build warning(s):

 drivers/cpufreq/powernow-k8.c: In function ‘pending_bit_stuck’:
 drivers/cpufreq/powernow-k8.c:89:10: warning: variable ‘hi’ set but not used [-Wunused-but-set-variable]
 89 | u32 lo, hi;
 | ^~
 drivers/cpufreq/powernow-k8.c: In function ‘core_voltage_pre_transition’:
 drivers/cpufreq/powernow-k8.c:285:14: warning: variable ‘lo’ set but not used [-Wunused-but-set-variable]
 285 | u32 maxvid, lo, rvomult = 1;
 | ^~

Cc: Andreas Herrmann <herrmann.der.user@googlemail.com>
Cc: Dominik Brodowski <linux@brodo.de>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Paul Devriendt <paul.devriendt@amd.com>
Cc: Mark Langsdorf <mark.langsdorf@amd.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

---
 drivers/cpufreq/powernow-k8.c | 2 ++
 1 file changed, 2 insertions(+)

-- 
2.25.1

Comments

Rafael J. Wysocki July 14, 2020, 5:43 p.m. | #1
On Tue, Jul 14, 2020 at 4:51 PM Lee Jones <lee.jones@linaro.org> wrote:
>

> If we fail to use a variable, even a 'dummy' one, then the compiler

> complains that it is set but not used.  We know this is fine, so we

> set it to its own value here.

>

> Fixes the following W=1 kernel build warning(s):

>

>  drivers/cpufreq/powernow-k8.c: In function ‘pending_bit_stuck’:

>  drivers/cpufreq/powernow-k8.c:89:10: warning: variable ‘hi’ set but not used [-Wunused-but-set-variable]

>  89 | u32 lo, hi;

>  | ^~

>  drivers/cpufreq/powernow-k8.c: In function ‘core_voltage_pre_transition’:

>  drivers/cpufreq/powernow-k8.c:285:14: warning: variable ‘lo’ set but not used [-Wunused-but-set-variable]

>  285 | u32 maxvid, lo, rvomult = 1;

>  | ^~

>

> Cc: Andreas Herrmann <herrmann.der.user@googlemail.com>

> Cc: Dominik Brodowski <linux@brodo.de>

> Cc: Pavel Machek <pavel@ucw.cz>

> Cc: Paul Devriendt <paul.devriendt@amd.com>

> Cc: Mark Langsdorf <mark.langsdorf@amd.com>

> Signed-off-by: Lee Jones <lee.jones@linaro.org>

> ---

>  drivers/cpufreq/powernow-k8.c | 2 ++

>  1 file changed, 2 insertions(+)

>

> diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c

> index 3984959eed1d5..b76df81044c4f 100644

> --- a/drivers/cpufreq/powernow-k8.c

> +++ b/drivers/cpufreq/powernow-k8.c

> @@ -89,6 +89,7 @@ static int pending_bit_stuck(void)

>         u32 lo, hi;

>

>         rdmsr(MSR_FIDVID_STATUS, lo, hi);

> +       hi &= hi; /* Silence set but not used warning */


Hmm.

What about using __always_unused for this?

>         return lo & MSR_S_LO_CHANGE_PENDING ? 1 : 0;

>  }

>

> @@ -292,6 +293,7 @@ static int core_voltage_pre_transition(struct powernow_k8_data *data,

>                 rvomult = 2;

>         rvosteps *= rvomult;

>         rdmsr(MSR_FIDVID_STATUS, lo, maxvid);

> +       lo &= lo; /* Silence set but not used warning */

>         maxvid = 0x1f & (maxvid >> 16);

>         pr_debug("ph1 maxvid=0x%x\n", maxvid);

>         if (reqvid < maxvid) /* lower numbers are higher voltages */

> --

> 2.25.1

>
Lee Jones July 14, 2020, 9:01 p.m. | #2
On Tue, 14 Jul 2020, Rafael J. Wysocki wrote:

> On Tue, Jul 14, 2020 at 4:51 PM Lee Jones <lee.jones@linaro.org> wrote:

> >

> > If we fail to use a variable, even a 'dummy' one, then the compiler

> > complains that it is set but not used.  We know this is fine, so we

> > set it to its own value here.

> >

> > Fixes the following W=1 kernel build warning(s):

> >

> >  drivers/cpufreq/powernow-k8.c: In function ‘pending_bit_stuck’:

> >  drivers/cpufreq/powernow-k8.c:89:10: warning: variable ‘hi’ set but not used [-Wunused-but-set-variable]

> >  89 | u32 lo, hi;

> >  | ^~

> >  drivers/cpufreq/powernow-k8.c: In function ‘core_voltage_pre_transition’:

> >  drivers/cpufreq/powernow-k8.c:285:14: warning: variable ‘lo’ set but not used [-Wunused-but-set-variable]

> >  285 | u32 maxvid, lo, rvomult = 1;

> >  | ^~

> >

> > Cc: Andreas Herrmann <herrmann.der.user@googlemail.com>

> > Cc: Dominik Brodowski <linux@brodo.de>

> > Cc: Pavel Machek <pavel@ucw.cz>

> > Cc: Paul Devriendt <paul.devriendt@amd.com>

> > Cc: Mark Langsdorf <mark.langsdorf@amd.com>

> > Signed-off-by: Lee Jones <lee.jones@linaro.org>

> > ---

> >  drivers/cpufreq/powernow-k8.c | 2 ++

> >  1 file changed, 2 insertions(+)

> >

> > diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c

> > index 3984959eed1d5..b76df81044c4f 100644

> > --- a/drivers/cpufreq/powernow-k8.c

> > +++ b/drivers/cpufreq/powernow-k8.c

> > @@ -89,6 +89,7 @@ static int pending_bit_stuck(void)

> >         u32 lo, hi;

> >

> >         rdmsr(MSR_FIDVID_STATUS, lo, hi);

> > +       hi &= hi; /* Silence set but not used warning */

> 

> Hmm.

> 

> What about using __always_unused for this?


I didn't know you could use that for standard variables.

Will fix.

> >         return lo & MSR_S_LO_CHANGE_PENDING ? 1 : 0;

> >  }

> >

> > @@ -292,6 +293,7 @@ static int core_voltage_pre_transition(struct powernow_k8_data *data,

> >                 rvomult = 2;

> >         rvosteps *= rvomult;

> >         rdmsr(MSR_FIDVID_STATUS, lo, maxvid);

> > +       lo &= lo; /* Silence set but not used warning */

> >         maxvid = 0x1f & (maxvid >> 16);

> >         pr_debug("ph1 maxvid=0x%x\n", maxvid);

> >         if (reqvid < maxvid) /* lower numbers are higher voltages */

> >


-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

Patch

diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index 3984959eed1d5..b76df81044c4f 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -89,6 +89,7 @@  static int pending_bit_stuck(void)
 	u32 lo, hi;
 
 	rdmsr(MSR_FIDVID_STATUS, lo, hi);
+	hi &= hi; /* Silence set but not used warning */
 	return lo & MSR_S_LO_CHANGE_PENDING ? 1 : 0;
 }
 
@@ -292,6 +293,7 @@  static int core_voltage_pre_transition(struct powernow_k8_data *data,
 		rvomult = 2;
 	rvosteps *= rvomult;
 	rdmsr(MSR_FIDVID_STATUS, lo, maxvid);
+	lo &= lo; /* Silence set but not used warning */
 	maxvid = 0x1f & (maxvid >> 16);
 	pr_debug("ph1 maxvid=0x%x\n", maxvid);
 	if (reqvid < maxvid) /* lower numbers are higher voltages */