All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: re: stmmac: add ipq806x glue layer
Date: Tue, 02 Jun 2015 10:03:15 +0000	[thread overview]
Message-ID: <20150602100315.GB11247@mwanda> (raw)

Hello Mathieu Olivari,

The patch b1c17215d718: "stmmac: add ipq806x glue layer" from May 27,
2015, leads to the following static checker warning:

	drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c:297 ipq806x_gmac_setup()
	warn: double left shift '1 << (1 << gmac->id)'

drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
   292          /* Configure the clock src according to the mode */
   293          regmap_read(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, &val);
   294          val &= ~NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id);
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
We are clearing a bit here, but it's not the same bit we set later.

   295          switch (gmac->phy_mode) {
   296          case PHY_INTERFACE_MODE_RGMII:
   297                  val |= NSS_COMMON_CLK_SRC_CTRL_RGMII(gmac->id) <<
   298                          NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id);

NSS_COMMON_CLK_SRC_CTRL_RGMII(gmac->id) is always 1.
NSS_COMMON_CLK_SRC_CTRL_OFFSET is "(1 << gmac->id)".
gmac->id is a number in the 0-3 range so val is either 0x100, 0x10, 0x4
or 0x2, which is kind of weird.

Also the comments seem to imply that we read a number 1-4 for gmac->id
but we map it to 0-3 so that counting starts at zero.  But I don't see
that we subtract 1 from the number that we read in
ipq806x_gmac_of_parse().

   299                  break;
   300          case PHY_INTERFACE_MODE_SGMII:
   301                  val |= NSS_COMMON_CLK_SRC_CTRL_SGMII(gmac->id) <<
   302                          NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id);
   303                  break;
   304          default:
   305                  dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
   306                          phy_modes(gmac->phy_mode));
   307                  return NULL;
   308          }
   309          regmap_write(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, val);



regards,
dan carpenter

             reply	other threads:[~2015-06-02 10:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02 10:03 Dan Carpenter [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-07-30 19:12 stmmac: add ipq806x glue layer Dan Carpenter
2015-08-04 22:49 Dan Carpenter

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=20150602100315.GB11247@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.