aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/r8169.c
diff options
context:
space:
mode:
authorFrancois Romieu <romieu@fr.zoreil.com>2011-04-29 09:05:51 -0400
committerFrancois romieu <romieu@fr.zoreil.com>2011-05-09 15:02:58 -0400
commit6f43adc88f49cb8164fbd665e968de4de380dc35 (patch)
treeced085bef1bdc283e7cf657a46b370165b42d411 /drivers/net/r8169.c
parentcecb5fd7c277c1bba161980bb41792a60b56df4a (diff)
r8169: remove some code duplication.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com> Cc: Realtek linux nic maintainers <nic_swsd@realtek.com>
Diffstat (limited to 'drivers/net/r8169.c')
-rw-r--r--drivers/net/r8169.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index c51515f53df1..976bb31b2092 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -3224,6 +3224,22 @@ static void __devinit rtl_init_pll_power_ops(struct rtl8169_private *tp)
3224 } 3224 }
3225} 3225}
3226 3226
3227static void rtl_hw_reset(struct rtl8169_private *tp)
3228{
3229 void __iomem *ioaddr = tp->mmio_addr;
3230 int i;
3231
3232 /* Soft reset the chip. */
3233 RTL_W8(ChipCmd, CmdReset);
3234
3235 /* Check that the chip has finished the reset. */
3236 for (i = 0; i < 100; i++) {
3237 if ((RTL_R8(ChipCmd) & CmdReset) == 0)
3238 break;
3239 msleep_interruptible(1);
3240 }
3241}
3242
3227static int __devinit 3243static int __devinit
3228rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 3244rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3229{ 3245{
@@ -3323,6 +3339,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3323 rc = -EIO; 3339 rc = -EIO;
3324 goto err_out_free_res_3; 3340 goto err_out_free_res_3;
3325 } 3341 }
3342 tp->mmio_addr = ioaddr;
3326 3343
3327 tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); 3344 tp->pcie_cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
3328 if (!tp->pcie_cap) 3345 if (!tp->pcie_cap)
@@ -3330,15 +3347,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3330 3347
3331 RTL_W16(IntrMask, 0x0000); 3348 RTL_W16(IntrMask, 0x0000);
3332 3349
3333 /* Soft reset the chip. */ 3350 rtl_hw_reset(tp);
3334 RTL_W8(ChipCmd, CmdReset);
3335
3336 /* Check that the chip has finished the reset. */
3337 for (i = 0; i < 100; i++) {
3338 if ((RTL_R8(ChipCmd) & CmdReset) == 0)
3339 break;
3340 msleep_interruptible(1);
3341 }
3342 3351
3343 RTL_W16(IntrStatus, 0xffff); 3352 RTL_W16(IntrStatus, 0xffff);
3344 3353
@@ -3409,8 +3418,6 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3409 3418
3410 spin_lock_init(&tp->lock); 3419 spin_lock_init(&tp->lock);
3411 3420
3412 tp->mmio_addr = ioaddr;
3413
3414 /* Get MAC address */ 3421 /* Get MAC address */
3415 for (i = 0; i < MAC_ADDR_LEN; i++) 3422 for (i = 0; i < MAC_ADDR_LEN; i++)
3416 dev->dev_addr[i] = RTL_R8(MAC0 + i); 3423 dev->dev_addr[i] = RTL_R8(MAC0 + i);
@@ -3658,25 +3665,14 @@ static void rtl_set_rx_tx_config_registers(struct rtl8169_private *tp)
3658static void rtl_hw_start(struct net_device *dev) 3665static void rtl_hw_start(struct net_device *dev)
3659{ 3666{
3660 struct rtl8169_private *tp = netdev_priv(dev); 3667 struct rtl8169_private *tp = netdev_priv(dev);
3661 void __iomem *ioaddr = tp->mmio_addr;
3662 unsigned int i;
3663 3668
3664 /* Soft reset the chip. */ 3669 rtl_hw_reset(tp);
3665 RTL_W8(ChipCmd, CmdReset);
3666
3667 /* Check that the chip has finished the reset. */
3668 for (i = 0; i < 100; i++) {
3669 if ((RTL_R8(ChipCmd) & CmdReset) == 0)
3670 break;
3671 msleep_interruptible(1);
3672 }
3673 3670
3674 tp->hw_start(dev); 3671 tp->hw_start(dev);
3675 3672
3676 netif_start_queue(dev); 3673 netif_start_queue(dev);
3677} 3674}
3678 3675
3679
3680static void rtl_set_rx_tx_desc_registers(struct rtl8169_private *tp, 3676static void rtl_set_rx_tx_desc_registers(struct rtl8169_private *tp,
3681 void __iomem *ioaddr) 3677 void __iomem *ioaddr)
3682{ 3678{