fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / net / wan / cosa.c
index dbd7901..6c7dfb5 100644 (file)
 \f
 /* ---------- Headers, macros, data structures ---------- */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/poll.h>
 #include <linux/fs.h>
-#include <linux/devfs_fs_kernel.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
@@ -156,7 +154,7 @@ struct cosa_data {
        unsigned short startaddr;       /* Firmware start address */
        unsigned short busmaster;       /* Use busmastering? */
        int nchannels;                  /* # of channels on this card */
-       int driver_status;              /* For communicating with firware */
+       int driver_status;              /* For communicating with firmware */
        int firmware_status;            /* Downloaded, reseted, etc. */
        long int rxbitmap, txbitmap;    /* Bitmap of channels who are willing to send/receive data */
        long int rxtx;                  /* RX or TX in progress? */
@@ -235,14 +233,14 @@ static int dma[MAX_CARDS+1];
 static int irq[MAX_CARDS+1] = { -1, -1, -1, -1, -1, -1, 0, };
 
 /* for class stuff*/
-static struct class_simple *cosa_class;
+static struct class *cosa_class;
 
 #ifdef MODULE
-MODULE_PARM(io, "1-" __MODULE_STRING(MAX_CARDS) "i");
+module_param_array(io, int, NULL, 0);
 MODULE_PARM_DESC(io, "The I/O bases of the COSA or SRP cards");
-MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_CARDS) "i");
+module_param_array(irq, int, NULL, 0);
 MODULE_PARM_DESC(irq, "The IRQ lines of the COSA or SRP cards");
-MODULE_PARM(dma, "1-" __MODULE_STRING(MAX_CARDS) "i");
+module_param_array(dma, int, NULL, 0);
 MODULE_PARM_DESC(dma, "The DMA channels of the COSA or SRP cards");
 
 MODULE_AUTHOR("Jan \"Yenya\" Kasprzak, <kas@fi.muni.cz>");
@@ -347,7 +345,7 @@ static void put_driver_status(struct cosa_data *cosa);
 static void put_driver_status_nolock(struct cosa_data *cosa);
 
 /* Interrupt handling */
-static irqreturn_t cosa_interrupt(int irq, void *cosa, struct pt_regs *regs);
+static irqreturn_t cosa_interrupt(int irq, void *cosa);
 
 /* I/O ops debugging */
 #ifdef DEBUG_IO
@@ -393,22 +391,14 @@ static int __init cosa_init(void)
                err = -ENODEV;
                goto out;
        }
-       devfs_mk_dir("cosa");
-       cosa_class = class_simple_create(THIS_MODULE, "cosa");
+       cosa_class = class_create(THIS_MODULE, "cosa");
        if (IS_ERR(cosa_class)) {
                err = PTR_ERR(cosa_class);
                goto out_chrdev;
        }
        for (i=0; i<nr_cards; i++) {
-               class_simple_device_add(cosa_class, MKDEV(cosa_major, i),
+               class_device_create(cosa_class, NULL, MKDEV(cosa_major, i),
                                NULL, "cosa%d", i);
-               err = devfs_mk_cdev(MKDEV(cosa_major, i),
-                               S_IFCHR|S_IRUSR|S_IWUSR,
-                               "cosa/%d", i);
-               if (err) {
-                       class_simple_device_remove(MKDEV(cosa_major, i));
-                       goto out_chrdev;                
-               }
        }
        err = 0;
        goto out;
@@ -426,12 +416,9 @@ static void __exit cosa_exit(void)
        int i;
        printk(KERN_INFO "Unloading the cosa module\n");
 
-       for (i=0; i<nr_cards; i++) {
-               class_simple_device_remove(MKDEV(cosa_major, i));
-               devfs_remove("cosa/%d", i);
-       }
-       class_simple_destroy(cosa_class);
-       devfs_remove("cosa");
+       for (i=0; i<nr_cards; i++)
+               class_device_destroy(cosa_class, MKDEV(cosa_major, i));
+       class_destroy(cosa_class);
        for (cosa=cosa_cards; nr_cards--; cosa++) {
                /* Clean up the per-channel data */
                for (i=0; i<cosa->nchannels; i++) {
@@ -543,7 +530,7 @@ static int cosa_probe(int base, int irq, int dma)
                 * FIXME: When this code is not used as module, we should
                 * probably call udelay() instead of the interruptible sleep.
                 */
-               current->state = TASK_INTERRUPTIBLE;
+               set_current_state(TASK_INTERRUPTIBLE);
                cosa_putstatus(cosa, SR_TX_INT_ENA);
                schedule_timeout(30);
                irq = probe_irq_off(irqs);
@@ -642,11 +629,11 @@ static void sppp_channel_init(struct channel_data *chan)
                return;
        }
        chan->pppdev.dev = d;
-       sppp_attach(&chan->pppdev);
        d->base_addr = chan->cosa->datareg;
        d->irq = chan->cosa->irq;
        d->dma = chan->cosa->dma;
        d->priv = chan;
+       sppp_attach(&chan->pppdev);
        if (register_netdev(d)) {
                printk(KERN_WARNING "%s: register_netdev failed.\n", d->name);
                sppp_detach(d);
@@ -987,12 +974,12 @@ static int cosa_open(struct inode *inode, struct file *file)
        unsigned long flags;
        int n;
 
-       if ((n=iminor(file->f_dentry->d_inode)>>CARD_MINOR_BITS)
+       if ((n=iminor(file->f_path.dentry->d_inode)>>CARD_MINOR_BITS)
                >= nr_cards)
                return -ENODEV;
        cosa = cosa_cards+n;
 
-       if ((n=iminor(file->f_dentry->d_inode)
+       if ((n=iminor(file->f_path.dentry->d_inode)
                & ((1<<CARD_MINOR_BITS)-1)) >= cosa->nchannels)
                return -ENODEV;
        chan = cosa->chan + n;
@@ -1564,8 +1551,7 @@ static int cosa_reset_and_read_id(struct cosa_data *cosa, char *idstring)
        cosa_getdata8(cosa);
        cosa_putstatus(cosa, SR_RST);
 #ifdef MODULE
-       current->state = TASK_INTERRUPTIBLE;
-       schedule_timeout(HZ/2);
+       msleep(500);
 #else
        udelay(5*100000);
 #endif
@@ -1618,8 +1604,7 @@ static int get_wait_data(struct cosa_data *cosa)
                        return r;
                }
                /* sleep if not ready to read */
-               current->state = TASK_INTERRUPTIBLE;
-               schedule_timeout(1);
+               schedule_timeout_interruptible(1);
        }
        printk(KERN_INFO "cosa: timeout in get_wait_data (status 0x%x)\n",
                cosa_getstatus(cosa));
@@ -1645,8 +1630,7 @@ static int put_wait_data(struct cosa_data *cosa, int data)
                }
 #if 0
                /* sleep if not ready to read */
-               current->state = TASK_INTERRUPTIBLE;
-               schedule_timeout(1);
+               schedule_timeout_interruptible(1);
 #endif
        }
        printk(KERN_INFO "cosa%d: timeout in put_wait_data (status 0x%x)\n",
@@ -1988,7 +1972,7 @@ out:
        spin_unlock_irqrestore(&cosa->lock, flags);
 }
 
-static irqreturn_t cosa_interrupt(int irq, void *cosa_, struct pt_regs *regs)
+static irqreturn_t cosa_interrupt(int irq, void *cosa_)
 {
        unsigned status;
        int count = 0;