netpoll: Add ndo_netpoll_setup
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 10 Jun 2010 16:12:47 +0000 (16:12 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 15 Jun 2010 17:58:39 +0000 (10:58 -0700)
This patch adds ndo_netpoll_setup as the initialisation primitive
to complement ndo_netpoll_cleanup.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netdevice.h
net/core/netpoll.c

index 4fbccc5f609af0af89514c55a9c535110570aee5..fb20cc55ba522dbe383dbfa88049c9cf3e260b2f 100644 (file)
@@ -744,6 +744,8 @@ struct net_device_ops {
                                                        unsigned short vid);
 #ifdef CONFIG_NET_POLL_CONTROLLER
        void                    (*ndo_poll_controller)(struct net_device *dev);
+       int                     (*ndo_netpoll_setup)(struct net_device *dev,
+                                                    struct netpoll_info *info);
        void                    (*ndo_netpoll_cleanup)(struct net_device *dev);
 #endif
        int                     (*ndo_set_vf_mac)(struct net_device *dev,
index d10c249bcc8f80b77b7f193bfa7eaf78c4f4b930..7de6dcad5d79dba90997c7b4ca8c601a7329418f 100644 (file)
@@ -698,6 +698,7 @@ int netpoll_setup(struct netpoll *np)
        struct net_device *ndev = NULL;
        struct in_device *in_dev;
        struct netpoll_info *npinfo;
+       const struct net_device_ops *ops;
        unsigned long flags;
        int err;
 
@@ -797,6 +798,13 @@ int netpoll_setup(struct netpoll *np)
                INIT_DELAYED_WORK(&npinfo->tx_work, queue_process);
 
                atomic_set(&npinfo->refcnt, 1);
+
+               ops = np->dev->netdev_ops;
+               if (ops->ndo_netpoll_setup) {
+                       err = ops->ndo_netpoll_setup(ndev, npinfo);
+                       if (err)
+                               goto free_npinfo;
+               }
        } else {
                npinfo = ndev->npinfo;
                atomic_inc(&npinfo->refcnt);
@@ -817,6 +825,8 @@ int netpoll_setup(struct netpoll *np)
 
        return 0;
 
+free_npinfo:
+       kfree(npinfo);
 unlock:
        rtnl_unlock();
 put: