]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wan/cosa.c
[MTD] [NAND] fix platform driver hotplug/coldplug
[linux-2.6-omap-h63xx.git] / drivers / net / wan / cosa.c
index ff37bf437a99e3b955e373b12b2070c1ba37b62d..45ddfc9763ccc176004640a3356be0265c6b3dbc 100644 (file)
@@ -90,6 +90,7 @@
 #include <linux/ioport.h>
 #include <linux/netdevice.h>
 #include <linux/spinlock.h>
+#include <linux/mutex.h>
 #include <linux/device.h>
 
 #undef COSA_SLOW_IO    /* for testing purposes only */
@@ -127,7 +128,8 @@ struct channel_data {
        int (*tx_done)(struct channel_data *channel, int size);
 
        /* Character device parts */
-       struct semaphore rsem, wsem;
+       struct mutex rlock;
+       struct semaphore wsem;
        char *rxdata;
        int rxsize;
        wait_queue_head_t txwaitq, rxwaitq;
@@ -395,8 +397,7 @@ static int __init cosa_init(void)
                goto out_chrdev;
        }
        for (i=0; i<nr_cards; i++) {
-               class_device_create(cosa_class, NULL, MKDEV(cosa_major, i),
-                               NULL, "cosa%d", i);
+               device_create(cosa_class, NULL, MKDEV(cosa_major, i), "cosa%d", i);
        }
        err = 0;
        goto out;
@@ -415,7 +416,7 @@ static void __exit cosa_exit(void)
        printk(KERN_INFO "Unloading the cosa module\n");
 
        for (i=0; i<nr_cards; i++)
-               class_device_destroy(cosa_class, MKDEV(cosa_major, i));
+               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 */
@@ -808,7 +809,7 @@ static struct net_device_stats *cosa_net_stats(struct net_device *dev)
 
 static void chardev_channel_init(struct channel_data *chan)
 {
-       init_MUTEX(&chan->rsem);
+       mutex_init(&chan->rlock);
        init_MUTEX(&chan->wsem);
 }
 
@@ -826,12 +827,12 @@ static ssize_t cosa_read(struct file *file,
                        cosa->name, cosa->firmware_status);
                return -EPERM;
        }
-       if (down_interruptible(&chan->rsem))
+       if (mutex_lock_interruptible(&chan->rlock))
                return -ERESTARTSYS;
        
        if ((chan->rxdata = kmalloc(COSA_MTU, GFP_DMA|GFP_KERNEL)) == NULL) {
                printk(KERN_INFO "%s: cosa_read() - OOM\n", cosa->name);
-               up(&chan->rsem);
+               mutex_unlock(&chan->rlock);
                return -ENOMEM;
        }
 
@@ -849,7 +850,7 @@ static ssize_t cosa_read(struct file *file,
                        remove_wait_queue(&chan->rxwaitq, &wait);
                        current->state = TASK_RUNNING;
                        spin_unlock_irqrestore(&cosa->lock, flags);
-                       up(&chan->rsem);
+                       mutex_unlock(&chan->rlock);
                        return -ERESTARTSYS;
                }
        }
@@ -858,7 +859,7 @@ static ssize_t cosa_read(struct file *file,
        kbuf = chan->rxdata;
        count = chan->rxsize;
        spin_unlock_irqrestore(&cosa->lock, flags);
-       up(&chan->rsem);
+       mutex_unlock(&chan->rlock);
 
        if (copy_to_user(buf, kbuf, count)) {
                kfree(kbuf);