[PATCH 1/4] staging/hv: remove use of internal list routines in NetVsc
Bill Pemberton
wfp5p at virginia.edu
Thu Sep 3 20:43:02 UTC 2009
The hv driver has it's own linked list routines. This removes them
from NetVsc and uses the kernels routines instead.
Signed-off-by: Bill Pemberton <wfp5p at virginia.edu>
---
drivers/staging/hv/NetVsc.c | 61 +++++++++++++++++----------------------
drivers/staging/hv/NetVsc.h | 4 +-
drivers/staging/hv/NetVscApi.h | 4 +-
3 files changed, 31 insertions(+), 38 deletions(-)
diff --git a/drivers/staging/hv/NetVsc.c b/drivers/staging/hv/NetVsc.c
index fb1cbf0..e5b45e4 100644
--- a/drivers/staging/hv/NetVsc.c
+++ b/drivers/staging/hv/NetVsc.c
@@ -800,9 +800,9 @@ NetVscOnDeviceAdd(
struct NETVSC_DEVICE *netDevice;
struct hv_netvsc_packet *packet;
- LIST_ENTRY *entry;
-
struct netvsc_driver *netDriver = (struct netvsc_driver *)Device->Driver;
+ struct list_head *pos;
+ struct list_head *pos2;
DPRINT_ENTER(NETVSC);
@@ -821,7 +821,7 @@ NetVscOnDeviceAdd(
netDevice->SendBufferSize = NETVSC_SEND_BUFFER_SIZE;
- INITIALIZE_LIST_HEAD(&netDevice->ReceivePacketList);
+ INIT_LIST_HEAD(&netDevice->ReceivePacketList);
for (i=0; i < NETVSC_RECEIVE_PACKETLIST_COUNT; i++)
{
@@ -832,7 +832,7 @@ NetVscOnDeviceAdd(
break;
}
- INSERT_TAIL_LIST(&netDevice->ReceivePacketList, &packet->ListEntry);
+ list_add_tail(&packet->ListEntry, &netDevice->ReceivePacketList);
}
netDevice->ChannelInitEvent = osd_WaitEventCreate();
@@ -879,10 +879,10 @@ Cleanup:
{
kfree(netDevice->ChannelInitEvent);
- while (!IsListEmpty(&netDevice->ReceivePacketList))
- {
- entry = REMOVE_HEAD_LIST(&netDevice->ReceivePacketList);
- packet = CONTAINING_RECORD(entry, struct hv_netvsc_packet, ListEntry);
+ list_for_each_safe(pos, pos2, &netDevice->ReceivePacketList) {
+ packet = list_entry(&netDevice->ReceivePacketList,
+ struct hv_netvsc_packet, ListEntry);
+ list_del(&packet->ListEntry);
kfree(packet);
}
@@ -913,8 +913,9 @@ NetVscOnDeviceRemove(
{
struct NETVSC_DEVICE *netDevice;
struct hv_netvsc_packet *netvscPacket;
+ struct list_head *pos;
+ struct list_head *pos2;
int ret=0;
- LIST_ENTRY *entry;
DPRINT_ENTER(NETVSC);
@@ -952,11 +953,9 @@ NetVscOnDeviceRemove(
Device->Driver->VmbusChannelInterface.Close(Device);
/* Release all resources */
- while (!IsListEmpty(&netDevice->ReceivePacketList))
- {
- entry = REMOVE_HEAD_LIST(&netDevice->ReceivePacketList);
- netvscPacket = CONTAINING_RECORD(entry, struct hv_netvsc_packet, ListEntry);
-
+ list_for_each_safe(pos, pos2, &netDevice->ReceivePacketList) {
+ netvscPacket = list_entry(pos, struct hv_netvsc_packet, ListEntry);
+ list_del(&netvscPacket->ListEntry);
kfree(netvscPacket);
}
@@ -1116,12 +1115,11 @@ NetVscOnReceive(
struct vmtransfer_page_packet_header *vmxferpagePacket;
struct nvsp_message *nvspPacket;
struct hv_netvsc_packet *netvscPacket=NULL;
- LIST_ENTRY* entry;
unsigned long start;
unsigned long end, endVirtual;
/* struct netvsc_driver *netvscDriver; */
struct xferpage_packet *xferpagePacket=NULL;
- LIST_ENTRY listHead;
+ LIST_HEAD(listHead);
int i=0, j=0;
int count=0, bytesRemain=0;
@@ -1168,8 +1166,6 @@ NetVscOnReceive(
DPRINT_DBG(NETVSC, "xfer page - range count %d", vmxferpagePacket->RangeCount);
- INITIALIZE_LIST_HEAD(&listHead);
-
/*
* Grab free packets (range count + 1) to represent this xfer
* page packet. +1 to represent the xfer page packet itself.
@@ -1177,12 +1173,9 @@ NetVscOnReceive(
* fulfil
*/
spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags);
- while (!IsListEmpty(&netDevice->ReceivePacketList))
+ while (!list_empty(&netDevice->ReceivePacketList))
{
- entry = REMOVE_HEAD_LIST(&netDevice->ReceivePacketList);
- netvscPacket = CONTAINING_RECORD(entry, struct hv_netvsc_packet, ListEntry);
-
- INSERT_TAIL_LIST(&listHead, &netvscPacket->ListEntry);
+ list_move_tail(&netDevice->ReceivePacketList, &listHead);
if (++count == vmxferpagePacket->RangeCount + 1)
break;
@@ -1202,10 +1195,7 @@ NetVscOnReceive(
spin_lock_irqsave(&netDevice->receive_packet_list_lock, flags);
for (i=count; i != 0; i--)
{
- entry = REMOVE_HEAD_LIST(&listHead);
- netvscPacket = CONTAINING_RECORD(entry, struct hv_netvsc_packet, ListEntry);
-
- INSERT_TAIL_LIST(&netDevice->ReceivePacketList, &netvscPacket->ListEntry);
+ list_move_tail(&listHead, &netDevice->ReceivePacketList);
}
spin_unlock_irqrestore(&netDevice->receive_packet_list_lock, flags);
@@ -1216,8 +1206,10 @@ NetVscOnReceive(
}
/* Remove the 1st packet to represent the xfer page packet itself */
- entry = REMOVE_HEAD_LIST(&listHead);
- xferpagePacket = CONTAINING_RECORD(entry, struct xferpage_packet, ListEntry);
+
+ xferpagePacket = list_entry(&listHead, struct xferpage_packet, ListEntry);
+ list_del(&xferpagePacket->ListEntry);
+
xferpagePacket->Count = count - 1; /* This is how much we can satisfy */
ASSERT(xferpagePacket->Count > 0 && xferpagePacket->Count <= vmxferpagePacket->RangeCount);
@@ -1229,8 +1221,8 @@ NetVscOnReceive(
/* Each range represents 1 RNDIS pkt that contains 1 ethernet frame */
for (i=0; i < (count - 1); i++)
{
- entry = REMOVE_HEAD_LIST(&listHead);
- netvscPacket = CONTAINING_RECORD(entry, struct hv_netvsc_packet, ListEntry);
+ netvscPacket = list_entry(&listHead, struct hv_netvsc_packet, ListEntry);
+ list_del(&netvscPacket->ListEntry);
/* Initialize the netvsc packet */
netvscPacket->XferPagePacket = xferpagePacket;
@@ -1292,7 +1284,7 @@ NetVscOnReceive(
NetVscOnReceiveCompletion(netvscPacket->Completion.Recv.ReceiveCompletionContext);
}
- ASSERT(IsListEmpty(&listHead));
+ ASSERT(list_empty(&listHead));
PutNetDevice(Device);
DPRINT_EXIT(NETVSC);
@@ -1388,11 +1380,12 @@ NetVscOnReceiveCompletion(
fSendReceiveComp = true;
transactionId = packet->Completion.Recv.ReceiveCompletionTid;
- INSERT_TAIL_LIST(&netDevice->ReceivePacketList, &packet->XferPagePacket->ListEntry);
+ list_add_tail(&packet->XferPagePacket->ListEntry,
+ &netDevice->ReceivePacketList);
}
/* Put the packet back */
- INSERT_TAIL_LIST(&netDevice->ReceivePacketList, &packet->ListEntry);
+ list_add_tail(&packet->ListEntry, &netDevice->ReceivePacketList);
spin_unlock_irqrestore(&netDevice->receive_packet_list_lock, flags);
/* Send a receive completion for the xfer page packet */
diff --git a/drivers/staging/hv/NetVsc.h b/drivers/staging/hv/NetVsc.h
index 73de16e..08f4fa7 100644
--- a/drivers/staging/hv/NetVsc.h
+++ b/drivers/staging/hv/NetVsc.h
@@ -24,9 +24,9 @@
#ifndef _NETVSC_H_
#define _NETVSC_H_
+#include <linux/list.h>
#include "VmbusPacketFormat.h"
#include "VmbusChannelInterface.h"
-#include "List.h"
#include "NetVscApi.h"
@@ -299,7 +299,7 @@ struct NETVSC_DEVICE {
* List of free preallocated hv_netvsc_packet to represent receive
* packet
*/
- LIST_ENTRY ReceivePacketList;
+ struct list_head ReceivePacketList;
spinlock_t receive_packet_list_lock;
/* Send buffer allocated by us but manages by NetVSP */
diff --git a/drivers/staging/hv/NetVscApi.h b/drivers/staging/hv/NetVscApi.h
index c53e417..3284c1c 100644
--- a/drivers/staging/hv/NetVscApi.h
+++ b/drivers/staging/hv/NetVscApi.h
@@ -50,7 +50,7 @@ typedef void (*PFN_ON_LINKSTATUS_CHANGED)(struct hv_device *dev, u32 Status);
/* Represent the xfer page packet which contains 1 or more netvsc packet */
struct xferpage_packet {
- LIST_ENTRY ListEntry;
+ struct list_head ListEntry;
/* # of netvsc packets this xfer packet contains */
u32 Count;
@@ -65,7 +65,7 @@ struct xferpage_packet {
*/
struct hv_netvsc_packet {
/* Bookkeeping stuff */
- LIST_ENTRY ListEntry;
+ struct list_head ListEntry;
struct hv_device *Device;
bool IsDataPacket;
--
1.6.2.5
More information about the devel
mailing list