Commit a72f3a4c authored by Vitaly Kuznetsov's avatar Vitaly Kuznetsov Committed by Greg Kroah-Hartman

Drivers: hv: utils: rename outmsg_lock

As a preparation to reusing outmsg_lock to protect test-and-set openrations
on 'mode' rename it the more general 'lock'.
Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1f75338b
...@@ -27,11 +27,11 @@ static struct list_head hvt_list = LIST_HEAD_INIT(hvt_list); ...@@ -27,11 +27,11 @@ static struct list_head hvt_list = LIST_HEAD_INIT(hvt_list);
static void hvt_reset(struct hvutil_transport *hvt) static void hvt_reset(struct hvutil_transport *hvt)
{ {
mutex_lock(&hvt->outmsg_lock); mutex_lock(&hvt->lock);
kfree(hvt->outmsg); kfree(hvt->outmsg);
hvt->outmsg = NULL; hvt->outmsg = NULL;
hvt->outmsg_len = 0; hvt->outmsg_len = 0;
mutex_unlock(&hvt->outmsg_lock); mutex_unlock(&hvt->lock);
if (hvt->on_reset) if (hvt->on_reset)
hvt->on_reset(); hvt->on_reset();
} }
...@@ -47,7 +47,7 @@ static ssize_t hvt_op_read(struct file *file, char __user *buf, ...@@ -47,7 +47,7 @@ static ssize_t hvt_op_read(struct file *file, char __user *buf,
if (wait_event_interruptible(hvt->outmsg_q, hvt->outmsg_len > 0)) if (wait_event_interruptible(hvt->outmsg_q, hvt->outmsg_len > 0))
return -EINTR; return -EINTR;
mutex_lock(&hvt->outmsg_lock); mutex_lock(&hvt->lock);
if (!hvt->outmsg) { if (!hvt->outmsg) {
ret = -EAGAIN; ret = -EAGAIN;
goto out_unlock; goto out_unlock;
...@@ -68,7 +68,7 @@ static ssize_t hvt_op_read(struct file *file, char __user *buf, ...@@ -68,7 +68,7 @@ static ssize_t hvt_op_read(struct file *file, char __user *buf,
hvt->outmsg_len = 0; hvt->outmsg_len = 0;
out_unlock: out_unlock:
mutex_unlock(&hvt->outmsg_lock); mutex_unlock(&hvt->lock);
return ret; return ret;
} }
...@@ -197,7 +197,7 @@ int hvutil_transport_send(struct hvutil_transport *hvt, void *msg, int len) ...@@ -197,7 +197,7 @@ int hvutil_transport_send(struct hvutil_transport *hvt, void *msg, int len)
return ret; return ret;
} }
/* HVUTIL_TRANSPORT_CHARDEV */ /* HVUTIL_TRANSPORT_CHARDEV */
mutex_lock(&hvt->outmsg_lock); mutex_lock(&hvt->lock);
if (hvt->outmsg) { if (hvt->outmsg) {
/* Previous message wasn't received */ /* Previous message wasn't received */
ret = -EFAULT; ret = -EFAULT;
...@@ -211,7 +211,7 @@ int hvutil_transport_send(struct hvutil_transport *hvt, void *msg, int len) ...@@ -211,7 +211,7 @@ int hvutil_transport_send(struct hvutil_transport *hvt, void *msg, int len)
} else } else
ret = -ENOMEM; ret = -ENOMEM;
out_unlock: out_unlock:
mutex_unlock(&hvt->outmsg_lock); mutex_unlock(&hvt->lock);
return ret; return ret;
} }
...@@ -242,7 +242,7 @@ struct hvutil_transport *hvutil_transport_init(const char *name, ...@@ -242,7 +242,7 @@ struct hvutil_transport *hvutil_transport_init(const char *name,
hvt->mdev.fops = &hvt->fops; hvt->mdev.fops = &hvt->fops;
init_waitqueue_head(&hvt->outmsg_q); init_waitqueue_head(&hvt->outmsg_q);
mutex_init(&hvt->outmsg_lock); mutex_init(&hvt->lock);
spin_lock(&hvt_list_lock); spin_lock(&hvt_list_lock);
list_add(&hvt->list, &hvt_list); list_add(&hvt->list, &hvt_list);
......
...@@ -38,7 +38,7 @@ struct hvutil_transport { ...@@ -38,7 +38,7 @@ struct hvutil_transport {
u8 *outmsg; /* message to the userspace */ u8 *outmsg; /* message to the userspace */
int outmsg_len; /* its length */ int outmsg_len; /* its length */
wait_queue_head_t outmsg_q; /* poll/read wait queue */ wait_queue_head_t outmsg_q; /* poll/read wait queue */
struct mutex outmsg_lock; /* protects outmsg */ struct mutex lock; /* protects struct members */
}; };
struct hvutil_transport *hvutil_transport_init(const char *name, struct hvutil_transport *hvutil_transport_init(const char *name,
......
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