Commit a1d842e8 authored by Ken Cox's avatar Ken Cox Committed by Greg Kroah-Hartman

Staging: unisys: channels: Cleanup sparse warnings

Clean up multiple sparse warnings mostly due to different address spaces
when accessing I/O memory.

Also, remove SignalRemoveAll(), SignalQueueHasOneElement(),
SignalQueueIsFull(), because they were never called.
Signed-off-by: default avatarKen Cox <jkc@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4b4b535e
...@@ -44,38 +44,41 @@ ...@@ -44,38 +44,41 @@
* 1 if the insertion succeeds, 0 if the queue was full. * 1 if the insertion succeeds, 0 if the queue was full.
*/ */
unsigned char unsigned char
visor_signal_insert(pCHANNEL_HEADER pChannel, U32 Queue, void *pSignal) visor_signal_insert(CHANNEL_HEADER __iomem *pChannel, U32 Queue, void *pSignal)
{ {
void *psignal; void __iomem *psignal;
unsigned int head, tail; unsigned int head, tail, nof;
pSIGNAL_QUEUE_HEADER pqhdr =
(pSIGNAL_QUEUE_HEADER) ((char *) pChannel + SIGNAL_QUEUE_HEADER __iomem *pqhdr =
pChannel->oChannelSpace) + Queue; (SIGNAL_QUEUE_HEADER __iomem *)
((char __iomem *) pChannel + readq(&pChannel->oChannelSpace))
+ Queue;
/* capture current head and tail */ /* capture current head and tail */
head = pqhdr->Head; head = readl(&pqhdr->Head);
tail = pqhdr->Tail; tail = readl(&pqhdr->Tail);
/* queue is full if (head + 1) % n equals tail */ /* queue is full if (head + 1) % n equals tail */
if (((head + 1) % pqhdr->MaxSignalSlots) == tail) { if (((head + 1) % readl(&pqhdr->MaxSignalSlots)) == tail) {
pqhdr->NumOverflows++; nof = readq(&pqhdr->NumOverflows) + 1;
writeq(nof, &pqhdr->NumOverflows);
return 0; return 0;
} }
/* increment the head index */ /* increment the head index */
head = (head + 1) % pqhdr->MaxSignalSlots; head = (head + 1) % readl(&pqhdr->MaxSignalSlots);
/* copy signal to the head location from the area pointed to /* copy signal to the head location from the area pointed to
* by pSignal * by pSignal
*/ */
psignal = psignal = (char __iomem *)pqhdr + readq(&pqhdr->oSignalBase) +
(char *) pqhdr + pqhdr->oSignalBase + (head * pqhdr->SignalSize); (head * readl(&pqhdr->SignalSize));
MEMCPY(psignal, pSignal, pqhdr->SignalSize); MEMCPY_TOIO(psignal, pSignal, readl(&pqhdr->SignalSize));
VolatileBarrier(); VolatileBarrier();
pqhdr->Head = head; writel(head, &pqhdr->Head);
pqhdr->NumSignalsSent++; writeq(readq(&pqhdr->NumSignalsSent) + 1, &pqhdr->NumSignalsSent);
return 1; return 1;
} }
EXPORT_SYMBOL_GPL(visor_signal_insert); EXPORT_SYMBOL_GPL(visor_signal_insert);
...@@ -99,36 +102,37 @@ EXPORT_SYMBOL_GPL(visor_signal_insert); ...@@ -99,36 +102,37 @@ EXPORT_SYMBOL_GPL(visor_signal_insert);
* 1 if the removal succeeds, 0 if the queue was empty. * 1 if the removal succeeds, 0 if the queue was empty.
*/ */
unsigned char unsigned char
visor_signal_remove(pCHANNEL_HEADER pChannel, U32 Queue, void *pSignal) visor_signal_remove(CHANNEL_HEADER __iomem *pChannel, U32 Queue, void *pSignal)
{ {
void *psource; void __iomem *psource;
unsigned int head, tail; unsigned int head, tail;
pSIGNAL_QUEUE_HEADER pqhdr = SIGNAL_QUEUE_HEADER __iomem *pqhdr =
(pSIGNAL_QUEUE_HEADER) ((char *) pChannel + (SIGNAL_QUEUE_HEADER __iomem *) ((char __iomem *) pChannel +
pChannel->oChannelSpace) + Queue; readq(&pChannel->oChannelSpace)) + Queue;
/* capture current head and tail */ /* capture current head and tail */
head = pqhdr->Head; head = readl(&pqhdr->Head);
tail = pqhdr->Tail; tail = readl(&pqhdr->Tail);
/* queue is empty if the head index equals the tail index */ /* queue is empty if the head index equals the tail index */
if (head == tail) { if (head == tail) {
pqhdr->NumEmptyCnt++; writeq(readq(&pqhdr->NumEmptyCnt) + 1, &pqhdr->NumEmptyCnt);
return 0; return 0;
} }
/* advance past the 'empty' front slot */ /* advance past the 'empty' front slot */
tail = (tail + 1) % pqhdr->MaxSignalSlots; tail = (tail + 1) % readl(&pqhdr->MaxSignalSlots);
/* copy signal from tail location to the area pointed to by pSignal */ /* copy signal from tail location to the area pointed to by pSignal */
psource = psource = (char __iomem *) pqhdr + readq(&pqhdr->oSignalBase) +
(char *) pqhdr + pqhdr->oSignalBase + (tail * pqhdr->SignalSize); (tail * readl(&pqhdr->SignalSize));
MEMCPY(pSignal, psource, pqhdr->SignalSize); MEMCPY_FROMIO(pSignal, psource, readl(&pqhdr->SignalSize));
VolatileBarrier(); VolatileBarrier();
pqhdr->Tail = tail; writel(tail, &pqhdr->Tail);
pqhdr->NumSignalsReceived++; writeq(readq(&pqhdr->NumSignalsReceived) + 1,
&pqhdr->NumSignalsReceived);
return 1; return 1;
} }
EXPORT_SYMBOL_GPL(visor_signal_remove); EXPORT_SYMBOL_GPL(visor_signal_remove);
...@@ -192,59 +196,6 @@ SignalRemoveAll(pCHANNEL_HEADER pChannel, U32 Queue, void *pSignal) ...@@ -192,59 +196,6 @@ SignalRemoveAll(pCHANNEL_HEADER pChannel, U32 Queue, void *pSignal)
return signalCount; return signalCount;
} }
/*
* Routine Description:
* Copies one signal from channel pChannel's nth Queue at the given position
* at the time of the call into the memory pointed to by pSignal.
*
* Parameters:
* pChannel: (IN) points to the IO Channel
* Queue: (IN) nth Queue of the IO Channel
* Position: (IN) nth entry in Queue of the IO Channel
* pSignal: (IN) pointer to where the signals are to be copied
*
* Assumptions:
* - pChannel and Queue are valid.
* - pSignal points to a memory area large enough to hold queue's SignalSize
*
* Return value:
* 1 if the copy succeeds, 0 if the queue was empty or Position was invalid.
*/
unsigned char
SignalPeek(pCHANNEL_HEADER pChannel, U32 Queue, U32 Position, void *pSignal)
{
void *psignal;
unsigned int head, tail;
pSIGNAL_QUEUE_HEADER pqhdr =
(pSIGNAL_QUEUE_HEADER) ((char *) pChannel +
pChannel->oChannelSpace) + Queue;
head = pqhdr->Head;
tail = pqhdr->Tail;
/* check if Position is out of range or queue is empty */
if (Position >= pqhdr->MaxSignalSlots || Position == tail
|| head == tail)
return 0;
/* check if Position is between tail and head */
if (head > tail) {
if (Position > head || Position < tail)
return 0;
} else if ((Position > head) && (Position < tail))
return 0;
/* copy signal from Position location to the area pointed to
* by pSignal
*/
psignal =
(char *) pqhdr + pqhdr->oSignalBase +
(Position * pqhdr->SignalSize);
MEMCPY(pSignal, psignal, pqhdr->SignalSize);
return 1;
}
/* /*
* Routine Description: * Routine Description:
* Determine whether a signal queue is empty. * Determine whether a signal queue is empty.
...@@ -257,51 +208,12 @@ SignalPeek(pCHANNEL_HEADER pChannel, U32 Queue, U32 Position, void *pSignal) ...@@ -257,51 +208,12 @@ SignalPeek(pCHANNEL_HEADER pChannel, U32 Queue, U32 Position, void *pSignal)
* 1 if the signal queue is empty, 0 otherwise. * 1 if the signal queue is empty, 0 otherwise.
*/ */
unsigned char unsigned char
visor_signalqueue_empty(pCHANNEL_HEADER pChannel, U32 Queue) visor_signalqueue_empty(CHANNEL_HEADER __iomem *pChannel, U32 Queue)
{ {
pSIGNAL_QUEUE_HEADER pqhdr = SIGNAL_QUEUE_HEADER __iomem *pqhdr =
(pSIGNAL_QUEUE_HEADER) ((char *) pChannel + (SIGNAL_QUEUE_HEADER __iomem *) ((char __iomem *) pChannel +
pChannel->oChannelSpace) + Queue; readq(&pChannel->oChannelSpace)) + Queue;
return pqhdr->Head == pqhdr->Tail; return readl(&pqhdr->Head) == readl(&pqhdr->Tail);
} }
EXPORT_SYMBOL_GPL(visor_signalqueue_empty); EXPORT_SYMBOL_GPL(visor_signalqueue_empty);
/*
* Routine Description:
* Determine whether a signal queue is empty.
*
* Parameters:
* pChannel: (IN) points to the IO Channel
* Queue: (IN) nth Queue of the IO Channel
*
* Return value:
* 1 if the signal queue has 1 element, 0 otherwise.
*/
unsigned char
SignalQueueHasOneElement(pCHANNEL_HEADER pChannel, U32 Queue)
{
pSIGNAL_QUEUE_HEADER pqhdr =
(pSIGNAL_QUEUE_HEADER) ((char *) pChannel +
pChannel->oChannelSpace) + Queue;
return ((pqhdr->Tail + 1) % pqhdr->MaxSignalSlots) == pqhdr->Head;
}
/*
* Routine Description:
* Determine whether a signal queue is full.
*
* Parameters:
* pChannel: (IN) points to the IO Channel
* Queue: (IN) nth Queue of the IO Channel
*
* Return value:
* 1 if the signal queue is full, 0 otherwise.
*/
unsigned char
SignalQueueIsFull(pCHANNEL_HEADER pChannel, U32 Queue)
{
pSIGNAL_QUEUE_HEADER pqhdr =
(pSIGNAL_QUEUE_HEADER) ((char *) pChannel +
pChannel->oChannelSpace) + Queue;
return ((pqhdr->Head + 1) % pqhdr->MaxSignalSlots) == pqhdr->Tail;
}
...@@ -27,19 +27,19 @@ ...@@ -27,19 +27,19 @@
#include "chanstub.h" #include "chanstub.h"
#include "version.h" #include "version.h"
__init int static __init int
channel_mod_init(void) channel_mod_init(void)
{ {
return 0; return 0;
} }
__exit void static __exit void
channel_mod_exit(void) channel_mod_exit(void)
{ {
} }
unsigned char unsigned char
SignalInsert_withLock(pCHANNEL_HEADER pChannel, U32 Queue, SignalInsert_withLock(CHANNEL_HEADER __iomem *pChannel, U32 Queue,
void *pSignal, spinlock_t *lock) void *pSignal, spinlock_t *lock)
{ {
unsigned char result; unsigned char result;
...@@ -51,7 +51,7 @@ SignalInsert_withLock(pCHANNEL_HEADER pChannel, U32 Queue, ...@@ -51,7 +51,7 @@ SignalInsert_withLock(pCHANNEL_HEADER pChannel, U32 Queue,
} }
unsigned char unsigned char
SignalRemove_withLock(pCHANNEL_HEADER pChannel, U32 Queue, SignalRemove_withLock(CHANNEL_HEADER __iomem *pChannel, U32 Queue,
void *pSignal, spinlock_t *lock) void *pSignal, spinlock_t *lock)
{ {
unsigned char result; unsigned char result;
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
#ifndef __CHANSTUB_H__ #ifndef __CHANSTUB_H__
#define __CHANSTUB_H__ #define __CHANSTUB_H__
unsigned char SignalInsert_withLock(pCHANNEL_HEADER pChannel, U32 Queue, unsigned char SignalInsert_withLock(CHANNEL_HEADER __iomem *pChannel, U32 Queue,
void *pSignal, spinlock_t *lock); void *pSignal, spinlock_t *lock);
unsigned char SignalRemove_withLock(pCHANNEL_HEADER pChannel, U32 Queue, unsigned char SignalRemove_withLock(CHANNEL_HEADER __iomem *pChannel, U32 Queue,
void *pSignal, spinlock_t *lock); void *pSignal, spinlock_t *lock);
#endif #endif
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/types.h> #include <linux/types.h>
#include <linux/version.h> #include <linux/version.h>
#include <linux/io.h>
#else #else
#include <stdint.h> #include <stdint.h>
#include <syslog.h> #include <syslog.h>
...@@ -72,6 +73,7 @@ typedef U64 GUEST_PHYSICAL_ADDRESS; ...@@ -72,6 +73,7 @@ typedef U64 GUEST_PHYSICAL_ADDRESS;
#define MEMSET(ptr, val, len) memset(ptr, val, len) #define MEMSET(ptr, val, len) memset(ptr, val, len)
#define MEMCMP(m1, m2, len) memcmp(m1, m2, len) #define MEMCMP(m1, m2, len) memcmp(m1, m2, len)
#define MEMCMP_IO(m1, m2, len) memcmp((void __force *)m1, m2, len)
#define STRLEN(s) ((UINTN)strlen((const char *)s)) #define STRLEN(s) ((UINTN)strlen((const char *)s))
#define STRCPY(d, s) (strcpy((char *)d, (const char *)s)) #define STRCPY(d, s) (strcpy((char *)d, (const char *)s))
...@@ -81,6 +83,8 @@ typedef U64 GUEST_PHYSICAL_ADDRESS; ...@@ -81,6 +83,8 @@ typedef U64 GUEST_PHYSICAL_ADDRESS;
#ifdef __KERNEL__ #ifdef __KERNEL__
#define MEMORYBARRIER mb() #define MEMORYBARRIER mb()
#define MEMCPY(dest, src, len) memcpy(dest, src, len) #define MEMCPY(dest, src, len) memcpy(dest, src, len)
#define MEMCPY_TOIO(dest, src, len) memcpy_toio(dest, src, len)
#define MEMCPY_FROMIO(dest, src, len) memcpy_fromio(dest, src, len)
#define CHANNEL_GUID_MISMATCH(chType, chName, field, expected, actual, fil, \ #define CHANNEL_GUID_MISMATCH(chType, chName, field, expected, actual, fil, \
lin, logCtx) \ lin, logCtx) \
......
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