Re: [PATCH] EDAC, mpc85xx: fix build warning

From: Guenter Roeck
Date: Tue Feb 02 2016 - 09:38:11 EST


On Tue, Feb 02, 2016 at 12:15:45PM +0100, Borislav Petkov wrote:
> On Tue, Feb 02, 2016 at 01:30:21PM +0530, Sudip Mukherjee wrote:
> > We were getting build warning about:
> > drivers/edac/mpc85xx_edac.c:1247:6: warning: unused variable 'pvr'
> >
> > pvr is only used if CONFIG_FSL_SOC_BOOKE was defined. Declare the
> > variable as a local variable inside the #ifdef block.
>
> What's wrong with doing the simpler thing:
>
> ---
> diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
> index b7139c160baf..f756b6215228 100644
> --- a/drivers/edac/mpc85xx_edac.c
> +++ b/drivers/edac/mpc85xx_edac.c
> @@ -1244,7 +1244,6 @@ static struct platform_driver * const drivers[] = {
> static int __init mpc85xx_mc_init(void)
> {
> int res = 0;
> - u32 pvr = 0;
>
Or with just adding __maybe_unused here.

Guenter

> printk(KERN_INFO "Freescale(R) MPC85xx EDAC driver, "
> "(C) 2006 Montavista Software\n");
> @@ -1264,10 +1263,8 @@ static int __init mpc85xx_mc_init(void)
> printk(KERN_WARNING EDAC_MOD_STR "drivers fail to register\n");
>
> #ifdef CONFIG_FSL_SOC_BOOKE
> - pvr = mfspr(SPRN_PVR);
> -
> - if ((PVR_VER(pvr) == PVR_VER_E500V1) ||
> - (PVR_VER(pvr) == PVR_VER_E500V2)) {
> + if ((PVR_VER(mfspr(SPRN_PVR)) == PVR_VER_E500V1) ||
> + (PVR_VER(mfspr(SPRN_PVR)) == PVR_VER_E500V2)) {
> /*
> * need to clear HID1[RFXE] to disable machine check int
> * so we can catch it
> ---
>
> Granted, we get MFSPR issued twice by the compiler but that's the init
> path.
>
> --
> Regards/Gruss,
> Boris.
>
> ECO tip #101: Trim your mails when you reply.
>
>