Subject: Re: [PATCH] firmware: arm_scmi: Remove set but not used variable 'val'

From: Sudeep Holla <[email-masked]>
Date: Mon, 11 Nov 2019 16:04:03 +0000

On Mon, Nov 11, 2019 at 03:49:55PM +0000, Robin Murphy wrote:
> On 10/11/2019 10:30, Zheng Yongjun wrote:
> > Fixes gcc '-Wunused-but-set-variable' warning:
> >
> > drivers/firmware/arm_scmi/perf.c: In function scmi_perf_fc_ring_db:
> > drivers/firmware/arm_scmi/perf.c:323:7: warning: variable val set but not used [-Wunused-but-set-variable]
> >
> > val is never used, so remove it.
> >
> > Reported-by: Hulk Robot <[email-masked]>
> > Signed-off-by: Zheng Yongjun <[email-masked]>
> > ---
> >   drivers/firmware/arm_scmi/perf.c | 4 +---
> >   1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c
> > index 4a8012e3cb8c..efa98d2ee045 100644
> > --- a/drivers/firmware/arm_scmi/perf.c
> > +++ b/drivers/firmware/arm_scmi/perf.c
> > @@ -319,10 +319,8 @@ static void scmi_perf_fc_ring_db(struct scmi_fc_db_info *db)
> >   		SCMI_PERF_FC_RING_DB(64);
> >   #else
> >   	{
> > -		u64 val = 0;
> > -
> >   		if (db->mask)
> > -			val = ioread64_hi_lo(db->addr) & db->mask;
> > +			ioread64_hi_lo(db->addr) & db->mask;
> >   		iowrite64_hi_lo(db->set, db->addr);
>
> FWIW, compared to the SCMI_PERF_FC_RING_DB() macro, this looks like the
> wrong "fix".
>

Yes, no idea how I didn't spot this earlier. That could be because this
was just added to fix 32-bit build and wasn't tested.

The below patch should fix the warning and also fixes the real bug.

Regards,
Sudeep

diff --git i/drivers/firmware/arm_scmi/perf.c w/drivers/firmware/arm_scmi/perf.c
index 4a8012e3cb8c..601af4edad5e 100644
--- i/drivers/firmware/arm_scmi/perf.c
+++ w/drivers/firmware/arm_scmi/perf.c
@@ -323,7 +323,7 @@ static void scmi_perf_fc_ring_db(struct scmi_fc_db_info *db)

                if (db->mask)
                        val = ioread64_hi_lo(db->addr) & db->mask;
-               iowrite64_hi_lo(db->set, db->addr);
+               iowrite64_hi_lo(db->set | val, db->addr);
        }
 #endif
 }

_______________________________________________
linux-arm-kernel mailing list
[email-masked]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel