Commit b6ab3b3d authored by François Romieu's avatar François Romieu Committed by Jeff Garzik

[netdrvr rrunner] small fixes and cleanups:

 - pci_disable_device() added in rr_remove_one() to balance
   pci_enable_device() in rr_init_one()
 - rr_timer() and rr_close() are leaking pci_map'ed memory: make them
   use rr_raz_{rx/tx}
 - error exiting path in rr_open() was balancing pci_alloc_consistent()
   with kfree().
parent 5ebe9e17
...@@ -255,6 +255,7 @@ static void __devexit rr_remove_one (struct pci_dev *pdev) ...@@ -255,6 +255,7 @@ static void __devexit rr_remove_one (struct pci_dev *pdev)
iounmap(rr->regs); iounmap(rr->regs);
kfree(dev); kfree(dev);
pci_release_regions(pdev); pci_release_regions(pdev);
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
} }
} }
...@@ -1128,14 +1129,12 @@ static void rr_interrupt(int irq, void *dev_id, struct pt_regs *ptregs) ...@@ -1128,14 +1129,12 @@ static void rr_interrupt(int irq, void *dev_id, struct pt_regs *ptregs)
spin_unlock(&rrpriv->lock); spin_unlock(&rrpriv->lock);
} }
static void rr_timer(unsigned long data) static void rr_timer(unsigned long data)
{ {
struct net_device *dev = (struct net_device *)data; struct net_device *dev = (struct net_device *)data;
struct rr_private *rrpriv = (struct rr_private *)dev->priv; struct rr_private *rrpriv = (struct rr_private *)dev->priv;
struct rr_regs *regs = rrpriv->regs; struct rr_regs *regs = rrpriv->regs;
unsigned long flags; unsigned long flags;
int i;
if (readl(&regs->HostCtrl) & NIC_HALTED){ if (readl(&regs->HostCtrl) & NIC_HALTED){
printk("%s: Restarting nic\n", dev->name); printk("%s: Restarting nic\n", dev->name);
...@@ -1143,23 +1142,8 @@ static void rr_timer(unsigned long data) ...@@ -1143,23 +1142,8 @@ static void rr_timer(unsigned long data)
memset(rrpriv->info, 0, sizeof(struct rr_info)); memset(rrpriv->info, 0, sizeof(struct rr_info));
wmb(); wmb();
for (i = 0; i < TX_RING_ENTRIES; i++) { rr_raz_tx(rrpriv, dev);
if (rrpriv->tx_skbuff[i]) { rr_raz_rx(rrpriv, dev);
rrpriv->tx_ring[i].size = 0;
set_rraddr(&rrpriv->tx_ring[i].addr, 0);
dev_kfree_skb(rrpriv->tx_skbuff[i]);
rrpriv->tx_skbuff[i] = NULL;
}
}
for (i = 0; i < RX_RING_ENTRIES; i++) {
if (rrpriv->rx_skbuff[i]) {
rrpriv->rx_ring[i].size = 0;
set_rraddr(&rrpriv->rx_ring[i].addr, 0);
dev_kfree_skb(rrpriv->rx_skbuff[i]);
rrpriv->rx_skbuff[i] = NULL;
}
}
if (rr_init1(dev)) { if (rr_init1(dev)) {
spin_lock_irqsave(&rrpriv->lock, flags); spin_lock_irqsave(&rrpriv->lock, flags);
...@@ -1246,11 +1230,13 @@ static int rr_open(struct net_device *dev) ...@@ -1246,11 +1230,13 @@ static int rr_open(struct net_device *dev)
spin_unlock_irqrestore(&rrpriv->lock, flags); spin_unlock_irqrestore(&rrpriv->lock, flags);
if (rrpriv->info) { if (rrpriv->info) {
kfree(rrpriv->info); pci_free_consistent(pdev, sizeof(struct rr_info), rrpriv->info,
rrpriv->info_dma);
rrpriv->info = NULL; rrpriv->info = NULL;
} }
if (rrpriv->rx_ctrl) { if (rrpriv->rx_ctrl) {
kfree(rrpriv->rx_ctrl); pci_free_consistent(pdev, sizeof(struct ring_ctrl),
rrpriv->rx_ctrl, rrpriv->rx_ctrl_dma);
rrpriv->rx_ctrl = NULL; rrpriv->rx_ctrl = NULL;
} }
...@@ -1413,23 +1399,8 @@ static int rr_close(struct net_device *dev) ...@@ -1413,23 +1399,8 @@ static int rr_close(struct net_device *dev)
rrpriv->info->evt_ctrl.pi = 0; rrpriv->info->evt_ctrl.pi = 0;
rrpriv->rx_ctrl[4].entries = 0; rrpriv->rx_ctrl[4].entries = 0;
for (i = 0; i < TX_RING_ENTRIES; i++) { rr_raz_tx(rrpriv, dev);
if (rrpriv->tx_skbuff[i]) { rr_raz_rx(rrpriv, dev);
rrpriv->tx_ring[i].size = 0;
set_rraddr(&rrpriv->tx_ring[i].addr, 0);
dev_kfree_skb(rrpriv->tx_skbuff[i]);
rrpriv->tx_skbuff[i] = NULL;
}
}
for (i = 0; i < RX_RING_ENTRIES; i++) {
if (rrpriv->rx_skbuff[i]) {
rrpriv->rx_ring[i].size = 0;
set_rraddr(&rrpriv->rx_ring[i].addr, 0);
dev_kfree_skb(rrpriv->rx_skbuff[i]);
rrpriv->rx_skbuff[i] = NULL;
}
}
pci_free_consistent(rrpriv->pci_dev, 256 * sizeof(struct ring_ctrl), pci_free_consistent(rrpriv->pci_dev, 256 * sizeof(struct ring_ctrl),
rrpriv->rx_ctrl, rrpriv->rx_ctrl_dma); rrpriv->rx_ctrl, rrpriv->rx_ctrl_dma);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment