* [bug report] cpufreq: brcmstb-avs-cpufreq: Fix initial command check
@ 2019-08-20 12:50 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2019-08-20 12:50 UTC (permalink / raw)
To: f.fainelli; +Cc: linux-pm
Hello Florian Fainelli,
The patch 22a26cc6a51e: "cpufreq: brcmstb-avs-cpufreq: Fix initial
command check" from May 22, 2019, leads to the following static
checker warning:
drivers/cpufreq/brcmstb-avs-cpufreq.c:449 brcm_avs_is_firmware_loaded()
warn: was && intended here instead of ||?
drivers/cpufreq/brcmstb-avs-cpufreq.c
435 /*
436 * To ensure the right firmware is running we need to
437 * - check the MAGIC matches what we expect
438 * - brcm_avs_get_pmap() doesn't return -ENOTSUPP or -EINVAL
439 * We need to set up our interrupt handling before calling brcm_avs_get_pmap()!
440 */
441 static bool brcm_avs_is_firmware_loaded(struct private_data *priv)
442 {
443 u32 magic;
444 int rc;
445
446 rc = brcm_avs_get_pmap(priv, NULL);
447 magic = readl(priv->base + AVS_MBOX_MAGIC);
448
449 return (magic == AVS_FIRMWARE_MAGIC) && ((rc != -ENOTSUPP) ||
450 (rc != -EINVAL));
This is quite an interesting one because originally this was && instead
of || as the static checker suggests. Obviously "(rc != -ENOTSUPP ||
rc != -EINVAL) is always true because "rc" can't possibly be both values
at the same time.
I see the comment at the top of the function, but I don't understand why
those particular error codes are special. The temptation for me would
be to do:
rc = brcm_avs_get_pmap(priv, NULL);
if (rc)
return false;
magic = readl(priv->base + AVS_MBOX_MAGIC);
return magic == AVS_FIRMWARE_MAGIC;
But I'm clearly missing some information so I'm just going to report
this bug instead.
451 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-08-20 12:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-20 12:50 [bug report] cpufreq: brcmstb-avs-cpufreq: Fix initial command check Dan Carpenter
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).