cosa: Kill off the use of the old ioctl path
[safe/jmp/linux-2.6] / drivers / net / wan / cosa.c
index f140515..2eceb1a 100644 (file)
@@ -279,7 +279,7 @@ static int cosa_net_attach(struct net_device *dev, unsigned short encoding,
 static int cosa_net_open(struct net_device *d);
 static int cosa_net_close(struct net_device *d);
 static void cosa_net_timeout(struct net_device *d);
-static int cosa_net_tx(struct sk_buff *skb, struct net_device *d);
+static netdev_tx_t cosa_net_tx(struct sk_buff *skb, struct net_device *d);
 static char *cosa_net_setup_rx(struct channel_data *channel, int size);
 static int cosa_net_rx_done(struct channel_data *channel);
 static int cosa_net_tx_done(struct channel_data *channel, int size);
@@ -296,8 +296,8 @@ static ssize_t cosa_write(struct file *file,
 static unsigned int cosa_poll(struct file *file, poll_table *poll);
 static int cosa_open(struct inode *inode, struct file *file);
 static int cosa_release(struct inode *inode, struct file *file);
-static int cosa_chardev_ioctl(struct inode *inode, struct file *file,
-       unsigned int cmd, unsigned long arg);
+static long cosa_chardev_ioctl(struct file *file, unsigned int cmd,
+                               unsigned long arg);
 #ifdef COSA_FASYNC_WORKING
 static int cosa_fasync(struct inode *inode, struct file *file, int on);
 #endif
@@ -308,7 +308,7 @@ static const struct file_operations cosa_fops = {
        .read           = cosa_read,
        .write          = cosa_write,
        .poll           = cosa_poll,
-       .ioctl          = cosa_chardev_ioctl,
+       .unlocked_ioctl = cosa_chardev_ioctl,
        .open           = cosa_open,
        .release        = cosa_release,
 #ifdef COSA_FASYNC_WORKING
@@ -388,8 +388,8 @@ static int __init cosa_init(void)
                goto out_chrdev;
        }
        for (i = 0; i < nr_cards; i++)
-               device_create_drvdata(cosa_class, NULL, MKDEV(cosa_major, i),
-                                     NULL, "cosa%d", i);
+               device_create(cosa_class, NULL, MKDEV(cosa_major, i), NULL,
+                             "cosa%d", i);
        err = 0;
        goto out;
 
@@ -427,6 +427,15 @@ static void __exit cosa_exit(void)
 }
 module_exit(cosa_exit);
 
+static const struct net_device_ops cosa_ops = {
+       .ndo_open       = cosa_net_open,
+       .ndo_stop       = cosa_net_close,
+       .ndo_change_mtu = hdlc_change_mtu,
+       .ndo_start_xmit = hdlc_start_xmit,
+       .ndo_do_ioctl   = cosa_net_ioctl,
+       .ndo_tx_timeout = cosa_net_timeout,
+};
+
 static int cosa_probe(int base, int irq, int dma)
 {
        struct cosa_data *cosa = cosa_cards+nr_cards;
@@ -575,10 +584,7 @@ static int cosa_probe(int base, int irq, int dma)
                }
                dev_to_hdlc(chan->netdev)->attach = cosa_net_attach;
                dev_to_hdlc(chan->netdev)->xmit = cosa_net_tx;
-               chan->netdev->open = cosa_net_open;
-               chan->netdev->stop = cosa_net_close;
-               chan->netdev->do_ioctl = cosa_net_ioctl;
-               chan->netdev->tx_timeout = cosa_net_timeout;
+               chan->netdev->netdev_ops = &cosa_ops;
                chan->netdev->watchdog_timeo = TX_TIMEOUT;
                chan->netdev->base_addr = chan->cosa->datareg;
                chan->netdev->irq = chan->cosa->irq;
@@ -666,7 +672,8 @@ static int cosa_net_open(struct net_device *dev)
        return 0;
 }
 
-static int cosa_net_tx(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t cosa_net_tx(struct sk_buff *skb,
+                                    struct net_device *dev)
 {
        struct channel_data *chan = dev_to_chan(dev);
 
@@ -674,7 +681,7 @@ static int cosa_net_tx(struct sk_buff *skb, struct net_device *dev)
 
        chan->tx_skb = skb;
        cosa_start_tx(chan, skb->data, skb->len);
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 static void cosa_net_timeout(struct net_device *dev)
@@ -725,8 +732,7 @@ static char *cosa_net_setup_rx(struct channel_data *chan, int size)
         * We can safely fall back to non-dma-able memory, because we have
         * the cosa->bouncebuf pre-allocated.
         */
-       if (chan->rx_skb)
-               kfree_skb(chan->rx_skb);
+       kfree_skb(chan->rx_skb);
        chan->rx_skb = dev_alloc_skb(size);
        if (chan->rx_skb == NULL) {
                printk(KERN_NOTICE "%s: Memory squeeze, dropping packet\n",
@@ -754,7 +760,6 @@ static int cosa_net_rx_done(struct channel_data *chan)
        chan->netdev->stats.rx_bytes += chan->cosa->rxsize;
        netif_rx(chan->rx_skb);
        chan->rx_skb = NULL;
-       chan->netdev->last_rx = jiffies;
        return 0;
 }
 
@@ -994,8 +999,8 @@ static struct fasync_struct *fasync[256] = { NULL, };
 static int cosa_fasync(struct inode *inode, struct file *file, int on)
 {
         int port = iminor(inode);
-        int rv = fasync_helper(inode, file, on, &fasync[port]);
-        return rv < 0 ? rv : 0;
+
+       return fasync_helper(inode, file, on, &fasync[port]);
 }
 #endif
 
@@ -1198,12 +1203,18 @@ static int cosa_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        return hdlc_ioctl(dev, ifr, cmd);
 }
 
-static int cosa_chardev_ioctl(struct inode *inode, struct file *file,
-       unsigned int cmd, unsigned long arg)
+static long cosa_chardev_ioctl(struct file *file, unsigned int cmd,
+                                                       unsigned long arg)
 {
        struct channel_data *channel = file->private_data;
-       struct cosa_data *cosa = channel->cosa;
-       return cosa_ioctl_common(cosa, channel, cmd, arg);
+       struct cosa_data *cosa;
+       long ret;
+
+       lock_kernel();
+       cosa = channel->cosa;
+       ret = cosa_ioctl_common(cosa, channel, cmd, arg);
+       unlock_kernel();
+       return ret;
 }
 
 \f