Staging: hv: fix various coding style issues in RingBuffer.c

This is a patch to the RingBuffer.c file that corrects various coding style
warnings and errors found by checkpatch.pl

[ The real solution here is to get rid of this file entirely, and use the
kernel's internal ring buffer api, but until then, make these changes so as to
make checkpatch.pl happy, and keep others from continuously sending this type
of patch. - gkh]

Signed-off-by: Craig Bartlett <c-bartlett@hotmail.co.uk>
Cc: Bill Pemberton <wfp5p@virginia.edu>
Cc: Nicolas Palix <npalix@diku.dk>
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:
C. Bartlett 2010-02-03 15:34:27 +00:00 коммит произвёл Greg Kroah-Hartman
Родитель a73e6b7c50
Коммит 4408f5319b
1 изменённых файлов: 86 добавлений и 67 удалений

Просмотреть файл

@ -192,7 +192,8 @@ Description:
static inline u64 static inline u64
GetRingBufferIndices(RING_BUFFER_INFO *RingInfo) GetRingBufferIndices(RING_BUFFER_INFO *RingInfo)
{ {
return ((u64)RingInfo->RingBuffer->WriteIndex << 32) || RingInfo->RingBuffer->ReadIndex; return ((u64)RingInfo->RingBuffer->WriteIndex << 32)
|| RingInfo->RingBuffer->ReadIndex;
} }
@ -210,9 +211,14 @@ void DumpRingInfo(RING_BUFFER_INFO *RingInfo, char *Prefix)
u32 bytesAvailToWrite; u32 bytesAvailToWrite;
u32 bytesAvailToRead; u32 bytesAvailToRead;
GetRingBufferAvailBytes(RingInfo, &bytesAvailToRead, &bytesAvailToWrite); GetRingBufferAvailBytes(RingInfo,
&bytesAvailToRead,
&bytesAvailToWrite);
DPRINT(VMBUS, DEBUG_RING_LVL, "%s <<ringinfo %p buffer %p avail write %u avail read %u read idx %u write idx %u>>", DPRINT(VMBUS,
DEBUG_RING_LVL,
"%s <<ringinfo %p buffer %p avail write %u "
"avail read %u read idx %u write idx %u>>",
Prefix, Prefix,
RingInfo, RingInfo,
RingInfo->RingBuffer->Buffer, RingInfo->RingBuffer->Buffer,
@ -256,15 +262,15 @@ void RingBufferGetDebugInfo(RING_BUFFER_INFO *RingInfo,
u32 bytesAvailToWrite; u32 bytesAvailToWrite;
u32 bytesAvailToRead; u32 bytesAvailToRead;
if (RingInfo->RingBuffer) if (RingInfo->RingBuffer) {
{ GetRingBufferAvailBytes(RingInfo,
GetRingBufferAvailBytes(RingInfo, &bytesAvailToRead, &bytesAvailToWrite); &bytesAvailToRead,
&bytesAvailToWrite);
DebugInfo->BytesAvailToRead = bytesAvailToRead; DebugInfo->BytesAvailToRead = bytesAvailToRead;
DebugInfo->BytesAvailToWrite = bytesAvailToWrite; DebugInfo->BytesAvailToWrite = bytesAvailToWrite;
DebugInfo->CurrentReadIndex = RingInfo->RingBuffer->ReadIndex; DebugInfo->CurrentReadIndex = RingInfo->RingBuffer->ReadIndex;
DebugInfo->CurrentWriteIndex = RingInfo->RingBuffer->WriteIndex; DebugInfo->CurrentWriteIndex = RingInfo->RingBuffer->WriteIndex;
DebugInfo->CurrentInterruptMask = RingInfo->RingBuffer->InterruptMask; DebugInfo->CurrentInterruptMask = RingInfo->RingBuffer->InterruptMask;
} }
} }
@ -356,17 +362,23 @@ int RingBufferWrite(RING_BUFFER_INFO *OutRingInfo,
spin_lock_irqsave(&OutRingInfo->ring_lock, flags); spin_lock_irqsave(&OutRingInfo->ring_lock, flags);
GetRingBufferAvailBytes(OutRingInfo, &byteAvailToRead, &byteAvailToWrite); GetRingBufferAvailBytes(OutRingInfo,
&byteAvailToRead,
&byteAvailToWrite);
DPRINT_DBG(VMBUS, "Writing %u bytes...", totalBytesToWrite); DPRINT_DBG(VMBUS, "Writing %u bytes...", totalBytesToWrite);
/* DumpRingInfo(OutRingInfo, "BEFORE "); */ /* DumpRingInfo(OutRingInfo, "BEFORE "); */
/* If there is only room for the packet, assume it is full. Otherwise, the next time around, we think the ring buffer */ /* If there is only room for the packet, assume it is full. */
/* Otherwise, the next time around, we think the ring buffer */
/* is empty since the read index == write index */ /* is empty since the read index == write index */
if (byteAvailToWrite <= totalBytesToWrite) if (byteAvailToWrite <= totalBytesToWrite) {
{ DPRINT_DBG(VMBUS,
DPRINT_DBG(VMBUS, "No more space left on outbound ring buffer (needed %u, avail %u)", totalBytesToWrite, byteAvailToWrite); "No more space left on outbound ring buffer "
"(needed %u, avail %u)",
totalBytesToWrite,
byteAvailToWrite);
spin_unlock_irqrestore(&OutRingInfo->ring_lock, flags); spin_unlock_irqrestore(&OutRingInfo->ring_lock, flags);
@ -428,12 +440,17 @@ int RingBufferPeek(RING_BUFFER_INFO *InRingInfo, void *Buffer, u32 BufferLen)
spin_lock_irqsave(&InRingInfo->ring_lock, flags); spin_lock_irqsave(&InRingInfo->ring_lock, flags);
GetRingBufferAvailBytes(InRingInfo, &bytesAvailToRead, &bytesAvailToWrite); GetRingBufferAvailBytes(InRingInfo,
&bytesAvailToRead,
&bytesAvailToWrite);
/* Make sure there is something to read */ /* Make sure there is something to read */
if (bytesAvailToRead < BufferLen ) if (bytesAvailToRead < BufferLen) {
{ /* DPRINT_DBG(VMBUS,
/* DPRINT_DBG(VMBUS, "got callback but not enough to read <avail to read %d read size %d>!!", bytesAvailToRead, BufferLen); */ "got callback but not enough to read "
"<avail to read %d read size %d>!!",
bytesAvailToRead,
BufferLen); */
spin_unlock_irqrestore(&InRingInfo->ring_lock, flags); spin_unlock_irqrestore(&InRingInfo->ring_lock, flags);
@ -476,16 +493,21 @@ int RingBufferRead(RING_BUFFER_INFO *InRingInfo, void *Buffer,
spin_lock_irqsave(&InRingInfo->ring_lock, flags); spin_lock_irqsave(&InRingInfo->ring_lock, flags);
GetRingBufferAvailBytes(InRingInfo, &bytesAvailToRead, &bytesAvailToWrite); GetRingBufferAvailBytes(InRingInfo,
&bytesAvailToRead,
&bytesAvailToWrite);
DPRINT_DBG(VMBUS, "Reading %u bytes...", BufferLen); DPRINT_DBG(VMBUS, "Reading %u bytes...", BufferLen);
/* DumpRingInfo(InRingInfo, "BEFORE "); */ /* DumpRingInfo(InRingInfo, "BEFORE "); */
/* Make sure there is something to read */ /* Make sure there is something to read */
if (bytesAvailToRead < BufferLen ) if (bytesAvailToRead < BufferLen) {
{ DPRINT_DBG(VMBUS,
DPRINT_DBG(VMBUS, "got callback but not enough to read <avail to read %d read size %d>!!", bytesAvailToRead, BufferLen); "got callback but not enough to read "
"<avail to read %d read size %d>!!",
bytesAvailToRead,
BufferLen);
spin_unlock_irqrestore(&InRingInfo->ring_lock, flags); spin_unlock_irqrestore(&InRingInfo->ring_lock, flags);
@ -505,7 +527,8 @@ int RingBufferRead(RING_BUFFER_INFO *InRingInfo, void *Buffer,
nextReadLocation); nextReadLocation);
/* Make sure all reads are done before we update the read index since */ /* Make sure all reads are done before we update the read index since */
/* the writer may start writing to the read area once the read index is updated */ /* the writer may start writing to the read area once the read index */
/*is updated */
mb(); mb();
/* Update the read index */ /* Update the read index */
@ -540,18 +563,15 @@ CopyToRingBuffer(
u32 ringBufferSize = GetRingBufferSize(RingInfo); u32 ringBufferSize = GetRingBufferSize(RingInfo);
u32 fragLen; u32 fragLen;
if (SrcLen > ringBufferSize - StartWriteOffset) /* wrap-around detected! */ /* wrap-around detected! */
{ if (SrcLen > ringBufferSize - StartWriteOffset) {
DPRINT_DBG(VMBUS, "wrap-around detected!"); DPRINT_DBG(VMBUS, "wrap-around detected!");
fragLen = ringBufferSize - StartWriteOffset; fragLen = ringBufferSize - StartWriteOffset;
memcpy(ringBuffer + StartWriteOffset, Src, fragLen); memcpy(ringBuffer + StartWriteOffset, Src, fragLen);
memcpy(ringBuffer, Src + fragLen, SrcLen - fragLen); memcpy(ringBuffer, Src + fragLen, SrcLen - fragLen);
} } else
else
{
memcpy(ringBuffer + StartWriteOffset, Src, SrcLen); memcpy(ringBuffer + StartWriteOffset, Src, SrcLen);
}
StartWriteOffset += SrcLen; StartWriteOffset += SrcLen;
StartWriteOffset %= ringBufferSize; StartWriteOffset %= ringBufferSize;
@ -582,19 +602,18 @@ CopyFromRingBuffer(
u32 fragLen; u32 fragLen;
if (DestLen > ringBufferSize - StartReadOffset) /* wrap-around detected at the src */ /* wrap-around detected at the src */
{ if (DestLen > ringBufferSize - StartReadOffset) {
DPRINT_DBG(VMBUS, "src wrap-around detected!"); DPRINT_DBG(VMBUS, "src wrap-around detected!");
fragLen = ringBufferSize - StartReadOffset; fragLen = ringBufferSize - StartReadOffset;
memcpy(Dest, ringBuffer + StartReadOffset, fragLen); memcpy(Dest, ringBuffer + StartReadOffset, fragLen);
memcpy(Dest + fragLen, ringBuffer, DestLen - fragLen); memcpy(Dest + fragLen, ringBuffer, DestLen - fragLen);
} } else
else
{
memcpy(Dest, ringBuffer + StartReadOffset, DestLen); memcpy(Dest, ringBuffer + StartReadOffset, DestLen);
}
StartReadOffset += DestLen; StartReadOffset += DestLen;
StartReadOffset %= ringBufferSize; StartReadOffset %= ringBufferSize;