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 865d9a4883a3cd97548ffe20f153f96623facc16..6fb6e5b3ddaf5264ec467229b8f8f854c4959e0a 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 9a7531f66fdb916def6cb7b8ed3fbb2dc3647dd8..ce601aecee656fe77292d072913c3288c2766b99 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 97451bab64d2bc0b7fa71ddfaa3552cc1a4ae0e1..4132642aa05b0fa9b9e746a241b31a26c4eb36f3 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 f5fd542bb67fd0abd1980372aa00986d1731d1b9..b1f4a47b3d62e491ec6e0542efed53f58cc296d7 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 7b32aa9fb90b794ddc828c5633e6e9843e043cf2..9329e2838fde02560c453868258e3d5320982b5e 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 */