cpufreq: brcmstb-avs-cpufreq: issue with error number check that's always true
Hi,
There seems to be a logic issue with the rc comparisons in the following function in drivers/cpufreq/brcmstb-avs-cpufreq.c
/*
* To ensure the right firmware is running we need to
* - check the MAGIC matches what we expect
* - brcm_avs_get_pmap() doesn't return -ENOTSUPP or -EINVAL
* We need to set up our interrupt handling before callingbrcm_avs_get_pmap()!
*/
static bool brcm_avs_is_firmware_loaded(struct private_data *priv)
{
u32 magic;
int rc;
rc = brcm_avs_get_pmap(priv, NULL);
magic = readl(priv->base + AVS_MBOX_MAGIC);
return (magic == AVS_FIRMWARE_MAGIC) && ((rc != -ENOTSUPP) ||
(rc != -EINVAL));
}..the following condition is always true:
((rc != -ENOTSUPP) || (rc != -EINVAL))
.. because rc cannot be equal to two different values at the same time, so it must be not equal to at least one of them.
This was introduced with commit:
commit 22a26cc6a51ef73dcfeb64c50513903f6b2d53d8
Author: Florian Fainelli <[email protected]> Date: Wed May 22 11:45:46 2019 -0700
cpufreq: brcmstb-avs-cpufreq: Fix initial command check
There is a logical error in brcm_avs_is_firmware_loaded() whereby
if the
firmware returns -EINVAL, we will be reporting this as an error. The comment is correct, the code was not.
..the commit message seems to rely on the logic expressed in the comment, but I think the "or" used in the comment is not equivalent to the English grammatical use of "or". I suspect the commit is incorrect and needs reverting/fixing.
Colin
Quoted 13 lines · Colin King (gmail)
This was introduced with commit:
commit
22a26cc6a51ef73dcfeb64c50513903f6b2d53d8Author: Florian Fainelli <[email protected]> Date: Wed May 22 11:45:46 2019 -0700cpufreq: brcmstb-avs-cpufreq: Fix initial command check
There is a logical error in
brcm_avs_is_firmware_loaded()whereby if the firmware returns-EINVAL, we will be reporting this as an error. The comment is correct, the code was not.
Quoted 4 lines
..the commit message seems to rely on the logic expressed in the comment, but I think the "or" used in the comment is not equivalent to the English grammatical use of "or". I suspect the commit is incorrect and needs reverting/fixing.
Yeah, perhaps the existing code was doing the right thing and this patch was never required.
Can you send a revert for this since we haven't heard from Markus or Florian.
Signature · 1 line
viresh