staging: unisys: refactor ULTRA_check_channel_server()
authorBenjamin Romer <benjamin.romer@unisys.com>
Thu, 23 Oct 2014 18:30:11 +0000 (14:30 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Oct 2014 02:33:10 +0000 (10:33 +0800)
Rename spar_check_channel_server() to spar_check_channel_server(),
remove unused parameters fileName, lineNumber, and logCtx, update
references to the function and remove unused parameters in macros that
call it, and fix CamelCase names:

typeGuid => typeuuid
channelName => name
expectedMinBytes => expected_min_bytes
actualBytes => actual_bytes

Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/common-spar/include/channels/channel.h
drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
drivers/staging/unisys/common-spar/include/channels/diagchannel.h
drivers/staging/unisys/common-spar/include/channels/iochannel.h
drivers/staging/unisys/common-spar/include/channels/vbuschannel.h

index 865d9a4..6fb6e5b 100644 (file)
@@ -348,6 +348,26 @@ spar_check_channel_client(void __iomem *ch,
        return 1;
 }
 
+/* Generic function useful for validating any type of channel when it is about
+ * to be initialized by the server of the channel.
+ * Note that <logCtx> is only needed for callers in the EFI environment, and
+ * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
+ */
+static inline int spar_check_channel_server(uuid_le typeuuid, char *name,
+                                           u64 expected_min_bytes,
+                                           u64 actual_bytes)
+{
+       if (expected_min_bytes > 0)     /* caller wants us to verify
+                                        * channel size */
+               if (actual_bytes < expected_min_bytes) {
+                       pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8llx actual=0x%-8.8llx\n",
+                              name, &typeuuid, expected_min_bytes,
+                              actual_bytes);
+                       return 0;
+               }
+       return 1;
+}
+
 /* Given a file pathname <s> (with '/' or '\' separating directory nodes),
  * returns a pointer to the beginning of a node within that pathname such
  * that the number of nodes from that pointer to the end of the string is
index 9a7531f..ce601ae 100644 (file)
@@ -52,6 +52,11 @@ static const uuid_le UltraControlvmChannelProtocolGuid =
                                   sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \
                                   ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
                                   ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE))
+#define ULTRA_CONTROLVM_CHANNEL_OK_SERVER(actualBytes)        \
+       (spar_check_channel_server(UltraControlvmChannelProtocolGuid,   \
+                                   "controlvm",                        \
+                                   sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \
+                                   actualBytes))
 
 #define MY_DEVICE_INDEX 0
 #define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */
index 97451ba..4132642 100644 (file)
@@ -65,11 +65,11 @@ static const uuid_le UltraDiagChannelProtocolGuid =
                                    sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \
                                    ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID, \
                                    ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE))
-#define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes, logCtx)              \
-       (ULTRA_check_channel_server(UltraDiagChannelProtocolGuid,       \
-                                   "diag",                             \
-                                   sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \
-                                   actualBytes, __FILE__, __LINE__, logCtx))
+#define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes)              \
+       (spar_check_channel_server(UltraDiagChannelProtocolGuid,        \
+                                  "diag",                              \
+                                  sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \
+                                   actualBytes))
 #define MAX_MODULE_NAME_SIZE 128       /* Maximum length of module name... */
 #define MAX_ADDITIONAL_INFO_SIZE 256   /* Maximum length of any additional info
                                         * accompanying event... */
index f5fd542..b1f4a47 100644 (file)
                                   "vhba", MIN_IO_CHANNEL_SIZE, \
                                   ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \
                                   ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE))
+#define ULTRA_VHBA_CHANNEL_OK_SERVER(actualBytes)              \
+       (spar_check_channel_server(spar_vhba_channel_protocol_uuid,     \
+                                  "vhba", MIN_IO_CHANNEL_SIZE, actualBytes))
 #define SPAR_VNIC_CHANNEL_OK_CLIENT(pChannel, logCtx)                  \
        (spar_check_channel_client(pChannel, spar_vnic_channel_protocol_uuid, \
                                   "vnic", MIN_IO_CHANNEL_SIZE, \
                                   ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \
                                   ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE))
+#define ULTRA_VNIC_CHANNEL_OK_SERVER(actualBytes)              \
+       (spar_check_channel_server(spar_vnic_channel_protocol_uuid,     \
+                                  "vnic", MIN_IO_CHANNEL_SIZE, actualBytes))
 #define SPAR_VSWITCH_CHANNEL_OK_CLIENT(pChannel, logCtx)               \
        (spar_check_channel_client(pChannel, UltraVswitchChannelProtocolGuid, \
                                   "vswitch", MIN_IO_CHANNEL_SIZE,      \
                                   ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID, \
                                   ULTRA_VSWITCH_CHANNEL_PROTOCOL_SIGNATURE))
-
+#define ULTRA_VSWITCH_CHANNEL_OK_SERVER(actualBytes)          \
+       (spar_check_channel_server(UltraVswitchChannelProtocolGuid,     \
+                                   "vswitch", MIN_IO_CHANNEL_SIZE,     \
+                                   actualBytes))
 /*
 * Everything necessary to handle SCSI & NIC traffic between Guest Partition and
 * IO Partition is defined below.  */
index 7b32aa9..9329e28 100644 (file)
@@ -51,6 +51,12 @@ static const uuid_le UltraVbusChannelProtocolGuid =
                                    ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID, \
                                    ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE)) \
 
+#define ULTRA_VBUS_CHANNEL_OK_SERVER(actualBytes)    \
+       (spar_check_channel_server(UltraVbusChannelProtocolGuid,        \
+                                   "vbus",                             \
+                                   sizeof(struct ultra_vbus_channel_protocol),\
+                                   actualBytes))
+
 #pragma pack(push, 1)          /* both GCC and VC now allow this pragma */
 typedef struct _ULTRA_VBUS_HEADERINFO {
        u32 structBytes;        /* size of this struct in bytes */