mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-07 07:08:07 +00:00
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>
This commit is contained in:
parent
ee6b967301
commit
6387c4bed5
1 changed files with 8 additions and 6 deletions
|
@ -90,6 +90,7 @@
|
||||||
#include <linux/ioport.h>
|
#include <linux/ioport.h>
|
||||||
#include <linux/netdevice.h>
|
#include <linux/netdevice.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
|
#include <linux/mutex.h>
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
|
|
||||||
#undef COSA_SLOW_IO /* for testing purposes only */
|
#undef COSA_SLOW_IO /* for testing purposes only */
|
||||||
|
@ -127,7 +128,8 @@ struct channel_data {
|
||||||
int (*tx_done)(struct channel_data *channel, int size);
|
int (*tx_done)(struct channel_data *channel, int size);
|
||||||
|
|
||||||
/* Character device parts */
|
/* Character device parts */
|
||||||
struct semaphore rsem, wsem;
|
struct mutex rlock;
|
||||||
|
struct semaphore wsem;
|
||||||
char *rxdata;
|
char *rxdata;
|
||||||
int rxsize;
|
int rxsize;
|
||||||
wait_queue_head_t txwaitq, rxwaitq;
|
wait_queue_head_t txwaitq, rxwaitq;
|
||||||
|
@ -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)
|
static void chardev_channel_init(struct channel_data *chan)
|
||||||
{
|
{
|
||||||
init_MUTEX(&chan->rsem);
|
mutex_init(&chan->rlock);
|
||||||
init_MUTEX(&chan->wsem);
|
init_MUTEX(&chan->wsem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -825,12 +827,12 @@ static ssize_t cosa_read(struct file *file,
|
||||||
cosa->name, cosa->firmware_status);
|
cosa->name, cosa->firmware_status);
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
if (down_interruptible(&chan->rsem))
|
if (mutex_lock_interruptible(&chan->rlock))
|
||||||
return -ERESTARTSYS;
|
return -ERESTARTSYS;
|
||||||
|
|
||||||
if ((chan->rxdata = kmalloc(COSA_MTU, GFP_DMA|GFP_KERNEL)) == NULL) {
|
if ((chan->rxdata = kmalloc(COSA_MTU, GFP_DMA|GFP_KERNEL)) == NULL) {
|
||||||
printk(KERN_INFO "%s: cosa_read() - OOM\n", cosa->name);
|
printk(KERN_INFO "%s: cosa_read() - OOM\n", cosa->name);
|
||||||
up(&chan->rsem);
|
mutex_unlock(&chan->rlock);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -848,7 +850,7 @@ static ssize_t cosa_read(struct file *file,
|
||||||
remove_wait_queue(&chan->rxwaitq, &wait);
|
remove_wait_queue(&chan->rxwaitq, &wait);
|
||||||
current->state = TASK_RUNNING;
|
current->state = TASK_RUNNING;
|
||||||
spin_unlock_irqrestore(&cosa->lock, flags);
|
spin_unlock_irqrestore(&cosa->lock, flags);
|
||||||
up(&chan->rsem);
|
mutex_unlock(&chan->rlock);
|
||||||
return -ERESTARTSYS;
|
return -ERESTARTSYS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -857,7 +859,7 @@ static ssize_t cosa_read(struct file *file,
|
||||||
kbuf = chan->rxdata;
|
kbuf = chan->rxdata;
|
||||||
count = chan->rxsize;
|
count = chan->rxsize;
|
||||||
spin_unlock_irqrestore(&cosa->lock, flags);
|
spin_unlock_irqrestore(&cosa->lock, flags);
|
||||||
up(&chan->rsem);
|
mutex_unlock(&chan->rlock);
|
||||||
|
|
||||||
if (copy_to_user(buf, kbuf, count)) {
|
if (copy_to_user(buf, kbuf, count)) {
|
||||||
kfree(kbuf);
|
kfree(kbuf);
|
||||||
|
|
Loading…
Add table
Reference in a new issue