Staging: hv: remove more usages of internal list routines

The hv driver has it's own linked list routines.  This removes them
from more places in hv.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Hank Janssen <hjanssen@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Bill Pemberton 2009-09-11 21:46:44 -04:00 committed by Greg Kroah-Hartman
parent d29274efb7
commit 53af545b27
5 changed files with 55 additions and 65 deletions

View file

@ -247,8 +247,8 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
memcpy(openMsg->UserData, UserData, UserDataLen);
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList,
&openInfo->MsgListEntry);
list_add_tail(&openInfo->MsgListEntry,
&gVmbusConnection.ChannelMsgList);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_DBG(VMBUS, "Sending channel open msg...");
@ -271,7 +271,7 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
Cleanup:
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
REMOVE_ENTRY_LIST(&openInfo->MsgListEntry);
list_del(&openInfo->MsgListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
kfree(openInfo->WaitEvent);
@ -362,7 +362,7 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
sizeof(struct gpa_range) + pfnCount * sizeof(u64);
msgHeader = kzalloc(msgSize, GFP_KERNEL);
INITIALIZE_LIST_HEAD(&msgHeader->SubMsgList);
INIT_LIST_HEAD(&msgHeader->SubMsgList);
msgHeader->MessageSize = msgSize;
gpaHeader = (struct vmbus_channel_gpadl_header *)msgHeader->Msg;
@ -411,8 +411,8 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
gpadlBody->Pfn[i] = pfn + pfnSum + i;
/* add to msg header */
INSERT_TAIL_LIST(&msgHeader->SubMsgList,
&msgBody->MsgListEntry);
list_add_tail(&msgBody->MsgListEntry,
&msgHeader->SubMsgList);
pfnSum += pfnCurr;
pfnLeft -= pfnCurr;
}
@ -457,8 +457,7 @@ int VmbusChannelEstablishGpadl(struct vmbus_channel *Channel, void *Kbuffer,
struct vmbus_channel_msginfo *msgInfo;
struct vmbus_channel_msginfo *subMsgInfo;
u32 msgCount;
LIST_ENTRY *anchor;
LIST_ENTRY *curr;
struct list_head *curr;
u32 nextGpadlHandle;
unsigned long flags;
int ret;
@ -481,10 +480,10 @@ int VmbusChannelEstablishGpadl(struct vmbus_channel *Channel, void *Kbuffer,
DumpGpadlHeader(gpadlMsg);
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList,
&msgInfo->MsgListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
list_add_tail(&msgInfo->MsgListEntry,
&gVmbusConnection.ChannelMsgList);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_DBG(VMBUS, "buffer %p, size %d msg cnt %d",
Kbuffer, Size, msgCount);
@ -499,7 +498,9 @@ int VmbusChannelEstablishGpadl(struct vmbus_channel *Channel, void *Kbuffer,
}
if (msgCount > 1) {
ITERATE_LIST_ENTRIES(anchor, curr, &msgInfo->SubMsgList) {
list_for_each(curr, &msgInfo->SubMsgList) {
/* FIXME: should this use list_entry() instead ? */
subMsgInfo = (struct vmbus_channel_msginfo *)curr;
gpadlBody =
(struct vmbus_channel_gpadl_body *)subMsgInfo->Msg;
@ -532,7 +533,7 @@ int VmbusChannelEstablishGpadl(struct vmbus_channel *Channel, void *Kbuffer,
Cleanup:
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
REMOVE_ENTRY_LIST(&msgInfo->MsgListEntry);
list_del(&msgInfo->MsgListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
kfree(msgInfo->WaitEvent);
@ -570,7 +571,8 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
msg->Gpadl = GpadlHandle;
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList, &info->MsgListEntry);
list_add_tail(&info->MsgListEntry,
&gVmbusConnection.ChannelMsgList);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
ret = VmbusPostMessage(msg,
@ -584,7 +586,7 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle)
/* Received a torndown response */
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
REMOVE_ENTRY_LIST(&info->MsgListEntry);
list_del(&info->MsgListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
kfree(info->WaitEvent);
@ -651,7 +653,7 @@ void VmbusChannelClose(struct vmbus_channel *Channel)
if (Channel->State == CHANNEL_OPEN_STATE) {
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
REMOVE_ENTRY_LIST(&Channel->ListEntry);
list_del(&Channel->ListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
FreeVmbusChannel(Channel);

View file

@ -20,6 +20,7 @@
*/
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/list.h>
#include "osd.h"
#include "logging.h"
#include "VmbusPrivate.h"
@ -136,8 +137,6 @@ static void VmbusChannelProcessOffer(void *context)
{
struct vmbus_channel *newChannel = context;
struct vmbus_channel *channel;
LIST_ENTRY *anchor;
LIST_ENTRY *curr;
bool fNew = true;
int ret;
unsigned long flags;
@ -147,10 +146,7 @@ static void VmbusChannelProcessOffer(void *context)
/* Make sure this is a new offer */
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelList) {
channel = CONTAINING_RECORD(curr, struct vmbus_channel,
ListEntry);
list_for_each_entry(channel, &gVmbusConnection.ChannelList, ListEntry) {
if (!memcmp(&channel->OfferMsg.Offer.InterfaceType,
&newChannel->OfferMsg.Offer.InterfaceType,
sizeof(struct hv_guid)) &&
@ -163,8 +159,8 @@ static void VmbusChannelProcessOffer(void *context)
}
if (fNew)
INSERT_TAIL_LIST(&gVmbusConnection.ChannelList,
&newChannel->ListEntry);
list_add_tail(&newChannel->ListEntry,
&gVmbusConnection.ChannelList);
spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
@ -201,7 +197,7 @@ static void VmbusChannelProcessOffer(void *context)
newChannel->OfferMsg.ChildRelId);
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
REMOVE_ENTRY_LIST(&newChannel->ListEntry);
list_del(&newChannel->ListEntry);
spin_unlock_irqrestore(&gVmbusConnection.channel_lock, flags);
FreeVmbusChannel(newChannel);
@ -360,8 +356,7 @@ static void VmbusChannelOnOffersDelivered(
static void VmbusChannelOnOpenResult(struct vmbus_channel_message_header *hdr)
{
struct vmbus_channel_open_result *result;
LIST_ENTRY *anchor;
LIST_ENTRY *curr;
struct list_head *curr;
struct vmbus_channel_msginfo *msgInfo;
struct vmbus_channel_message_header *requestHeader;
struct vmbus_channel_open_channel *openMsg;
@ -377,7 +372,8 @@ static void VmbusChannelOnOpenResult(struct vmbus_channel_message_header *hdr)
*/
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList) {
list_for_each(curr, &gVmbusConnection.ChannelMsgList) {
/* FIXME: this should probably use list_entry() instead */
msgInfo = (struct vmbus_channel_msginfo *)curr;
requestHeader = (struct vmbus_channel_message_header *)msgInfo->Msg;
@ -408,8 +404,7 @@ static void VmbusChannelOnOpenResult(struct vmbus_channel_message_header *hdr)
static void VmbusChannelOnGpadlCreated(struct vmbus_channel_message_header *hdr)
{
struct vmbus_channel_gpadl_created *gpadlCreated;
LIST_ENTRY *anchor;
LIST_ENTRY *curr;
struct list_head *curr;
struct vmbus_channel_msginfo *msgInfo;
struct vmbus_channel_message_header *requestHeader;
struct vmbus_channel_gpadl_header *gpadlHeader;
@ -427,7 +422,8 @@ static void VmbusChannelOnGpadlCreated(struct vmbus_channel_message_header *hdr)
*/
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList) {
list_for_each(curr, &gVmbusConnection.ChannelMsgList) {
/* FIXME: this should probably use list_entry() instead */
msgInfo = (struct vmbus_channel_msginfo *)curr;
requestHeader = (struct vmbus_channel_message_header *)msgInfo->Msg;
@ -461,8 +457,7 @@ static void VmbusChannelOnGpadlTorndown(
struct vmbus_channel_message_header *hdr)
{
struct vmbus_channel_gpadl_torndown *gpadlTorndown;
LIST_ENTRY *anchor;
LIST_ENTRY *curr;
struct list_head *curr;
struct vmbus_channel_msginfo *msgInfo;
struct vmbus_channel_message_header *requestHeader;
struct vmbus_channel_gpadl_teardown *gpadlTeardown;
@ -477,7 +472,8 @@ static void VmbusChannelOnGpadlTorndown(
*/
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList) {
list_for_each(curr, &gVmbusConnection.ChannelMsgList) {
/* FIXME: this should probably use list_entry() instead */
msgInfo = (struct vmbus_channel_msginfo *)curr;
requestHeader = (struct vmbus_channel_message_header *)msgInfo->Msg;
@ -508,8 +504,7 @@ static void VmbusChannelOnGpadlTorndown(
static void VmbusChannelOnVersionResponse(
struct vmbus_channel_message_header *hdr)
{
LIST_ENTRY *anchor;
LIST_ENTRY *curr;
struct list_head *curr;
struct vmbus_channel_msginfo *msgInfo;
struct vmbus_channel_message_header *requestHeader;
struct vmbus_channel_initiate_contact *initiate;
@ -521,7 +516,8 @@ static void VmbusChannelOnVersionResponse(
versionResponse = (struct vmbus_channel_version_response *)hdr;
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelMsgList) {
list_for_each(curr, &gVmbusConnection.ChannelMsgList) {
/* FIXME: this should probably use list_entry() instead */
msgInfo = (struct vmbus_channel_msginfo *)curr;
requestHeader = (struct vmbus_channel_message_header *)msgInfo->Msg;
@ -659,23 +655,19 @@ int VmbusChannelRequestOffers(void)
*/
void VmbusChannelReleaseUnattachedChannels(void)
{
LIST_ENTRY *entry;
struct vmbus_channel *channel;
struct vmbus_channel *channel, *pos;
struct vmbus_channel *start = NULL;
unsigned long flags;
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
while (!IsListEmpty(&gVmbusConnection.ChannelList)) {
entry = TOP_LIST_ENTRY(&gVmbusConnection.ChannelList);
channel = CONTAINING_RECORD(entry, struct vmbus_channel,
ListEntry);
list_for_each_entry_safe(channel, pos, &gVmbusConnection.ChannelList,
ListEntry) {
if (channel == start)
break;
if (!channel->DeviceObject->Driver) {
REMOVE_ENTRY_LIST(&channel->ListEntry);
list_del(&channel->ListEntry);
DPRINT_INFO(VMBUS,
"Releasing unattached device object %p",
channel->DeviceObject);

View file

@ -25,7 +25,7 @@
#ifndef _CHANNEL_MGMT_H_
#define _CHANNEL_MGMT_H_
#include "List.h"
#include <linux/list.h>
#include "RingBuffer.h"
#include "VmbusChannelInterface.h"
#include "VmbusPacketFormat.h"
@ -225,7 +225,7 @@ enum vmbus_channel_state {
};
struct vmbus_channel {
LIST_ENTRY ListEntry;
struct list_head ListEntry;
struct hv_device *DeviceObject;
@ -281,10 +281,10 @@ struct vmbus_channel_debug_info {
*/
struct vmbus_channel_msginfo {
/* Bookkeeping stuff */
LIST_ENTRY MsgListEntry;
struct list_head MsgListEntry;
/* So far, this is only used to handle gpadl body message */
LIST_ENTRY SubMsgList;
struct list_head SubMsgList;
/* Synchronize the request/response if needed */
struct osd_waitevent *WaitEvent;

View file

@ -57,10 +57,10 @@ int VmbusConnect(void)
goto Cleanup;
}
INITIALIZE_LIST_HEAD(&gVmbusConnection.ChannelMsgList);
INIT_LIST_HEAD(&gVmbusConnection.ChannelMsgList);
spin_lock_init(&gVmbusConnection.channelmsg_lock);
INITIALIZE_LIST_HEAD(&gVmbusConnection.ChannelList);
INIT_LIST_HEAD(&gVmbusConnection.ChannelList);
spin_lock_init(&gVmbusConnection.channel_lock);
/*
@ -112,8 +112,9 @@ int VmbusConnect(void)
* receive the response before returning from this routine
*/
spin_lock_irqsave(&gVmbusConnection.channelmsg_lock, flags);
INSERT_TAIL_LIST(&gVmbusConnection.ChannelMsgList,
&msgInfo->MsgListEntry);
list_add_tail(&msgInfo->MsgListEntry,
&gVmbusConnection.ChannelMsgList);
spin_unlock_irqrestore(&gVmbusConnection.channelmsg_lock, flags);
DPRINT_DBG(VMBUS, "Vmbus connection - interrupt pfn %llx, "
@ -124,14 +125,14 @@ int VmbusConnect(void)
ret = VmbusPostMessage(msg,
sizeof(struct vmbus_channel_initiate_contact));
if (ret != 0) {
REMOVE_ENTRY_LIST(&msgInfo->MsgListEntry);
list_del(&msgInfo->MsgListEntry);
goto Cleanup;
}
/* Wait for the connection response */
osd_WaitEventWait(msgInfo->WaitEvent);
REMOVE_ENTRY_LIST(&msgInfo->MsgListEntry);
list_del(&msgInfo->MsgListEntry);
/* Check if successful */
if (msgInfo->Response.VersionResponse.VersionSupported) {
@ -223,15 +224,10 @@ struct vmbus_channel *GetChannelFromRelId(u32 relId)
{
struct vmbus_channel *channel;
struct vmbus_channel *foundChannel = NULL;
LIST_ENTRY *anchor;
LIST_ENTRY *curr;
unsigned long flags;
spin_lock_irqsave(&gVmbusConnection.channel_lock, flags);
ITERATE_LIST_ENTRIES(anchor, curr, &gVmbusConnection.ChannelList) {
channel = CONTAINING_RECORD(curr, struct vmbus_channel,
ListEntry);
list_for_each_entry(channel, &gVmbusConnection.ChannelList, ListEntry) {
if (channel->OfferMsg.ChildRelId == relId) {
foundChannel = channel;
break;

View file

@ -31,7 +31,7 @@
#include "ChannelMgmt.h"
#include "ChannelInterface.h"
#include "RingBuffer.h"
#include "List.h"
#include <linux/list.h>
/*
@ -76,11 +76,11 @@ struct VMBUS_CONNECTION {
* is child->parent notification
*/
void *MonitorPages;
LIST_ENTRY ChannelMsgList;
struct list_head ChannelMsgList;
spinlock_t channelmsg_lock;
/* List of channels */
LIST_ENTRY ChannelList;
struct list_head ChannelList;
spinlock_t channel_lock;
struct workqueue_struct *WorkQueue;
@ -89,7 +89,7 @@ struct VMBUS_CONNECTION {
struct VMBUS_MSGINFO {
/* Bookkeeping stuff */
LIST_ENTRY MsgListEntry;
struct list_head MsgListEntry;
/* Synchronize the request/response if needed */
struct osd_waitevent *WaitEvent;