[SCSI] gdth: Convert to use regular kernel types.
[safe/jmp/linux-2.6] / drivers / net / hamradio / mkiss.c
index a728650..7db0a1c 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/skbuff.h>
 #include <linux/if_arp.h>
 #include <linux/jiffies.h>
+#include <linux/compat.h>
 
 #include <net/ax25.h>
 
@@ -244,22 +245,21 @@ static int kiss_esc_crc(unsigned char *s, unsigned char *d, unsigned short crc,
 /* Send one completely decapsulated AX.25 packet to the AX.25 layer. */
 static void ax_bump(struct mkiss *ax)
 {
-       unsigned long flags;
        struct sk_buff *skb;
        int count;
 
-       spin_lock_irqsave(&ax->buflock, flags);
+       spin_lock_bh(&ax->buflock);
        if (ax->rbuff[0] > 0x0f) {
                if (ax->rbuff[0] & 0x80) {
                        if (check_crc_16(ax->rbuff, ax->rcount) < 0) {
                                ax->dev->stats.rx_errors++;
-                               spin_unlock_irqrestore(&ax->buflock, flags);
+                               spin_unlock_bh(&ax->buflock);
 
                                return;
                        }
                        if (ax->crcmode != CRC_MODE_SMACK && ax->crcauto) {
                                printk(KERN_INFO
-                                      "mkiss: %s: Switchting to crc-smack\n",
+                                      "mkiss: %s: Switching to crc-smack\n",
                                       ax->dev->name);
                                ax->crcmode = CRC_MODE_SMACK;
                        }
@@ -268,12 +268,12 @@ static void ax_bump(struct mkiss *ax)
                } else if (ax->rbuff[0] & 0x20)  {
                        if (check_crc_flex(ax->rbuff, ax->rcount) < 0) {
                                ax->dev->stats.rx_errors++;
-                               spin_unlock_irqrestore(&ax->buflock, flags);
+                               spin_unlock_bh(&ax->buflock);
                                return;
                        }
                        if (ax->crcmode != CRC_MODE_FLEX && ax->crcauto) {
                                printk(KERN_INFO
-                                      "mkiss: %s: Switchting to crc-flexnet\n",
+                                      "mkiss: %s: Switching to crc-flexnet\n",
                                       ax->dev->name);
                                ax->crcmode = CRC_MODE_FLEX;
                        }
@@ -295,7 +295,7 @@ static void ax_bump(struct mkiss *ax)
                printk(KERN_ERR "mkiss: %s: memory squeeze, dropping packet.\n",
                       ax->dev->name);
                ax->dev->stats.rx_dropped++;
-               spin_unlock_irqrestore(&ax->buflock, flags);
+               spin_unlock_bh(&ax->buflock);
                return;
        }
 
@@ -304,13 +304,11 @@ static void ax_bump(struct mkiss *ax)
        netif_rx(skb);
        ax->dev->stats.rx_packets++;
        ax->dev->stats.rx_bytes += count;
-       spin_unlock_irqrestore(&ax->buflock, flags);
+       spin_unlock_bh(&ax->buflock);
 }
 
 static void kiss_unesc(struct mkiss *ax, unsigned char s)
 {
-       unsigned long flags;
-
        switch (s) {
        case END:
                /* drop keeptest bit = VSV */
@@ -337,18 +335,18 @@ static void kiss_unesc(struct mkiss *ax, unsigned char s)
                break;
        }
 
-       spin_lock_irqsave(&ax->buflock, flags);
+       spin_lock_bh(&ax->buflock);
        if (!test_bit(AXF_ERROR, &ax->flags)) {
                if (ax->rcount < ax->buffsize) {
                        ax->rbuff[ax->rcount++] = s;
-                       spin_unlock_irqrestore(&ax->buflock, flags);
+                       spin_unlock_bh(&ax->buflock);
                        return;
                }
 
                ax->dev->stats.rx_over_errors++;
                set_bit(AXF_ERROR, &ax->flags);
        }
-       spin_unlock_irqrestore(&ax->buflock, flags);
+       spin_unlock_bh(&ax->buflock);
 }
 
 static int ax_set_mac_address(struct net_device *dev, void *addr)
@@ -370,7 +368,6 @@ static void ax_changedmtu(struct mkiss *ax)
 {
        struct net_device *dev = ax->dev;
        unsigned char *xbuff, *rbuff, *oxbuff, *orbuff;
-       unsigned long flags;
        int len;
 
        len = dev->mtu * 2;
@@ -396,7 +393,7 @@ static void ax_changedmtu(struct mkiss *ax)
                return;
        }
 
-       spin_lock_irqsave(&ax->buflock, flags);
+       spin_lock_bh(&ax->buflock);
 
        oxbuff    = ax->xbuff;
        ax->xbuff = xbuff;
@@ -427,7 +424,7 @@ static void ax_changedmtu(struct mkiss *ax)
        ax->mtu      = dev->mtu + 73;
        ax->buffsize = len;
 
-       spin_unlock_irqrestore(&ax->buflock, flags);
+       spin_unlock_bh(&ax->buflock);
 
        kfree(oxbuff);
        kfree(orbuff);
@@ -437,7 +434,6 @@ static void ax_changedmtu(struct mkiss *ax)
 static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
 {
        struct mkiss *ax = netdev_priv(dev);
-       unsigned long flags;
        unsigned char *p;
        int actual, count;
 
@@ -454,7 +450,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
 
        p = icp;
 
-       spin_lock_irqsave(&ax->buflock, flags);
+       spin_lock_bh(&ax->buflock);
        if ((*p & 0x0f) != 0) {
                /* Configuration Command (kissparms(1).
                 * Protocol spec says: never append CRC.
@@ -484,7 +480,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
                                ax->crcauto = (cmd ? 0 : 1);
                                printk(KERN_INFO "mkiss: %s: crc mode %s %d\n", ax->dev->name, (len) ? "set to" : "is", cmd);
                        }
-                       spin_unlock_irqrestore(&ax->buflock, flags);
+                       spin_unlock_bh(&ax->buflock);
                        netif_start_queue(dev);
 
                        return;
@@ -517,7 +513,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
                        count = kiss_esc(p, (unsigned char *)ax->xbuff, len);
                }
        }
-       spin_unlock_irqrestore(&ax->buflock, flags);
+       spin_unlock_bh(&ax->buflock);
 
        set_bit(TTY_DO_WRITE_WAKEUP, &ax->tty->flags);
        actual = ax->tty->ops->write(ax->tty, ax->xbuff, count);
@@ -530,7 +526,7 @@ static void ax_encaps(struct net_device *dev, unsigned char *icp, int len)
 }
 
 /* Encapsulate an AX.25 packet and kick it into a TTY queue. */
-static int ax_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t ax_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct mkiss *ax = netdev_priv(dev);
 
@@ -565,7 +561,7 @@ static int ax_xmit(struct sk_buff *skb, struct net_device *dev)
                kfree_skb(skb);
        }
 
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 static int ax_open_dev(struct net_device *dev)
@@ -709,14 +705,13 @@ static DEFINE_RWLOCK(disc_data_lock);
 
 static struct mkiss *mkiss_get(struct tty_struct *tty)
 {
-       unsigned long flags;
        struct mkiss *ax;
 
-       read_lock_irqsave(&disc_data_lock, flags);
+       read_lock(&disc_data_lock);
        ax = tty->disc_data;
        if (ax)
                atomic_inc(&ax->refcnt);
-       read_unlock_irqrestore(&disc_data_lock, flags);
+       read_unlock(&disc_data_lock);
 
        return ax;
 }
@@ -815,13 +810,12 @@ out:
 
 static void mkiss_close(struct tty_struct *tty)
 {
-       unsigned long flags;
        struct mkiss *ax;
 
-       write_lock_irqsave(&disc_data_lock, flags);
+       write_lock(&disc_data_lock);
        ax = tty->disc_data;
        tty->disc_data = NULL;
-       write_unlock_irqrestore(&disc_data_lock, flags);
+       write_unlock(&disc_data_lock);
 
        if (!ax)
                return;
@@ -905,6 +899,23 @@ static int mkiss_ioctl(struct tty_struct *tty, struct file *file,
        return err;
 }
 
+#ifdef CONFIG_COMPAT
+static long mkiss_compat_ioctl(struct tty_struct *tty, struct file *file,
+       unsigned int cmd, unsigned long arg)
+{
+       switch (cmd) {
+       case SIOCGIFNAME:
+       case SIOCGIFENCAP:
+       case SIOCSIFENCAP:
+       case SIOCSIFHWADDR:
+               return mkiss_ioctl(tty, file, cmd,
+                                  (unsigned long)compat_ptr(arg));
+       }
+
+       return -ENOIOCTLCMD;
+}
+#endif
+
 /*
  * Handle the 'receiver data ready' interrupt.
  * This function is called by the 'tty_io' module in the kernel when
@@ -979,6 +990,9 @@ static struct tty_ldisc_ops ax_ldisc = {
        .open           = mkiss_open,
        .close          = mkiss_close,
        .ioctl          = mkiss_ioctl,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl   = mkiss_compat_ioctl,
+#endif
        .receive_buf    = mkiss_receive_buf,
        .write_wakeup   = mkiss_write_wakeup
 };