[Patch v3 2/4] Staging: unisys: Fix sparse warnings in uislib

Ken Cox jkc at redhat.com
Thu Jun 5 18:56:16 UTC 2014


Added I/O version for the function ultra_vbus_init_channel() to get rid
of noderef sparse warnings when accessing I/O space.

Signed-off-by: Ken Cox <jkc at redhat.com>
---
 .../common-spar/include/channels/vbuschannel.h     | 40 ++++++++++++++++++++--
 drivers/staging/unisys/uislib/uislib.c             |  2 +-
 2 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h
index 000182c..af5a1ff 100644
--- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h
+++ b/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h
@@ -95,12 +95,46 @@ typedef struct _ULTRA_VBUS_CHANNEL_PROTOCOL {
 #define VBUS_CH_SIZE(MAXDEVICES) COVER(VBUS_CH_SIZE_EXACT(MAXDEVICES), 4096)
 
 static inline void
-ultra_vbus_init_channel(ULTRA_VBUS_CHANNEL_PROTOCOL __iomem *x,
-			int bytesAllocated)
+ultra_vbus_init_channel(ULTRA_VBUS_CHANNEL_PROTOCOL *x,
+			int bytes)
 {
 	/* Please note that the memory at <x> does NOT necessarily have space
 	* for DevInfo structs allocated at the end, which is why we do NOT use
-	* <bytesAllocated> to clear. */
+	* <bytes> to clear. */
+	memset(x, 0, sizeof(ULTRA_VBUS_CHANNEL_PROTOCOL));
+	if (bytes < (int) sizeof(ULTRA_VBUS_CHANNEL_PROTOCOL))
+		return;
+
+	x->ChannelHeader.VersionId = ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID;
+	x->ChannelHeader.Signature = ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE;
+	x->ChannelHeader.SrvState = CHANNELSRV_READY;
+	x->ChannelHeader.HeaderSize = sizeof(x->ChannelHeader);
+	x->ChannelHeader.Size = bytes;
+	memcpy(&x->ChannelHeader.Type, &UltraVbusChannelProtocolGuid,
+		    sizeof(x->ChannelHeader.Type));
+	memcpy(&x->ChannelHeader.ZoneGuid, &NULL_UUID_LE, sizeof(uuid_le));
+	x->HdrInfo.structBytes = sizeof(ULTRA_VBUS_HEADERINFO);
+	x->HdrInfo.chpInfoByteOffset = sizeof(ULTRA_VBUS_HEADERINFO);
+	x->HdrInfo.busInfoByteOffset += sizeof(ULTRA_VBUS_DEVICEINFO);
+	x->HdrInfo.devInfoByteOffset += sizeof(ULTRA_VBUS_DEVICEINFO);
+	x->HdrInfo.deviceInfoStructBytes = sizeof(ULTRA_VBUS_DEVICEINFO);
+	bytes -= (sizeof(ULTRA_CHANNEL_PROTOCOL) +
+		  x->HdrInfo.devInfoByteOffset);
+	x->HdrInfo.devInfoCount = bytes / x->HdrInfo.deviceInfoStructBytes;
+}
+
+static inline void
+ultra_vbus_init_channel_io(ULTRA_VBUS_CHANNEL_PROTOCOL __iomem *x,
+			int bytesAllocated)
+{
+	/*
+	 * This is the same as ultra_vbus_init_channel() above, except
+	 * that it operates on I/O space.
+	 *
+	 * Please note that the memory at <x> does NOT necessarily have space
+	 * for DevInfo structs allocated at the end, which is why we do NOT use
+	 * <bytesAllocated> to clear.
+	 */
 	memset_io(x, 0, sizeof(ULTRA_VBUS_CHANNEL_PROTOCOL));
 	if (bytesAllocated < (int) sizeof(ULTRA_VBUS_CHANNEL_PROTOCOL))
 		return;
diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c
index 70cc00f..4d7c7f8 100644
--- a/drivers/staging/unisys/uislib/uislib.c
+++ b/drivers/staging/unisys/uislib/uislib.c
@@ -148,7 +148,7 @@ init_vbus_channel(U64 channelAddr, U32 channelBytes, int isServer)
 			rc = NULL;
 			goto Away;
 		}
-		ultra_vbus_init_channel(pChan, channelBytes);
+		ultra_vbus_init_channel_io(pChan, channelBytes);
 	} else {
 		if (!ULTRA_VBUS_CHANNEL_OK_CLIENT(pChan, NULL)) {
 			ERRDRV("%s channel cannot be used", __func__);
-- 
1.8.5.3



More information about the devel mailing list