From: Joe Perches <joe@perches.com>
To: Masayuki Ohtake <masa-korg@dsn.okisemi.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Randy Dunlap <randy.dunlap@oracle.com>,
John Linn <john.linn@xilinx.com>,
Ralf Baechle <ralf@linux-mips.org>,
Kristoffer Glembo <kristoffer@gaisler.com>,
Maxime Bizon <mbizon@freebox.fr>,
Greg Rose <gregory.v.rose@intel.com>,
ML netdev <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>, MeeGo <meego-dev@meego.com>,
Stephen Hemminger <shemminger@vyatta.com>,
Jili Slaby <jslaby@suse.cz>,
FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
"Wang, Qi" <qi.wang@intel.com>,
"Wang, Yong Y" <yong.y.wang@intel.com>,
Andrew <andrew.chih.howe.khor@intel.com>,
Intel OTC <joel.clark@intel.com>,
"Foster, Margie" <margie.foster@intel.com>,
Arjan <arjan@linux.intel.com>,
Toshiharu Okada <okada533@dsn.okisemi.com>,
Takahiro Shimizu <shimizu394@dsn.okisemi.com>,
Tomoya Morinaga <morinaga526@dsn.okisemi.com>
Subject: Re: [PATCH v3] Gigabit Ethernet driver of Topcliff PCH
Date: Thu, 09 Sep 2010 23:32:07 -0700 [thread overview]
Message-ID: <1284100327.24986.324.camel@Joe-Laptop> (raw)
In-Reply-To: <4C89C23A.6090707@dsn.okisemi.com>
On Fri, 2010-09-10 at 14:29 +0900, Masayuki Ohtake wrote:
> diff --git a/drivers/net/pch_gbe/pch_gbe_ethtool.c b/drivers/net/pch_gbe/pch_gbe_ethtool.c
[]
> +static void pch_gbe_get_regs(struct net_device *netdev,
> + struct ethtool_regs *regs, void *p)
> +{
> + struct pch_gbe_adapter *adapter = netdev_priv(netdev);
> + struct pch_gbe_hw *hw = &adapter->hw;
> + struct pci_dev *pdev = adapter->pdev;
> + u32 *regs_buff = p;
> + u16 i, reg, tmp;
> +
> + regs->version = pdev->revision;
> + regs->version = 0x1000000 | (regs->version << 16) | pdev->device;
Might be simpler as:
regs->version = 0x1000000 | (__u32)pdev->revision << 16 | pdev->device;
The block below is a bit confusing to me.
> + memset(p, 0, PCH_GBE_REGS_LEN * (int)sizeof(u32));
It seems the memset is unnecessary as it's completely
overwritten below.
> + for (i = 0; i < PCH_GBE_MAC_REGS_LEN; i++)
> + regs_buff[i] = ioread32(&hw->reg->INT_ST + i);
> + /* PHY register */
> + for (i = PCH_GBE_MAC_REGS_LEN, reg = 0; reg < PCH_GBE_PHY_REGS_LEN;
> + i++, reg++) {
> + pch_gbe_hal_read_phy_reg(&adapter->hw, reg, &tmp);
> + regs_buff[i] = tmp;
> + }
I think i'd be simpler to do something like:
for (i = 0; i < PCH_GBE_MAC_REGS_LEN; i++)
*regs_buff++ = ioread32(&hw->reg->INT_ST + i);
/* PHY register */
for (i = 0; i < PCH_GBE_PHY_REGS_LEN; i++) {
pch_gbe_hal_read_phy_reg(&adapter->hw, i, &tmp);
*regs_buff++ = tmp;
}
[]
+void pch_gbe_mac_mar_set(struct pch_gbe_hw *hw, u8 * addr, u32 index)
> +{
> + u32 mar_low, mar_high, adrmask;
> +
> + pr_debug("index : 0x%x\n", index);
> +
> + /*
> + * HW expects these in little endian so we reverse the byte order
> + * from network order (big endian) to little endian
> + */
> + mar_high = ((u32) addr[0] | ((u32) addr[1] << 8) |
> + ((u32) addr[2] << 16) | ((u32) addr[3] << 24));
> + mar_low = ((u32) addr[4] | ((u32) addr[5] << 8));
> + /* Stop the MAC Address of index. */
> + adrmask = ioread32(&hw->reg->ADDR_MASK);
> + iowrite32((adrmask | (0x0001 << index)), &hw->reg->ADDR_MASK);
> + /* wait busy */
> + while ((ioread32(&hw->reg->ADDR_MASK) & PCH_GBE_BUSY)) {
> + int tmp = 0;
> + udelay(20);
> + tmp++;
> + if (tmp == 1000) {
> + pr_err("Address mask bit is not cleared\n");
> + break;
> + }
> + }
You need to move the declaration of tmp out of the while.
Do these really need to be busy-waits?
> + /* Set the MAC address to the MAC address 1A/1B register */
> + iowrite32(mar_high, &hw->reg->mac_adr[index].high);
> + iowrite32(mar_low, &hw->reg->mac_adr[index].low);
> + /* Start the MAC address of index */
> + iowrite32((adrmask & ~(0x0001 << index)), &hw->reg->ADDR_MASK);
> + /* wait busy */
> + while ((ioread32(&hw->reg->ADDR_MASK) & PCH_GBE_BUSY)) {
> + int tmp = 0;
> + udelay(20);
> + tmp++;
> + if (tmp == 1000) {
> + pr_err("Address mask bit is not cleared\n");
> + break;
> + }
> + }
> +}
Here too. There are more of these too I'm not listing.
Perhaps you could review the logic a bit more.
next prev parent reply other threads:[~2010-09-10 6:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-10 5:29 [PATCH v3] Gigabit Ethernet driver of Topcliff PCH Masayuki Ohtake
2010-09-10 6:32 ` Joe Perches [this message]
2010-09-15 12:19 ` Masayuki Ohtake
2010-09-10 8:19 ` Jiri Slaby
2010-09-12 22:19 ` Rafael J. Wysocki
2010-09-15 12:26 ` Masayuki Ohtake
2010-09-15 12:20 ` Masayuki Ohtake
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=1284100327.24986.324.camel@Joe-Laptop \
--to=joe@perches.com \
--cc=andrew.chih.howe.khor@intel.com \
--cc=arjan@linux.intel.com \
--cc=davem@davemloft.net \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=gregory.v.rose@intel.com \
--cc=joel.clark@intel.com \
--cc=john.linn@xilinx.com \
--cc=jslaby@suse.cz \
--cc=kristoffer@gaisler.com \
--cc=linux-kernel@vger.kernel.org \
--cc=margie.foster@intel.com \
--cc=masa-korg@dsn.okisemi.com \
--cc=mbizon@freebox.fr \
--cc=meego-dev@meego.com \
--cc=morinaga526@dsn.okisemi.com \
--cc=netdev@vger.kernel.org \
--cc=okada533@dsn.okisemi.com \
--cc=qi.wang@intel.com \
--cc=ralf@linux-mips.org \
--cc=randy.dunlap@oracle.com \
--cc=shemminger@vyatta.com \
--cc=shimizu394@dsn.okisemi.com \
--cc=yong.y.wang@intel.com \
/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).