Staging: bcm: fix up network device reference counting
authorGreg Kroah-Hartman <gregkh@suse.de>
Thu, 28 Oct 2010 16:54:23 +0000 (09:54 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 28 Oct 2010 16:54:23 +0000 (09:54 -0700)
The way network devices are reference counted does not include poking
around in the reference count itself.  This breaks when the reference
count is changed to be a different type.  Fix the driver to do the
proper function calls instead.

Cc: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/bcm/Bcmnet.c

index bb9260c6845eb1059f3950049674cad4007c26d1..bc296982142132ad6384d13a0e84a3be24bf837b 100644 (file)
@@ -22,17 +22,15 @@ static INT bcm_notify_event(struct notifier_block *nb, ULONG event, PVOID dev)
                        case NETDEV_REGISTER:
                                 /* Increment the Reference Count for "veth0" */
                                 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Register RefCount: %x\n",
-                                                                       atomic_read(&ndev->refcnt));
-                                atomic_inc(&ndev->refcnt);
+                                                                       netdev_refcnt_read(ndev));
+                                dev_hold(ndev);
                                 break;
 
                        case NETDEV_UNREGISTER:
                                 /* Decrement the Reference Count for "veth0" */
                                BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Unregister RefCnt: %x\n",
-                                                                       atomic_read(&ndev->refcnt));
-                               atomic_dec(&ndev->refcnt);
-                               if((int)atomic_read(&ndev->refcnt) < 0)
-                                       atomic_set(&ndev->refcnt, 0);
+                                                                       netdev_refcnt_read(ndev));
+                               dev_put(ndev);
                                break;
                };
        }