Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 90040
b: refs/heads/master
c: 6387c4b
h: refs/heads/master
v: v3
  • Loading branch information
Matthias Kaehlcke authored and David S. Miller committed Mar 6, 2008
1 parent fff60f5 commit 37f8284
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ee6b967301b4aa5d4a4b61e2f682f086266db9fb
refs/heads/master: 6387c4bed539539b05fa773cf2ff26529dc3074c
14 changes: 8 additions & 6 deletions trunk/drivers/net/wan/cosa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -807,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);
}

Expand All @@ -825,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;
}

Expand All @@ -848,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;
}
}
Expand All @@ -857,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);
Expand Down

0 comments on commit 37f8284

Please sign in to comment.