Skip to contentSkip to conversation

via-velocity: Remove private device list

PATCH In review Ben Hutchings 2 participants 2 messages Oct 25, 2009 – Oct 28, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 via-velocity: Remove private device list

via-velocity maintains a list of its devices in order to determine whether a netdev notification applies to one of them. That can be determined simply by checking the netdev_ops pointer, so the list can be removed.

Compile-tested only.

---
 drivers/net/via-velocity.c |   37 +++----------------------------------
 drivers/net/via-velocity.h |    2 --
 2 files changed, 3 insertions(+), 36 deletions(-)
drivers/net/via-velocity.c +3 -34
index e2a7725..0342d18 100644
@@ -406,9 +406,6 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status);
 static int velocity_suspend(struct pci_dev *pdev, pm_message_t state);
 static int velocity_resume(struct pci_dev *pdev);
 
-static DEFINE_SPINLOCK(velocity_dev_list_lock);
-static LIST_HEAD(velocity_dev_list);
-
 #endif
 
 #if defined(CONFIG_PM) && defined(CONFIG_INET)
@@ -488,14 +485,6 @@ static void __devexit velocity_remove1(struct pci_dev *pdev)
 	struct net_device *dev = pci_get_drvdata(pdev);
 	struct velocity_info *vptr = netdev_priv(dev);
 
-#ifdef CONFIG_PM
-	unsigned long flags;
-
-	spin_lock_irqsave(&velocity_dev_list_lock, flags);
-	if (!list_empty(&velocity_dev_list))
-		list_del(&vptr->list);
-	spin_unlock_irqrestore(&velocity_dev_list_lock, flags);
-#endif
 	unregister_netdev(dev);
 	iounmap(vptr->mac_regs);
 	pci_release_regions(pdev);
@@ -998,15 +987,6 @@ static int __devinit velocity_found1(struct pci_dev *pdev, const struct pci_devi
 	/* and leave the chip powered down */
 
 	pci_set_power_state(pdev, PCI_D3hot);
-#ifdef CONFIG_PM
-	{
-		unsigned long flags;
-
-		spin_lock_irqsave(&velocity_dev_list_lock, flags);
-		list_add(&vptr->list, &velocity_dev_list);
-		spin_unlock_irqrestore(&velocity_dev_list_lock, flags);
-	}
-#endif
 	velocity_nics++;
 out:
 	return ret;
@@ -1062,7 +1042,6 @@ static void __devinit velocity_init_info(struct pci_dev *pdev,
 	vptr->tx.numq = info->txqueue;
 	vptr->multicast_limit = MCAM_SIZE;
 	spin_lock_init(&vptr->lock);
-	INIT_LIST_HEAD(&vptr->list);
 }
 
 /**
@@ -3470,20 +3449,10 @@ static int velocity_netdev_event(struct notifier_block *nb, unsigned long notifi
 {
 	struct in_ifaddr *ifa = (struct in_ifaddr *) ptr;
 	struct net_device *dev = ifa->ifa_dev->dev;
-	struct velocity_info *vptr;
-	unsigned long flags;
 
-	if (dev_net(dev) != &init_net)
-		return NOTIFY_DONE;
-
-	spin_lock_irqsave(&velocity_dev_list_lock, flags);
-	list_for_each_entry(vptr, &velocity_dev_list, list) {
-		if (vptr->dev == dev) {
-			velocity_get_ip(vptr);
-			break;
-		}
-	}
-	spin_unlock_irqrestore(&velocity_dev_list_lock, flags);
+	if (dev_net(dev) == &init_net &&
+	    dev->netdev_ops == &velocity_netdev_ops)
+		velocity_get_ip(netdev_priv(dev));
 
 	return NOTIFY_DONE;
 }
drivers/net/via-velocity.h +0 -2
index 4cd3f6c..6289241 100644
@@ -1499,8 +1499,6 @@ struct velocity_opt {
 #define GET_RD_BY_IDX(vptr, idx)   (vptr->rd_ring[idx])
 
 struct velocity_info {
-	struct list_head list;
-
 	struct pci_dev *pdev;
 	struct net_device *dev;
 
Signature · 1 line
1.6.4.3
maintainer
#1 lore raw

From: Ben Hutchings <[email protected]>
Date: Sun, 25 Oct 2009 20:08:49 +0000

Quoted 8 lines

via-velocity maintains a list of its devices in order to determine whether a netdev notification applies to one of them. That can be determined simply by checking the netdev_ops pointer, so the list can be removed.

Compile-tested only.

Looks good to me, applied to net-next-2.6