Commit c1549497 authored by Josef 'Jeff' Sipek's avatar Josef 'Jeff' Sipek Committed by Eric Van Hensbergen

9p: use struct mutex instead of struct semaphore

Replace semaphores protecting use flags with a mutex.
Signed-off-by: default avatarJosef 'Jeff' Sipek <jeffpc@josefsipek.net>
Acked-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
parent bb8ffdfc
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
#define VIRTQUEUE_NUM 128 #define VIRTQUEUE_NUM 128
/* a single mutex to manage channel initialization and attachment */ /* a single mutex to manage channel initialization and attachment */
static DECLARE_MUTEX(virtio_9p_lock); static DEFINE_MUTEX(virtio_9p_lock);
/* global which tracks highest initialized channel */ /* global which tracks highest initialized channel */
static int chan_index; static int chan_index;
...@@ -211,9 +211,9 @@ static void p9_virtio_close(struct p9_trans *trans) ...@@ -211,9 +211,9 @@ static void p9_virtio_close(struct p9_trans *trans)
chan->max_tag = 0; chan->max_tag = 0;
spin_unlock_irqrestore(&chan->lock, flags); spin_unlock_irqrestore(&chan->lock, flags);
down(&virtio_9p_lock); mutex_lock(&virtio_9p_lock);
chan->inuse = false; chan->inuse = false;
up(&virtio_9p_lock); mutex_unlock(&virtio_9p_lock);
kfree(trans); kfree(trans);
} }
...@@ -381,10 +381,10 @@ static int p9_virtio_probe(struct virtio_device *vdev) ...@@ -381,10 +381,10 @@ static int p9_virtio_probe(struct virtio_device *vdev)
struct virtio_chan *chan; struct virtio_chan *chan;
int index; int index;
down(&virtio_9p_lock); mutex_lock(&virtio_9p_lock);
index = chan_index++; index = chan_index++;
chan = &channels[index]; chan = &channels[index];
up(&virtio_9p_lock); mutex_unlock(&virtio_9p_lock);
if (chan_index > MAX_9P_CHAN) { if (chan_index > MAX_9P_CHAN) {
printk(KERN_ERR "9p: virtio: Maximum channels exceeded\n"); printk(KERN_ERR "9p: virtio: Maximum channels exceeded\n");
...@@ -413,9 +413,9 @@ static int p9_virtio_probe(struct virtio_device *vdev) ...@@ -413,9 +413,9 @@ static int p9_virtio_probe(struct virtio_device *vdev)
out_free_vq: out_free_vq:
vdev->config->del_vq(chan->vq); vdev->config->del_vq(chan->vq);
fail: fail:
down(&virtio_9p_lock); mutex_lock(&virtio_9p_lock);
chan_index--; chan_index--;
up(&virtio_9p_lock); mutex_unlock(&virtio_9p_lock);
return err; return err;
} }
...@@ -449,7 +449,7 @@ p9_virtio_create(const char *devname, char *args, int msize, ...@@ -449,7 +449,7 @@ p9_virtio_create(const char *devname, char *args, int msize,
struct virtio_chan *chan = channels; struct virtio_chan *chan = channels;
int index = 0; int index = 0;
down(&virtio_9p_lock); mutex_lock(&virtio_9p_lock);
while (index < MAX_9P_CHAN) { while (index < MAX_9P_CHAN) {
if (chan->initialized && !chan->inuse) { if (chan->initialized && !chan->inuse) {
chan->inuse = true; chan->inuse = true;
...@@ -459,7 +459,7 @@ p9_virtio_create(const char *devname, char *args, int msize, ...@@ -459,7 +459,7 @@ p9_virtio_create(const char *devname, char *args, int msize,
chan = &channels[index]; chan = &channels[index];
} }
} }
up(&virtio_9p_lock); mutex_unlock(&virtio_9p_lock);
if (index >= MAX_9P_CHAN) { if (index >= MAX_9P_CHAN) {
printk(KERN_ERR "9p: no channels available\n"); printk(KERN_ERR "9p: no channels available\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment