All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Palix <npalix@diku.dk>
To: gregkh@suse.de, hjanssen@microsoft.com,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct scatterlist
Date: Thu, 30 Jul 2009 15:37:23 +0000	[thread overview]
Message-ID: <200907301737.23849.npalix@diku.dk> (raw)


typedef SG_BUFFER_LIST is removed and its uses are replaced by the use of
struct scatterlist.

Signed-off-by: Nicolas Palix <npalix@diku.dk>
---
 drivers/staging/hv/Channel.c    |   42 +++++++++++++-------------------------
 drivers/staging/hv/RingBuffer.c |   27 +++++++++++++------------
 drivers/staging/hv/RingBuffer.h |   13 ++++-------
 3 files changed, 34 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/hv/Channel.c b/drivers/staging/hv/Channel.c
index be9770e..2938e58 100644
--- a/drivers/staging/hv/Channel.c
+++ b/drivers/staging/hv/Channel.c
@@ -773,7 +773,7 @@ VmbusChannelSendPacket(
 	VMPACKET_DESCRIPTOR desc;
 	u32 packetLen = sizeof(VMPACKET_DESCRIPTOR) + BufferLen;
 	u32 packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
-	SG_BUFFER_LIST bufferList[3];
+	struct scatterlist bufferList[3];
 	u64 alignedData=0;
 
 	DPRINT_ENTER(VMBUS);
@@ -790,14 +790,10 @@ VmbusChannelSendPacket(
 	desc.Length8 = (u16)(packetLenAligned >> 3);
 	desc.TransactionId = RequestId;
 
-	bufferList[0].Data = &desc;
-	bufferList[0].Length = sizeof(VMPACKET_DESCRIPTOR);
-
-	bufferList[1].Data = Buffer;
-	bufferList[1].Length = BufferLen;
-
-	bufferList[2].Data = &alignedData;
-	bufferList[2].Length = packetLenAligned - packetLen;
+	sg_init_table(bufferList,3);
+	sg_set_buf(&bufferList[0], &desc, sizeof(VMPACKET_DESCRIPTOR));
+	sg_set_buf(&bufferList[1], Buffer, BufferLen);
+	sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
 
 	ret = RingBufferWrite(
 		&Channel->Outbound,
@@ -841,7 +837,7 @@ VmbusChannelSendPacketPageBuffer(
 	u32 descSize;
 	u32 packetLen;
 	u32 packetLenAligned;
-	SG_BUFFER_LIST bufferList[3];
+	struct scatterlist bufferList[3];
 	u64 alignedData=0;
 
 	DPRINT_ENTER(VMBUS);
@@ -872,14 +868,10 @@ VmbusChannelSendPacketPageBuffer(
 		desc.Range[i].Pfn	 = PageBuffers[i].Pfn;
 	}
 
-	bufferList[0].Data = &desc;
-	bufferList[0].Length = descSize;
-
-	bufferList[1].Data = Buffer;
-	bufferList[1].Length = BufferLen;
-
-	bufferList[2].Data = &alignedData;
-	bufferList[2].Length = packetLenAligned - packetLen;
+	sg_init_table(bufferList,3);
+	sg_set_buf(&bufferList[0], &desc, descSize);
+	sg_set_buf(&bufferList[1], Buffer, BufferLen);
+	sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
 
 	ret = RingBufferWrite(
 		&Channel->Outbound,
@@ -922,7 +914,7 @@ VmbusChannelSendPacketMultiPageBuffer(
 	u32 descSize;
 	u32 packetLen;
 	u32 packetLenAligned;
-	SG_BUFFER_LIST bufferList[3];
+	struct scatterlist bufferList[3];
 	u64 alignedData=0;
 	u32 PfnCount = NUM_PAGES_SPANNED(MultiPageBuffer->Offset, MultiPageBuffer->Length);
 
@@ -955,14 +947,10 @@ VmbusChannelSendPacketMultiPageBuffer(
 
 	memcpy(desc.Range.PfnArray, MultiPageBuffer->PfnArray, PfnCount*sizeof(u64));
 
-	bufferList[0].Data = &desc;
-	bufferList[0].Length = descSize;
-
-	bufferList[1].Data = Buffer;
-	bufferList[1].Length = BufferLen;
-
-	bufferList[2].Data = &alignedData;
-	bufferList[2].Length = packetLenAligned - packetLen;
+	sg_init_table(bufferList,3);
+	sg_set_buf(&bufferList[0], &desc, descSize);
+	sg_set_buf(&bufferList[1], Buffer, BufferLen);
+	sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
 
 	ret = RingBufferWrite(
 		&Channel->Outbound,
diff --git a/drivers/staging/hv/RingBuffer.c b/drivers/staging/hv/RingBuffer.c
index d338ce2..571f9db 100644
--- a/drivers/staging/hv/RingBuffer.c
+++ b/drivers/staging/hv/RingBuffer.c
@@ -347,9 +347,9 @@ Description:
 --*/
 static int
 RingBufferWrite(
-	RING_BUFFER_INFO*	OutRingInfo,
-	SG_BUFFER_LIST		SgBuffers[],
-	u32				SgBufferCount
+	RING_BUFFER_INFO *OutRingInfo,
+	struct scatterlist *sglist,
+	u32 sgcount
 	)
 {
 	int i=0;
@@ -357,15 +357,16 @@ RingBufferWrite(
 	u32 byteAvailToRead;
 	u32 totalBytesToWrite=0;
 
+	struct scatterlist *sg;
 	volatile u32 nextWriteLocation;
 	u64 prevIndices=0;
 	unsigned long flags;
 
 	DPRINT_ENTER(VMBUS);
 
-	for (i=0; i < SgBufferCount; i++)
+	for_each_sg(sglist, sg, sgcount, i)
 	{
-		totalBytesToWrite += SgBuffers[i].Length;
+		totalBytesToWrite += sg->length;
 	}
 
 	totalBytesToWrite += sizeof(u64);
@@ -394,21 +395,21 @@ RingBufferWrite(
 	/* Write to the ring buffer */
 	nextWriteLocation = GetNextWriteLocation(OutRingInfo);
 
-	for (i=0; i < SgBufferCount; i++)
+	for_each_sg(sglist, sg, sgcount, i)
 	{
-		 nextWriteLocation = CopyToRingBuffer(OutRingInfo,
-												nextWriteLocation,
-												SgBuffers[i].Data,
-												SgBuffers[i].Length);
+		nextWriteLocation = CopyToRingBuffer(OutRingInfo,
+						     nextWriteLocation,
+						     sg_virt(sg),
+						     sg->length);
 	}
 
 	/* Set previous packet start */
 	prevIndices = GetRingBufferIndices(OutRingInfo);
 
 	nextWriteLocation = CopyToRingBuffer(OutRingInfo,
-												nextWriteLocation,
-												&prevIndices,
-												sizeof(u64));
+					     nextWriteLocation,
+					     &prevIndices,
+					     sizeof(u64));
 
 	/* Make sure we flush all writes before updating the writeIndex */
 	mb();
diff --git a/drivers/staging/hv/RingBuffer.h b/drivers/staging/hv/RingBuffer.h
index a0b6e0e..1658614 100644
--- a/drivers/staging/hv/RingBuffer.h
+++ b/drivers/staging/hv/RingBuffer.h
@@ -25,12 +25,9 @@
 #ifndef _RING_BUFFER_H_
 #define _RING_BUFFER_H_
 
-#include "include/osd.h"
+#include <linux/scatterlist.h>
 
-typedef struct _SG_BUFFER_LIST {
-	void *	Data;
-	u32	Length;
-} SG_BUFFER_LIST;
+#include "include/osd.h"
 
 typedef struct _RING_BUFFER {
     volatile u32	WriteIndex;     /* Offset in bytes from the start of ring data below */
@@ -83,9 +80,9 @@ RingBufferCleanup(
 
 static int
 RingBufferWrite(
-	RING_BUFFER_INFO	*RingInfo,
-	SG_BUFFER_LIST		SgBuffers[],
-	u32				SgBufferCount
+	RING_BUFFER_INFO *RingInfo,
+	struct scatterlist *sglist,
+	u32 sgcount
 	);
 
 static int
-- 
1.6.0.4


-- 
Nicolas Palix

WARNING: multiple messages have this Message-ID (diff)
From: Nicolas Palix <npalix@diku.dk>
To: gregkh@suse.de, hjanssen@microsoft.com,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct scatterlist
Date: Thu, 30 Jul 2009 17:37:23 +0200	[thread overview]
Message-ID: <200907301737.23849.npalix@diku.dk> (raw)


typedef SG_BUFFER_LIST is removed and its uses are replaced by the use of
struct scatterlist.

Signed-off-by: Nicolas Palix <npalix@diku.dk>
---
 drivers/staging/hv/Channel.c    |   42 +++++++++++++-------------------------
 drivers/staging/hv/RingBuffer.c |   27 +++++++++++++------------
 drivers/staging/hv/RingBuffer.h |   13 ++++-------
 3 files changed, 34 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/hv/Channel.c b/drivers/staging/hv/Channel.c
index be9770e..2938e58 100644
--- a/drivers/staging/hv/Channel.c
+++ b/drivers/staging/hv/Channel.c
@@ -773,7 +773,7 @@ VmbusChannelSendPacket(
 	VMPACKET_DESCRIPTOR desc;
 	u32 packetLen = sizeof(VMPACKET_DESCRIPTOR) + BufferLen;
 	u32 packetLenAligned = ALIGN_UP(packetLen, sizeof(u64));
-	SG_BUFFER_LIST bufferList[3];
+	struct scatterlist bufferList[3];
 	u64 alignedData=0;
 
 	DPRINT_ENTER(VMBUS);
@@ -790,14 +790,10 @@ VmbusChannelSendPacket(
 	desc.Length8 = (u16)(packetLenAligned >> 3);
 	desc.TransactionId = RequestId;
 
-	bufferList[0].Data = &desc;
-	bufferList[0].Length = sizeof(VMPACKET_DESCRIPTOR);
-
-	bufferList[1].Data = Buffer;
-	bufferList[1].Length = BufferLen;
-
-	bufferList[2].Data = &alignedData;
-	bufferList[2].Length = packetLenAligned - packetLen;
+	sg_init_table(bufferList,3);
+	sg_set_buf(&bufferList[0], &desc, sizeof(VMPACKET_DESCRIPTOR));
+	sg_set_buf(&bufferList[1], Buffer, BufferLen);
+	sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
 
 	ret = RingBufferWrite(
 		&Channel->Outbound,
@@ -841,7 +837,7 @@ VmbusChannelSendPacketPageBuffer(
 	u32 descSize;
 	u32 packetLen;
 	u32 packetLenAligned;
-	SG_BUFFER_LIST bufferList[3];
+	struct scatterlist bufferList[3];
 	u64 alignedData=0;
 
 	DPRINT_ENTER(VMBUS);
@@ -872,14 +868,10 @@ VmbusChannelSendPacketPageBuffer(
 		desc.Range[i].Pfn	 = PageBuffers[i].Pfn;
 	}
 
-	bufferList[0].Data = &desc;
-	bufferList[0].Length = descSize;
-
-	bufferList[1].Data = Buffer;
-	bufferList[1].Length = BufferLen;
-
-	bufferList[2].Data = &alignedData;
-	bufferList[2].Length = packetLenAligned - packetLen;
+	sg_init_table(bufferList,3);
+	sg_set_buf(&bufferList[0], &desc, descSize);
+	sg_set_buf(&bufferList[1], Buffer, BufferLen);
+	sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
 
 	ret = RingBufferWrite(
 		&Channel->Outbound,
@@ -922,7 +914,7 @@ VmbusChannelSendPacketMultiPageBuffer(
 	u32 descSize;
 	u32 packetLen;
 	u32 packetLenAligned;
-	SG_BUFFER_LIST bufferList[3];
+	struct scatterlist bufferList[3];
 	u64 alignedData=0;
 	u32 PfnCount = NUM_PAGES_SPANNED(MultiPageBuffer->Offset, MultiPageBuffer->Length);
 
@@ -955,14 +947,10 @@ VmbusChannelSendPacketMultiPageBuffer(
 
 	memcpy(desc.Range.PfnArray, MultiPageBuffer->PfnArray, PfnCount*sizeof(u64));
 
-	bufferList[0].Data = &desc;
-	bufferList[0].Length = descSize;
-
-	bufferList[1].Data = Buffer;
-	bufferList[1].Length = BufferLen;
-
-	bufferList[2].Data = &alignedData;
-	bufferList[2].Length = packetLenAligned - packetLen;
+	sg_init_table(bufferList,3);
+	sg_set_buf(&bufferList[0], &desc, descSize);
+	sg_set_buf(&bufferList[1], Buffer, BufferLen);
+	sg_set_buf(&bufferList[2], &alignedData, packetLenAligned - packetLen);
 
 	ret = RingBufferWrite(
 		&Channel->Outbound,
diff --git a/drivers/staging/hv/RingBuffer.c b/drivers/staging/hv/RingBuffer.c
index d338ce2..571f9db 100644
--- a/drivers/staging/hv/RingBuffer.c
+++ b/drivers/staging/hv/RingBuffer.c
@@ -347,9 +347,9 @@ Description:
 --*/
 static int
 RingBufferWrite(
-	RING_BUFFER_INFO*	OutRingInfo,
-	SG_BUFFER_LIST		SgBuffers[],
-	u32				SgBufferCount
+	RING_BUFFER_INFO *OutRingInfo,
+	struct scatterlist *sglist,
+	u32 sgcount
 	)
 {
 	int i=0;
@@ -357,15 +357,16 @@ RingBufferWrite(
 	u32 byteAvailToRead;
 	u32 totalBytesToWrite=0;
 
+	struct scatterlist *sg;
 	volatile u32 nextWriteLocation;
 	u64 prevIndices=0;
 	unsigned long flags;
 
 	DPRINT_ENTER(VMBUS);
 
-	for (i=0; i < SgBufferCount; i++)
+	for_each_sg(sglist, sg, sgcount, i)
 	{
-		totalBytesToWrite += SgBuffers[i].Length;
+		totalBytesToWrite += sg->length;
 	}
 
 	totalBytesToWrite += sizeof(u64);
@@ -394,21 +395,21 @@ RingBufferWrite(
 	/* Write to the ring buffer */
 	nextWriteLocation = GetNextWriteLocation(OutRingInfo);
 
-	for (i=0; i < SgBufferCount; i++)
+	for_each_sg(sglist, sg, sgcount, i)
 	{
-		 nextWriteLocation = CopyToRingBuffer(OutRingInfo,
-												nextWriteLocation,
-												SgBuffers[i].Data,
-												SgBuffers[i].Length);
+		nextWriteLocation = CopyToRingBuffer(OutRingInfo,
+						     nextWriteLocation,
+						     sg_virt(sg),
+						     sg->length);
 	}
 
 	/* Set previous packet start */
 	prevIndices = GetRingBufferIndices(OutRingInfo);
 
 	nextWriteLocation = CopyToRingBuffer(OutRingInfo,
-												nextWriteLocation,
-												&prevIndices,
-												sizeof(u64));
+					     nextWriteLocation,
+					     &prevIndices,
+					     sizeof(u64));
 
 	/* Make sure we flush all writes before updating the writeIndex */
 	mb();
diff --git a/drivers/staging/hv/RingBuffer.h b/drivers/staging/hv/RingBuffer.h
index a0b6e0e..1658614 100644
--- a/drivers/staging/hv/RingBuffer.h
+++ b/drivers/staging/hv/RingBuffer.h
@@ -25,12 +25,9 @@
 #ifndef _RING_BUFFER_H_
 #define _RING_BUFFER_H_
 
-#include "include/osd.h"
+#include <linux/scatterlist.h>
 
-typedef struct _SG_BUFFER_LIST {
-	void *	Data;
-	u32	Length;
-} SG_BUFFER_LIST;
+#include "include/osd.h"
 
 typedef struct _RING_BUFFER {
     volatile u32	WriteIndex;     /* Offset in bytes from the start of ring data below */
@@ -83,9 +80,9 @@ RingBufferCleanup(
 
 static int
 RingBufferWrite(
-	RING_BUFFER_INFO	*RingInfo,
-	SG_BUFFER_LIST		SgBuffers[],
-	u32				SgBufferCount
+	RING_BUFFER_INFO *RingInfo,
+	struct scatterlist *sglist,
+	u32 sgcount
 	);
 
 static int
-- 
1.6.0.4


-- 
Nicolas Palix

             reply	other threads:[~2009-07-30 15:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-30 15:37 Nicolas Palix [this message]
2009-07-30 15:37 ` [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct scatterlist Nicolas Palix
2009-07-30 15:58 ` [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct Greg KH
2009-07-30 15:58   ` [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct scatterlist Greg KH
2009-07-30 16:14   ` [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct Hank Janssen
2009-07-30 16:14     ` [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct scatterlist Hank Janssen
2009-07-30 16:20     ` [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct Greg KH
2009-07-30 16:20       ` [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct scatterlist Greg KH
2009-07-30 18:35   ` [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct Nicolas Palix
2009-07-30 18:35     ` [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct scatterlist Nicolas Palix
2009-07-30 18:37     ` [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct Hank Janssen
2009-07-30 18:37       ` [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct scatterlist Hank Janssen
2009-07-30 19:52     ` [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct Greg KH
2009-07-30 19:52       ` [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct scatterlist Greg KH
2009-07-30 20:48       ` [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct Nicolas Palix
2009-07-30 20:48         ` [PATCH] Staging: hv: Replace typedef SG_BUFFER_LIST by struct scatterlist Nicolas Palix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200907301737.23849.npalix@diku.dk \
    --to=npalix@diku.dk \
    --cc=gregkh@suse.de \
    --cc=hjanssen@microsoft.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.