diff options
author | Shaun Ruffell <sruffell@digium.com> | 2009-01-27 17:01:37 +0000 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2009-01-27 17:01:37 +0000 |
commit | c9445b29679fb5a027992316c89bd271b4939549 (patch) | |
tree | e809880ff1388845a3ca52b493db5c6cc209d00a | |
parent | e40909c8c3d17e4553a9e5c58a1057a0510cd217 (diff) |
Updated wctc4xxp for kernel version 2.6.29.
Closes issue #14285 .
Reported by: tzafrir
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@5842 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r-- | drivers/dahdi/wctc4xxp/base.c | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/drivers/dahdi/wctc4xxp/base.c b/drivers/dahdi/wctc4xxp/base.c index 65e27d8..8ec3279 100644 --- a/drivers/dahdi/wctc4xxp/base.c +++ b/drivers/dahdi/wctc4xxp/base.c @@ -503,6 +503,25 @@ struct wcdte { }; +#ifdef HAVE_NETDEV_PRIV +struct wcdte_netdev_priv { + struct wcdte *wc; +}; +#endif + +static inline struct wcdte * +wcdte_from_netdev(struct net_device *netdev) +{ +#ifdef HAVE_NETDEV_PRIV + struct wcdte_netdev_priv *priv; + priv = netdev_priv(netdev); + return priv->wc; +#else + return netdev->priv; +#endif +} + + static inline void wctc4xxp_set_ready(struct wcdte *wc) { set_bit(DTE_READY, &wc->flags); } @@ -568,7 +587,6 @@ static inline u8 wctc4xxp_dahdifmt_to_dtefmt(unsigned int fmt) return pt; } - static struct sk_buff * tcb_to_skb(struct net_device *netdev, const struct tcb *cmd) { @@ -618,7 +636,7 @@ wctc4xxp_skb_to_cmd(struct wcdte *wc, const struct sk_buff *skb) static void wctc4xxp_net_set_multi(struct net_device *netdev) { - struct wcdte *wc = netdev->priv; + struct wcdte *wc = wcdte_from_netdev(netdev); DTE_DEBUG(DTE_DEBUG_GENERAL, "%s promiscuity:%d\n", __FUNCTION__, netdev->promiscuity); } @@ -626,7 +644,7 @@ wctc4xxp_net_set_multi(struct net_device *netdev) static int wctc4xxp_net_up(struct net_device *netdev) { - struct wcdte *wc = netdev->priv; + struct wcdte *wc = wcdte_from_netdev(netdev); DTE_DEBUG(DTE_DEBUG_GENERAL, "%s\n", __FUNCTION__); #if 1 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) @@ -641,7 +659,7 @@ wctc4xxp_net_up(struct net_device *netdev) static int wctc4xxp_net_down(struct net_device *netdev) { - struct wcdte *wc = netdev->priv; + struct wcdte *wc = wcdte_from_netdev(netdev); DTE_DEBUG(DTE_DEBUG_GENERAL, "%s\n", __FUNCTION__); #if 1 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) @@ -658,7 +676,7 @@ static void wctc4xxp_transmit_cmd(struct wcdte *, struct tcb *); static int wctc4xxp_net_hard_start_xmit(struct sk_buff *skb, struct net_device *netdev) { - struct wcdte *wc = netdev->priv; + struct wcdte *wc = wcdte_from_netdev(netdev); struct tcb *cmd; /* We set DO_NOT_CAPTURE because this packet was already captured by @@ -693,7 +711,7 @@ wctc4xxp_net_receive(struct wcdte *wc, int max) static int wctc4xxp_poll(struct net_device *netdev, int *budget) { - struct wcdte *wc = netdev->priv; + struct wcdte *wc = wcdte_from_netdev(netdev); int count = 0; int quota = min(netdev->quota, *budget); @@ -719,7 +737,11 @@ wctc4xxp_poll(struct napi_struct *napi, int budget) count = wctc4xxp_net_receive(wc, budget); if (!skb_queue_len(&wc->captured_packets)) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) netif_rx_complete(wc->netdev, &wc->napi); +#else + netif_rx_complete(&wc->napi); +#endif } return count; } @@ -728,7 +750,7 @@ wctc4xxp_poll(struct napi_struct *napi, int budget) static struct net_device_stats * wctc4xxp_net_get_stats(struct net_device *netdev) { - struct wcdte *wc = netdev->priv; + struct wcdte *wc = wcdte_from_netdev(netdev); return &wc->net_stats; } @@ -765,7 +787,7 @@ static void wctc4xxp_turn_on_booted_led(struct wcdte *wc); static int wctc4xxp_net_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) { - struct wcdte *wc = netdev->priv; + struct wcdte *wc = wcdte_from_netdev(netdev); switch(cmd) { case 0x89f0: down(&wc->chansem); @@ -794,14 +816,25 @@ wctc4xxp_net_register(struct wcdte *wc) { int res; struct net_device *netdev; +# ifdef HAVE_NETDEV_PRIV + struct wcdte_netdev_priv *priv; +#endif const char our_mac[] = { 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; - if (!(netdev = alloc_netdev(0, wc->board_name, ether_setup))) { +# ifdef HAVE_NETDEV_PRIV + netdev = alloc_netdev(sizeof(struct wcdte_netdev_priv *), + wc->board_name, ether_setup); + if (!netdev) + return -ENOMEM; + priv = netdev_priv(netdev); + priv->wc = wc; +# else + netdev = alloc_netdev(0, wc->board_name, ether_setup); + if (!netdev) return -ENOMEM; - } - - memcpy(netdev->dev_addr, our_mac, sizeof(our_mac)); netdev->priv = wc; +# endif + memcpy(netdev->dev_addr, our_mac, sizeof(our_mac)); netdev->set_multicast_list = &wctc4xxp_net_set_multi; netdev->open = &wctc4xxp_net_up; netdev->stop = &wctc4xxp_net_down; @@ -890,10 +923,12 @@ wctc4xxp_net_capture_cmd(struct wcdte *wc, const struct tcb *cmd) } skb_queue_tail(&wc->captured_packets, skb); -# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) +# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) netif_rx_schedule(netdev); -# else +# elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29) netif_rx_schedule(netdev, &wc->napi); +# else + netif_rx_schedule(&wc->napi); # endif return; } |