Browse Source

Staging: unisys: uislib: Cleanup sparse warnings in uislib

Clean up code to get rid of sparse warnings, mostly related to accessing I/O
space.

Remove uislibcmpxchg64() and use cmpxchg() instead.

Signed-off-by: Ken Cox <jkc@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Ken Cox 11 years ago
parent
commit
8504ff6cab

+ 12 - 44
drivers/staging/unisys/include/uisqueue.h

@@ -34,7 +34,7 @@
 
 
 struct uisqueue_info {
 struct uisqueue_info {
 
 
-	pCHANNEL_HEADER chan;
+	CHANNEL_HEADER __iomem *chan;
 	/* channel containing queues in which scsi commands &
 	/* channel containing queues in which scsi commands &
 	 * responses are queued
 	 * responses are queued
 	 */
 	 */
@@ -75,9 +75,9 @@ struct uisqueue_info {
 		".previous\n"                   \
 		".previous\n"                   \
 		"661:\n\tlock; "
 		"661:\n\tlock; "
 
 
-unsigned long long uisqueue_InterlockedOr(volatile unsigned long long *Target,
+unsigned long long uisqueue_InterlockedOr(unsigned long long __iomem *Target,
 					  unsigned long long Set);
 					  unsigned long long Set);
-unsigned long long uisqueue_InterlockedAnd(volatile unsigned long long *Target,
+unsigned long long uisqueue_InterlockedAnd(unsigned long long __iomem *Target,
 					   unsigned long long Set);
 					   unsigned long long Set);
 
 
 unsigned int uisqueue_send_int_if_needed(struct uisqueue_info *pqueueinfo,
 unsigned int uisqueue_send_int_if_needed(struct uisqueue_info *pqueueinfo,
@@ -133,7 +133,7 @@ struct extport_info {
 };
 };
 
 
 struct device_info {
 struct device_info {
-	void *chanptr;
+	void __iomem *chanptr;
 	U64 channelAddr;
 	U64 channelAddr;
 	U64 channelBytes;
 	U64 channelBytes;
 	GUID channelTypeGuid;
 	GUID channelTypeGuid;
@@ -164,7 +164,7 @@ struct bus_info {
 	struct device_info **device;
 	struct device_info **device;
 	U64 guestHandle, recvBusInterruptHandle;
 	U64 guestHandle, recvBusInterruptHandle;
 	GUID busInstGuid;
 	GUID busInstGuid;
-	ULTRA_VBUS_CHANNEL_PROTOCOL *pBusChannel;
+	ULTRA_VBUS_CHANNEL_PROTOCOL __iomem *pBusChannel;
 	int busChannelBytes;
 	int busChannelBytes;
 	struct proc_dir_entry *proc_dir;	/* proc/uislib/vbus/<x> */
 	struct proc_dir_entry *proc_dir;	/* proc/uislib/vbus/<x> */
 	struct proc_dir_entry *proc_info;	/* proc/uislib/vbus/<x>/info */
 	struct proc_dir_entry *proc_info;	/* proc/uislib/vbus/<x>/info */
@@ -352,8 +352,8 @@ typedef enum {
 } GUESTPART_MSG_TYPE;
 } GUESTPART_MSG_TYPE;
 
 
 struct add_vbus_guestpart {
 struct add_vbus_guestpart {
-	void *chanptr;		/* pointer to data channel for bus -
-				 * NOT YET USED */
+	void __iomem *chanptr;		/* pointer to data channel for bus -
+					 * NOT YET USED */
 	U32 busNo;		/* bus number to be created/deleted */
 	U32 busNo;		/* bus number to be created/deleted */
 	U32 deviceCount;	/* max num of devices on bus */
 	U32 deviceCount;	/* max num of devices on bus */
 	GUID busTypeGuid;	/* indicates type of bus */
 	GUID busTypeGuid;	/* indicates type of bus */
@@ -368,7 +368,7 @@ struct del_vbus_guestpart {
 };
 };
 
 
 struct add_virt_guestpart {
 struct add_virt_guestpart {
-	void *chanptr;		/* pointer to data channel */
+	void __iomem *chanptr;		/* pointer to data channel */
 	U32 busNo;		/* bus number for the operation */
 	U32 busNo;		/* bus number for the operation */
 	U32 deviceNo;		/* number of device on the bus */
 	U32 deviceNo;		/* number of device on the bus */
 	GUID devInstGuid;	/* instance guid for device */
 	GUID devInstGuid;	/* instance guid for device */
@@ -382,15 +382,15 @@ struct add_virt_guestpart {
 };
 };
 
 
 struct pause_virt_guestpart {
 struct pause_virt_guestpart {
-	void *chanptr;		/* pointer to data channel */
+	void __iomem *chanptr;		/* pointer to data channel */
 };
 };
 
 
 struct resume_virt_guestpart {
 struct resume_virt_guestpart {
-	void *chanptr;		/* pointer to data channel */
+	void __iomem *chanptr;		/* pointer to data channel */
 };
 };
 
 
 struct del_virt_guestpart {
 struct del_virt_guestpart {
-	void *chanptr;		/* pointer to data channel */
+	void __iomem *chanptr;		/* pointer to data channel */
 };
 };
 
 
 struct init_chipset_guestpart {
 struct init_chipset_guestpart {
@@ -435,38 +435,6 @@ struct guest_msgs {
 *  guests.
 *  guests.
 */
 */
 
 
-static inline unsigned long
-uislibcmpxchg64(volatile void *ptr, unsigned long old, unsigned long new,
-		int size)
-{
-	unsigned long prev;
-	switch (size) {
-	case 1:
-	      __asm__ __volatile__(UISLIB_LOCK_PREFIX "cmpxchgb %b1,%2":"=a"(prev)
-	      :		     "q"(new), "m"(*__xg(ptr)),
-				     "0"(old)
-	      :		     "memory");
-		return prev;
-	case 2:
-	      __asm__ __volatile__(UISLIB_LOCK_PREFIX "cmpxchgw %w1,%2":"=a"(prev)
-	      :		     "r"(new), "m"(*__xg(ptr)),
-				     "0"(old)
-	      :		     "memory");
-		return prev;
-	case 4:
-	      __asm__ __volatile__(UISLIB_LOCK_PREFIX "cmpxchgl %k1,%2":"=a"(prev)
-	      :		     "r"(new), "m"(*__xg(ptr)),
-				     "0"(old)
-	      :		     "memory");
-		return prev;
-	case 8:
-	      __asm__ __volatile__(UISLIB_LOCK_PREFIX "cmpxchgq %1,%2":"=a"(prev)
-	      :		     "r"(new), "m"(*__xg(ptr)),
-				     "0"(old)
-	      :		     "memory");
-		return prev;
-	}
-	return old;
-}
+#define uislibcmpxchg64(p, o, n, s) cmpxchg(p, o, n)
 
 
 #endif				/* __UISQUEUE_H__ */
 #endif				/* __UISQUEUE_H__ */

+ 4 - 4
drivers/staging/unisys/include/uisutils.h

@@ -79,10 +79,10 @@ int ReqHandlerDel(GUID switchTypeGuid);
 #define uislib_ioremap_cache(addr, size) \
 #define uislib_ioremap_cache(addr, size) \
 	dbg_ioremap_cache(addr, size, __FILE__, __LINE__)
 	dbg_ioremap_cache(addr, size, __FILE__, __LINE__)
 
 
-static inline void *
+static inline void __iomem *
 dbg_ioremap_cache(U64 addr, unsigned long size, char *file, int line)
 dbg_ioremap_cache(U64 addr, unsigned long size, char *file, int line)
 {
 {
-	void *new;
+	void __iomem *new;
 	new = ioremap_cache(addr, size);
 	new = ioremap_cache(addr, size);
 	return new;
 	return new;
 }
 }
@@ -100,7 +100,7 @@ dbg_ioremap(U64 addr, unsigned long size, char *file, int line)
 #define uislib_iounmap(addr) dbg_iounmap(addr, __FILE__, __LINE__)
 #define uislib_iounmap(addr) dbg_iounmap(addr, __FILE__, __LINE__)
 
 
 static inline void
 static inline void
-dbg_iounmap(void *addr, char *file, int line)
+dbg_iounmap(void __iomem *addr, char *file, int line)
 {
 {
 	iounmap(addr);
 	iounmap(addr);
 }
 }
@@ -202,7 +202,7 @@ struct chaninfo {
  */
  */
 #define WAIT_FOR_VALID_GUID(guid) \
 #define WAIT_FOR_VALID_GUID(guid) \
 	do {						   \
 	do {						   \
-		while (memcmp(&guid, &Guid0, sizeof(Guid0)) == 0) {	\
+		while (MEMCMP_IO(&guid, &Guid0, sizeof(Guid0)) == 0) {	\
 			LOGERR("Waiting for non-0 GUID (why???)...\n"); \
 			LOGERR("Waiting for non-0 GUID (why???)...\n"); \
 			UIS_THREAD_WAIT_SEC(5);				\
 			UIS_THREAD_WAIT_SEC(5);				\
 		}							\
 		}							\

+ 6 - 6
drivers/staging/unisys/uislib/uisqueue.c

@@ -39,16 +39,16 @@
 /* Exported functions                                */
 /* Exported functions                                */
 /*****************************************************/
 /*****************************************************/
 unsigned long long
 unsigned long long
-uisqueue_InterlockedOr(volatile unsigned long long *Target,
+uisqueue_InterlockedOr(unsigned long long __iomem *Target,
 		       unsigned long long Set)
 		       unsigned long long Set)
 {
 {
 	unsigned long long i;
 	unsigned long long i;
 	unsigned long long j;
 	unsigned long long j;
 
 
-	j = *Target;
+	j = readq(Target);
 	do {
 	do {
 		i = j;
 		i = j;
-		j = uislibcmpxchg64((unsigned long long *) Target,
+		j = uislibcmpxchg64((__force unsigned long long *)Target,
 				    i, i | Set, sizeof(*(Target)));
 				    i, i | Set, sizeof(*(Target)));
 
 
 	} while (i != j);
 	} while (i != j);
@@ -58,16 +58,16 @@ uisqueue_InterlockedOr(volatile unsigned long long *Target,
 EXPORT_SYMBOL_GPL(uisqueue_InterlockedOr);
 EXPORT_SYMBOL_GPL(uisqueue_InterlockedOr);
 
 
 unsigned long long
 unsigned long long
-uisqueue_InterlockedAnd(volatile unsigned long long *Target,
+uisqueue_InterlockedAnd(unsigned long long __iomem *Target,
 			unsigned long long Set)
 			unsigned long long Set)
 {
 {
 	unsigned long long i;
 	unsigned long long i;
 	unsigned long long j;
 	unsigned long long j;
 
 
-	j = *Target;
+	j = readq(Target);
 	do {
 	do {
 		i = j;
 		i = j;
-		j = uislibcmpxchg64((unsigned long long *) Target,
+		j = uislibcmpxchg64((__force unsigned long long *)Target,
 				    i, i & Set, sizeof(*(Target)));
 				    i, i & Set, sizeof(*(Target)));
 
 
 	} while (i != j);
 	} while (i != j);