linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: f.fainelli@gmail.com
Cc: linux-pm@vger.kernel.org
Subject: [bug report] cpufreq: brcmstb-avs-cpufreq: Fix initial command check
Date: Tue, 20 Aug 2019 15:50:47 +0300	[thread overview]
Message-ID: <20190820125047.GA11755@mwanda> (raw)

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

                 reply	other threads:[~2019-08-20 12:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190820125047.GA11755@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=f.fainelli@gmail.com \
    --cc=linux-pm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).