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

Drivers: hv: rename sc_lock to the more generic lock

sc_lock spinlock in struct vmbus_channel is being used to not only protect the
sc_list field, e.g. vmbus_open() function uses it to implement test-and-set
access to the state field. Rename it to the more generic 'lock' and add the
description.
Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9c3a6f7e
...@@ -73,14 +73,14 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size, ...@@ -73,14 +73,14 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
unsigned long flags; unsigned long flags;
int ret, t, err = 0; int ret, t, err = 0;
spin_lock_irqsave(&newchannel->sc_lock, flags); spin_lock_irqsave(&newchannel->lock, flags);
if (newchannel->state == CHANNEL_OPEN_STATE) { if (newchannel->state == CHANNEL_OPEN_STATE) {
newchannel->state = CHANNEL_OPENING_STATE; newchannel->state = CHANNEL_OPENING_STATE;
} else { } else {
spin_unlock_irqrestore(&newchannel->sc_lock, flags); spin_unlock_irqrestore(&newchannel->lock, flags);
return -EINVAL; return -EINVAL;
} }
spin_unlock_irqrestore(&newchannel->sc_lock, flags); spin_unlock_irqrestore(&newchannel->lock, flags);
newchannel->onchannel_callback = onchannelcallback; newchannel->onchannel_callback = onchannelcallback;
newchannel->channel_callback_context = context; newchannel->channel_callback_context = context;
......
...@@ -146,7 +146,7 @@ static struct vmbus_channel *alloc_channel(void) ...@@ -146,7 +146,7 @@ static struct vmbus_channel *alloc_channel(void)
return NULL; return NULL;
spin_lock_init(&channel->inbound_lock); spin_lock_init(&channel->inbound_lock);
spin_lock_init(&channel->sc_lock); spin_lock_init(&channel->lock);
INIT_LIST_HEAD(&channel->sc_list); INIT_LIST_HEAD(&channel->sc_list);
INIT_LIST_HEAD(&channel->percpu_list); INIT_LIST_HEAD(&channel->percpu_list);
...@@ -246,9 +246,9 @@ static void vmbus_process_rescind_offer(struct work_struct *work) ...@@ -246,9 +246,9 @@ static void vmbus_process_rescind_offer(struct work_struct *work)
spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags); spin_unlock_irqrestore(&vmbus_connection.channel_lock, flags);
} else { } else {
primary_channel = channel->primary_channel; primary_channel = channel->primary_channel;
spin_lock_irqsave(&primary_channel->sc_lock, flags); spin_lock_irqsave(&primary_channel->lock, flags);
list_del(&channel->sc_list); list_del(&channel->sc_list);
spin_unlock_irqrestore(&primary_channel->sc_lock, flags); spin_unlock_irqrestore(&primary_channel->lock, flags);
} }
free_channel(channel); free_channel(channel);
} }
...@@ -323,9 +323,9 @@ static void vmbus_process_offer(struct work_struct *work) ...@@ -323,9 +323,9 @@ static void vmbus_process_offer(struct work_struct *work)
* Process the sub-channel. * Process the sub-channel.
*/ */
newchannel->primary_channel = channel; newchannel->primary_channel = channel;
spin_lock_irqsave(&channel->sc_lock, flags); spin_lock_irqsave(&channel->lock, flags);
list_add_tail(&newchannel->sc_list, &channel->sc_list); list_add_tail(&newchannel->sc_list, &channel->sc_list);
spin_unlock_irqrestore(&channel->sc_lock, flags); spin_unlock_irqrestore(&channel->lock, flags);
if (newchannel->target_cpu != get_cpu()) { if (newchannel->target_cpu != get_cpu()) {
put_cpu(); put_cpu();
......
...@@ -734,7 +734,12 @@ struct vmbus_channel { ...@@ -734,7 +734,12 @@ struct vmbus_channel {
*/ */
void (*sc_creation_callback)(struct vmbus_channel *new_sc); void (*sc_creation_callback)(struct vmbus_channel *new_sc);
spinlock_t sc_lock; /*
* The spinlock to protect the structure. It is being used to protect
* test-and-set access to various attributes of the structure as well
* as all sc_list operations.
*/
spinlock_t lock;
/* /*
* All Sub-channels of a primary channel are linked here. * All Sub-channels of a primary channel are linked here.
*/ */
......
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