include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / isdn / i4l / isdn_net.c
index 023ea11..8c85d1e 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include <linux/isdn.h>
+#include <linux/slab.h>
 #include <net/arp.h>
 #include <net/dst.h>
 #include <net/pkt_sched.h>
@@ -176,7 +177,8 @@ static __inline__ void isdn_net_zero_frame_cnt(isdn_net_local *lp)
 /* Prototypes */
 
 static int isdn_net_force_dial_lp(isdn_net_local *);
-static int isdn_net_start_xmit(struct sk_buff *, struct net_device *);
+static netdev_tx_t isdn_net_start_xmit(struct sk_buff *,
+                                            struct net_device *);
 
 static void isdn_net_ciscohdlck_connected(isdn_net_local *lp);
 static void isdn_net_ciscohdlck_disconnected(isdn_net_local *lp);
@@ -292,7 +294,9 @@ isdn_net_unbind_channel(isdn_net_local * lp)
        lp->dialstate = 0;
        dev->rx_netdev[isdn_dc2minor(lp->isdn_device, lp->isdn_channel)] = NULL;
        dev->st_netdev[isdn_dc2minor(lp->isdn_device, lp->isdn_channel)] = NULL;
-       isdn_free_channel(lp->isdn_device, lp->isdn_channel, ISDN_USAGE_NET);
+       if (lp->isdn_device != -1 && lp->isdn_channel != -1)
+               isdn_free_channel(lp->isdn_device, lp->isdn_channel,
+                                 ISDN_USAGE_NET);
        lp->flags &= ~ISDN_NET_CONNECTED;
        lp->isdn_device = -1;
        lp->isdn_channel = -1;
@@ -1049,12 +1053,12 @@ isdn_net_xmit(struct net_device *ndev, struct sk_buff *skb)
        isdn_net_dev *nd;
        isdn_net_local *slp;
        isdn_net_local *lp = (isdn_net_local *) netdev_priv(ndev);
-       int retv = 0;
+       int retv = NETDEV_TX_OK;
 
        if (((isdn_net_local *) netdev_priv(ndev))->master) {
                printk("isdn BUG at %s:%d!\n", __FILE__, __LINE__);
                dev_kfree_skb(skb);
-               return 0;
+               return NETDEV_TX_OK;
        }
 
        /* For the other encaps the header has already been built */
@@ -1067,7 +1071,7 @@ isdn_net_xmit(struct net_device *ndev, struct sk_buff *skb)
        lp = isdn_net_get_locked_lp(nd);
        if (!lp) {
                printk(KERN_WARNING "%s: all channels busy - requeuing!\n", ndev->name);
-               return 1;
+               return NETDEV_TX_BUSY;
        }
        /* we have our lp locked from now on */
 
@@ -1158,7 +1162,7 @@ static void isdn_net_tx_timeout(struct net_device * ndev)
  * If this interface isn't connected to a ISDN-Channel, find a free channel,
  * and start dialing.
  */
-static int
+static netdev_tx_t
 isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 {
        isdn_net_local *lp = (isdn_net_local *) netdev_priv(ndev);
@@ -1200,7 +1204,7 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev)
                        if (!(ISDN_NET_DIALMODE(*lp) == ISDN_NET_DM_AUTO)) {
                                isdn_net_unreachable(ndev, skb, "dial rejected: interface not in dialmode `auto'");
                                dev_kfree_skb(skb);
-                               return 0;
+                               return NETDEV_TX_OK;
                        }
                        if (lp->phone[1]) {
                                ulong flags;
@@ -1213,7 +1217,7 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev)
                                        if(time_before(jiffies, lp->dialwait_timer)) {
                                                isdn_net_unreachable(ndev, skb, "dial rejected: retry-time not reached");
                                                dev_kfree_skb(skb);
-                                               return 0;
+                                               return NETDEV_TX_OK;
                                        } else
                                                lp->dialwait_timer = 0;
                                }
@@ -1241,7 +1245,7 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev)
                                        isdn_net_unreachable(ndev, skb,
                                                           "No channel");
                                        dev_kfree_skb(skb);
-                                       return 0;
+                                       return NETDEV_TX_OK;
                                }
                                /* Log packet, which triggered dialing */
                                if (dev->net_verbose)
@@ -1256,7 +1260,7 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev)
                                                dev_kfree_skb(skb);
                                                isdn_net_unbind_channel(lp);
                                                spin_unlock_irqrestore(&dev->lock, flags);
-                                               return 0;       /* STN (skb to nirvana) ;) */
+                                               return NETDEV_TX_OK;    /* STN (skb to nirvana) ;) */
                                        }
 #ifdef CONFIG_IPPP_FILTER
                                        if (isdn_ppp_autodial_filter(skb, lp)) {
@@ -1265,25 +1269,25 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev)
                                                spin_unlock_irqrestore(&dev->lock, flags);
                                                isdn_net_unreachable(ndev, skb, "dial rejected: packet filtered");
                                                dev_kfree_skb(skb);
-                                               return 0;
+                                               return NETDEV_TX_OK;
                                        }
 #endif
                                        spin_unlock_irqrestore(&dev->lock, flags);
                                        isdn_net_dial();        /* Initiate dialing */
                                        netif_stop_queue(ndev);
-                                       return 1;       /* let upper layer requeue skb packet */
+                                       return NETDEV_TX_BUSY;  /* let upper layer requeue skb packet */
                                }
 #endif
                                /* Initiate dialing */
                                spin_unlock_irqrestore(&dev->lock, flags);
                                isdn_net_dial();
                                isdn_net_device_stop_queue(lp);
-                               return 1;
+                               return NETDEV_TX_BUSY;
                        } else {
                                isdn_net_unreachable(ndev, skb,
                                                     "No phone number");
                                dev_kfree_skb(skb);
-                               return 0;
+                               return NETDEV_TX_OK;
                        }
                } else {
                        /* Device is connected to an ISDN channel */ 
@@ -1298,7 +1302,7 @@ isdn_net_start_xmit(struct sk_buff *skb, struct net_device *ndev)
                                netif_stop_queue(ndev);
                }
        }
-       return 1;
+       return NETDEV_TX_BUSY;
 }
 
 /*
@@ -1485,6 +1489,24 @@ isdn_ciscohdlck_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        return (rc);
 }
 
+
+static int isdn_net_ioctl(struct net_device *dev,
+                         struct ifreq *ifr, int cmd)
+{
+       isdn_net_local *lp = (isdn_net_local *) netdev_priv(dev);
+
+       switch (lp->p_encap) {
+#ifdef CONFIG_ISDN_PPP
+       case ISDN_NET_ENCAP_SYNCPPP:
+               return isdn_ppp_dev_ioctl(dev, ifr, cmd);
+#endif
+       case ISDN_NET_ENCAP_CISCOHDLCK:
+               return isdn_ciscohdlck_dev_ioctl(dev, ifr, cmd);
+       default:
+               return -EINVAL;
+       }
+}
+
 /* called via cisco_timer.function */
 static void
 isdn_net_ciscohdlck_slarp_send_keepalive(unsigned long data)
@@ -1542,7 +1564,7 @@ isdn_net_ciscohdlck_slarp_send_keepalive(unsigned long data)
        *(__be32 *)(p +  4) = cpu_to_be32(CISCO_SLARP_KEEPALIVE);
        *(__be32 *)(p +  8) = cpu_to_be32(lp->cisco_myseq);
        *(__be32 *)(p + 12) = cpu_to_be32(lp->cisco_yourseq);
-       *(__be16 *)(p + 16) = cpu_to_be16(0xffff); // reliablity, always 0xffff
+       *(__be16 *)(p + 16) = cpu_to_be16(0xffff); // reliability, always 0xffff
        p += 18;
 
        isdn_net_write_super(lp, skb);
@@ -1998,23 +2020,6 @@ isdn_net_init(struct net_device *ndev)
        ushort max_hlhdr_len = 0;
        int drvidx;
 
-       ether_setup(ndev);
-       ndev->header_ops = NULL;
-
-       /* Setup the generic properties */
-       ndev->mtu = 1500;
-       ndev->flags = IFF_NOARP|IFF_POINTOPOINT;
-       ndev->type = ARPHRD_ETHER;
-       ndev->addr_len = ETH_ALEN;
-       ndev->validate_addr = NULL;
-
-       /* for clients with MPPP maybe higher values better */
-       ndev->tx_queue_len = 30;
-
-       /* The ISDN-specific entries in the device structure. */
-       ndev->open = &isdn_net_open;
-       ndev->hard_start_xmit = &isdn_net_start_xmit;
-
        /*
         *  up till binding we ask the protocol layer to reserve as much
         *  as we might need for HL layer
@@ -2026,9 +2031,6 @@ isdn_net_init(struct net_device *ndev)
                                max_hlhdr_len = dev->drv[drvidx]->interface->hl_hdrlen;
 
        ndev->hard_header_len = ETH_HLEN + max_hlhdr_len;
-       ndev->stop = &isdn_net_close;
-       ndev->get_stats = &isdn_net_get_stats;
-       ndev->do_ioctl = NULL;
        return 0;
 }
 
@@ -2508,6 +2510,18 @@ isdn_net_force_dial(char *name)
        return (isdn_net_force_dial_lp(p->local));
 }
 
+/* The ISDN-specific entries in the device structure. */
+static const struct net_device_ops isdn_netdev_ops = {
+       .ndo_init             = isdn_net_init,
+       .ndo_open             = isdn_net_open,
+       .ndo_stop             = isdn_net_close,
+       .ndo_do_ioctl         = isdn_net_ioctl,
+
+       .ndo_start_xmit       = isdn_net_start_xmit,
+       .ndo_get_stats        = isdn_net_get_stats,
+       .ndo_tx_timeout       = isdn_net_tx_timeout,
+};
+
 /*
  * Helper for alloc_netdev()
  */
@@ -2515,7 +2529,16 @@ static void _isdn_setup(struct net_device *dev)
 {
        isdn_net_local *lp = netdev_priv(dev);
 
-       dev->flags = IFF_NOARP | IFF_POINTOPOINT;
+       ether_setup(dev);
+
+       /* Setup the generic properties */
+       dev->flags = IFF_NOARP|IFF_POINTOPOINT;
+       dev->header_ops = NULL;
+       dev->netdev_ops = &isdn_netdev_ops;
+
+       /* for clients with MPPP maybe higher values better */
+       dev->tx_queue_len = 30;
+
        lp->p_encap = ISDN_NET_ENCAP_RAWIP;
        lp->magic = ISDN_NET_MAGIC;
        lp->last = lp;
@@ -2570,7 +2593,7 @@ isdn_net_new(char *name, struct net_device *master)
                return NULL;
        }
        netdev->local = netdev_priv(netdev->dev);
-       netdev->dev->init = isdn_net_init;
+
        if (master) {
                /* Device shall be a slave */
                struct net_device *p = MASTER_TO_SLAVE(master);
@@ -2588,7 +2611,6 @@ isdn_net_new(char *name, struct net_device *master)
                /*
                 * Watchdog timer (currently) for master only.
                 */
-               netdev->dev->tx_timeout = isdn_net_tx_timeout;
                netdev->dev->watchdog_timeo = ISDN_NET_TX_TIMEOUT;
                if (register_netdev(netdev->dev) != 0) {
                        printk(KERN_WARNING "isdn_net: Could not register net-device\n");
@@ -2704,7 +2726,6 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg)
 #else
                        p->dev->type = ARPHRD_PPP;      /* change ARP type */
                        p->dev->addr_len = 0;
-                       p->dev->do_ioctl = isdn_ppp_dev_ioctl;
 #endif
                        break;
                case ISDN_NET_ENCAP_X25IFACE:
@@ -2718,7 +2739,6 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg)
 #endif
                        break;
                case ISDN_NET_ENCAP_CISCOHDLCK:
-                       p->dev->do_ioctl = isdn_ciscohdlck_dev_ioctl;
                        break;
                default:
                        if( cfg->p_encap >= 0 &&