aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Kaehlcke <matthias@kaehlcke.net>2008-03-05 21:53:01 -0500
committerDavid S. Miller <davem@davemloft.net>2008-03-05 21:53:01 -0500
commit6387c4bed539539b05fa773cf2ff26529dc3074c (patch)
tree5b96e7489fe45e08a4442ccf97148ad8ad8632f8
parentee6b967301b4aa5d4a4b61e2f682f086266db9fb (diff)
COSA/SRP: convert channel_data.rsem to mutex
COSA/SRP driver: The semaphore channel_data.rsem is used as a mutex, convert it to the mutex API Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/wan/cosa.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index 1d706eae3052..45ddfc9763cc 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -90,6 +90,7 @@
90#include <linux/ioport.h> 90#include <linux/ioport.h>
91#include <linux/netdevice.h> 91#include <linux/netdevice.h>
92#include <linux/spinlock.h> 92#include <linux/spinlock.h>
93#include <linux/mutex.h>
93#include <linux/device.h> 94#include <linux/device.h>
94 95
95#undef COSA_SLOW_IO /* for testing purposes only */ 96#undef COSA_SLOW_IO /* for testing purposes only */
@@ -127,7 +128,8 @@ struct channel_data {
127 int (*tx_done)(struct channel_data *channel, int size); 128 int (*tx_done)(struct channel_data *channel, int size);
128 129
129 /* Character device parts */ 130 /* Character device parts */
130 struct semaphore rsem, wsem; 131 struct mutex rlock;
132 struct semaphore wsem;
131 char *rxdata; 133 char *rxdata;
132 int rxsize; 134 int rxsize;
133 wait_queue_head_t txwaitq, rxwaitq; 135 wait_queue_head_t txwaitq, rxwaitq;
@@ -807,7 +809,7 @@ static struct net_device_stats *cosa_net_stats(struct net_device *dev)
807 809
808static void chardev_channel_init(struct channel_data *chan) 810static void chardev_channel_init(struct channel_data *chan)
809{ 811{
810 init_MUTEX(&chan->rsem); 812 mutex_init(&chan->rlock);
811 init_MUTEX(&chan->wsem); 813 init_MUTEX(&chan->wsem);
812} 814}
813 815
@@ -825,12 +827,12 @@ static ssize_t cosa_read(struct file *file,
825 cosa->name, cosa->firmware_status); 827 cosa->name, cosa->firmware_status);
826 return -EPERM; 828 return -EPERM;
827 } 829 }
828 if (down_interruptible(&chan->rsem)) 830 if (mutex_lock_interruptible(&chan->rlock))
829 return -ERESTARTSYS; 831 return -ERESTARTSYS;
830 832
831 if ((chan->rxdata = kmalloc(COSA_MTU, GFP_DMA|GFP_KERNEL)) == NULL) { 833 if ((chan->rxdata = kmalloc(COSA_MTU, GFP_DMA|GFP_KERNEL)) == NULL) {
832 printk(KERN_INFO "%s: cosa_read() - OOM\n", cosa->name); 834 printk(KERN_INFO "%s: cosa_read() - OOM\n", cosa->name);
833 up(&chan->rsem); 835 mutex_unlock(&chan->rlock);
834 return -ENOMEM; 836 return -ENOMEM;
835 } 837 }
836 838
@@ -848,7 +850,7 @@ static ssize_t cosa_read(struct file *file,
848 remove_wait_queue(&chan->rxwaitq, &wait); 850 remove_wait_queue(&chan->rxwaitq, &wait);
849 current->state = TASK_RUNNING; 851 current->state = TASK_RUNNING;
850 spin_unlock_irqrestore(&cosa->lock, flags); 852 spin_unlock_irqrestore(&cosa->lock, flags);
851 up(&chan->rsem); 853 mutex_unlock(&chan->rlock);
852 return -ERESTARTSYS; 854 return -ERESTARTSYS;
853 } 855 }
854 } 856 }
@@ -857,7 +859,7 @@ static ssize_t cosa_read(struct file *file,
857 kbuf = chan->rxdata; 859 kbuf = chan->rxdata;
858 count = chan->rxsize; 860 count = chan->rxsize;
859 spin_unlock_irqrestore(&cosa->lock, flags); 861 spin_unlock_irqrestore(&cosa->lock, flags);
860 up(&chan->rsem); 862 mutex_unlock(&chan->rlock);
861 863
862 if (copy_to_user(buf, kbuf, count)) { 864 if (copy_to_user(buf, kbuf, count)) {
863 kfree(kbuf); 865 kfree(kbuf);