staging: unisys: refactor ULTRA_check_channel_client()
authorBenjamin Romer <benjamin.romer@unisys.com>
Thu, 23 Oct 2014 18:30:05 +0000 (14:30 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Oct 2014 02:33:09 +0000 (10:33 +0800)
Rename the function ULTRA_check_channel_client() to
spar_check_channel_client(), and fix CamelCase parameter names:

pChannel => ch
expectedTypeGuid => expected_uuid
channelName => chname
expectedMinBytes => expected_min_bytes
expectedVersionId => expected_version
expectedSignature => expected_signature

Rename macros that use spar_check_channel_client:

ULTRA_CONTROLVM_CHANNEL_OK_CLIENT => SPAR_CONTROLVM_CHANNEL_OK_CLIENT
ULTRA_VHBA_CHANNEL_OK_CLIENT => SPAR_VHBA_CHANNEL_OK_CLIENT
ULTRA_VNIC_CHANNEL_OK_CLIENT => SPAR_VNIC_CHANNEL_OK_CLIENT
ULTRA_VSWITCH_CHANNEL_OK_CLIENT => SPAR_VSWITCH_CHANNEL_OK_CLIENT
ULTRA_VBUS_CHANNEL_OK_CLIENT => SPAR_VBUS_CHANNEL_OK_CLIENT

Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/channels/channel.c
drivers/staging/unisys/channels/chanstub.c
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
drivers/staging/unisys/uislib/uislib.c
drivers/staging/unisys/uislib/uisqueue.c
drivers/staging/unisys/visorchipset/visorchipset_main.c

index 0a98c5c67ff9cc5776a03def6943191a864be7f0..4737b77476e18c4e170bef1d1da3beb1a612c48f 100644 (file)
  * Return value:
  * 1 if the insertion succeeds, 0 if the queue was full.
  */
-unsigned char
-visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue,
-                   void *pSignal)
+unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue,
+                                void *sig)
 {
        void __iomem *psignal;
        unsigned int head, tail, nof;
 
        struct signal_queue_header __iomem *pqhdr =
            (struct signal_queue_header __iomem *)
-               ((char __iomem *) pChannel + readq(&pChannel->ch_space_offset))
-               + Queue;
+               ((char __iomem *) ch + readq(&ch->ch_space_offset))
+               + queue;
 
        /* capture current head and tail */
        head = readl(&pqhdr->head);
@@ -74,7 +73,7 @@ visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue,
         */
        psignal = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) +
                (head * readl(&pqhdr->signal_size));
-       memcpy_toio(psignal, pSignal, readl(&pqhdr->signal_size));
+       memcpy_toio(psignal, sig, readl(&pqhdr->signal_size));
 
        mb(); /* channel synch */
        writel(head, &pqhdr->head);
@@ -82,7 +81,7 @@ visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue,
        writeq(readq(&pqhdr->num_sent) + 1, &pqhdr->num_sent);
        return 1;
 }
-EXPORT_SYMBOL_GPL(visor_signal_insert);
+EXPORT_SYMBOL_GPL(spar_signal_insert);
 
 /*
  * Routine Description:
index 23d5aafef2cd7718770ae61d3d857b62713c4469..fae9ab3d0f608536c3ba65dbd67418507b1465ed 100644 (file)
@@ -49,7 +49,7 @@ SignalInsert_withLock(struct channel_header __iomem *pChannel, u32 Queue,
        unsigned long flags;
 
        spin_lock_irqsave(lock, flags);
-       result = visor_signal_insert(pChannel, Queue, pSignal);
+       result = spar_signal_insert(pChannel, Queue, pSignal);
        spin_unlock_irqrestore(lock, flags);
        return result;
 }
index c01c2e69379d09c7410a09f320bf5f3b270b5237..16dd7a3394331ce6b92c2cf996b1aca3ff88a75c 100644 (file)
@@ -289,89 +289,65 @@ struct signal_queue_header {
  * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
  */
 static inline int
-ULTRA_check_channel_client(void __iomem *pChannel,
-                          uuid_le expectedTypeGuid,
-                          char *channelName,
-                          u64 expectedMinBytes,
-                          u32 expectedVersionId,
-                          u64 expectedSignature,
-                          char *fileName, int lineNumber, void *logCtx)
+spar_check_channel_client(void __iomem *ch,
+                         uuid_le expected_uuid,
+                         char *chname,
+                         u64 expected_min_bytes,
+                         u32 expected_version,
+                         u64 expected_signature)
 {
-       if (uuid_le_cmp(expectedTypeGuid, NULL_UUID_LE) != 0) {
+       if (uuid_le_cmp(expected_uuid, NULL_UUID_LE) != 0) {
                uuid_le guid;
 
                memcpy_fromio(&guid,
-                       &((struct channel_header __iomem *)(pChannel))->chtype,
-                       sizeof(guid));
+                             &((struct channel_header __iomem *)(ch))->chtype,
+                             sizeof(guid));
                /* caller wants us to verify type GUID */
-               if (uuid_le_cmp(guid, expectedTypeGuid) != 0) {
+               if (uuid_le_cmp(guid, expected_uuid) != 0) {
                        pr_err("Channel mismatch on channel=%s(%pUL) field=type expected=%pUL actual=%pUL\n",
-                              channelName, &expectedTypeGuid,
-                              &expectedTypeGuid, &guid);
+                              chname, &expected_uuid,
+                              &expected_uuid, &guid);
                        return 0;
                }
        }
-       if (expectedMinBytes > 0) {     /* caller wants us to verify
+       if (expected_min_bytes > 0) {   /* caller wants us to verify
                                         * channel size */
                unsigned long long bytes =
                                readq(&((struct channel_header __iomem *)
-                                       (pChannel))->size);
-               if (bytes < expectedMinBytes) {
+                                       (ch))->size);
+               if (bytes < expected_min_bytes) {
                        pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8Lx actual=0x%-8.8Lx\n",
-                              channelName, &expectedTypeGuid,
-                              (unsigned long long)expectedMinBytes, bytes);
+                              chname, &expected_uuid,
+                              (unsigned long long)expected_min_bytes, bytes);
                        return 0;
                }
        }
-       if (expectedVersionId > 0) {    /* caller wants us to verify
+       if (expected_version > 0) {     /* caller wants us to verify
                                         * channel version */
                unsigned long ver = readl(&((struct channel_header __iomem *)
-                                   (pChannel))->version_id);
-               if (ver != expectedVersionId) {
+                                   (ch))->version_id);
+               if (ver != expected_version) {
                        pr_err("Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8lx\n",
-                              channelName, &expectedTypeGuid,
-                              (unsigned long)expectedVersionId, ver);
+                              chname, &expected_uuid,
+                              (unsigned long)expected_version, ver);
                        return 0;
                }
        }
-       if (expectedSignature > 0) {    /* caller wants us to verify
+       if (expected_signature > 0) {   /* caller wants us to verify
                                         * channel signature */
                unsigned long long sig =
                                readq(&((struct channel_header __iomem *)
-                                       (pChannel))->signature);
-               if (sig != expectedSignature) {
+                                       (ch))->signature);
+               if (sig != expected_signature) {
                        pr_err("Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8llx actual=0x%-8.8llx\n",
-                              channelName, &expectedTypeGuid,
-                              expectedSignature, sig);
+                              chname, &expected_uuid,
+                              expected_signature, sig);
                        return 0;
                }
        }
        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
-ULTRA_check_channel_server(uuid_le typeGuid,
-                          char *channelName,
-                          u64 expectedMinBytes,
-                          u64 actualBytes,
-                          char *fileName, int lineNumber, void *logCtx)
-{
-       if (expectedMinBytes > 0)       /* caller wants us to verify
-                                        * channel size */
-               if (actualBytes < expectedMinBytes) {
-                       pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8llx actual=0x%-8.8llx\n",
-                              channelName, &typeGuid, expectedMinBytes,
-                              actualBytes);
-                       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
@@ -530,8 +506,8 @@ spar_channel_client_release_os(void __iomem *ch, u8 *id)
 * full.
 */
 
-unsigned char visor_signal_insert(struct channel_header __iomem *pChannel,
-                                 u32 Queue, void *pSignal);
+unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue,
+                                void *sig);
 
 /*
 * Routine Description:
index 91e75f4d3e21cb3e303f51528d71867ae4829661..9a7531f66fdb916def6cb7b8ed3fbb2dc3647dd8 100644 (file)
@@ -45,19 +45,13 @@ static const uuid_le UltraControlvmChannelProtocolGuid =
 * channel struct withOUT needing to increment this. */
 #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID  1
 
-#define ULTRA_CONTROLVM_CHANNEL_OK_CLIENT(pChannel, logCtx)           \
-       (ULTRA_check_channel_client(pChannel, \
-               UltraControlvmChannelProtocolGuid, \
-               "controlvm", \
-               sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \
-               ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
-               ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE, \
-               __FILE__, __LINE__, logCtx))
-#define ULTRA_CONTROLVM_CHANNEL_OK_SERVER(actualBytes, logCtx)        \
-       (ULTRA_check_channel_server(UltraControlvmChannelProtocolGuid,  \
-                                   "controlvm",                        \
-                                   sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \
-                                   actualBytes, __FILE__, __LINE__, logCtx))
+#define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(pChannel)           \
+       (spar_check_channel_client(pChannel, \
+                                  UltraControlvmChannelProtocolGuid, \
+                                  "controlvm", \
+                                  sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \
+                                  ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
+                                  ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE))
 
 #define MY_DEVICE_INDEX 0
 #define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */
index 919f628360c2c01aa926c2b5b11918eea6c1b17a..97451bab64d2bc0b7fa71ddfaa3552cc1a4ae0e1 100644 (file)
@@ -59,13 +59,12 @@ static const uuid_le UltraDiagChannelProtocolGuid =
 #define ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID 2
 
 #define ULTRA_DIAG_CHANNEL_OK_CLIENT(pChannel, logCtx)                 \
-       (ULTRA_check_channel_client(pChannel,                           \
+       (spar_check_channel_client(pChannel,                            \
                                    UltraDiagChannelProtocolGuid,       \
                                    "diag",                             \
                                    sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \
                                    ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID, \
-                                   ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE, \
-                                   __FILE__, __LINE__, logCtx))
+                                   ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE))
 #define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes, logCtx)              \
        (ULTRA_check_channel_server(UltraDiagChannelProtocolGuid,       \
                                    "diag",                             \
index d487cb2f06aafd8e0837d3710ca4162f1577ea49..f5fd542bb67fd0abd1980372aa00986d1731d1b9 100644 (file)
 #define ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID 2
 #define ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID 1
 
-#define ULTRA_VHBA_CHANNEL_OK_CLIENT(pChannel, logCtx)                 \
-       (ULTRA_check_channel_client(pChannel, spar_vhba_channel_protocol_uuid, \
-                                   "vhba", MIN_IO_CHANNEL_SIZE,        \
-                                   ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \
-                                   ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE, \
-                                   __FILE__, __LINE__, logCtx))
-#define ULTRA_VHBA_CHANNEL_OK_SERVER(actualBytes, logCtx)              \
-       (ULTRA_check_channel_server(spar_vhba_channel_protocol_uuid,    \
-                                   "vhba", MIN_IO_CHANNEL_SIZE, actualBytes, \
-                                   __FILE__, __LINE__, logCtx))
-#define ULTRA_VNIC_CHANNEL_OK_CLIENT(pChannel, logCtx)                 \
-       (ULTRA_check_channel_client(pChannel, spar_vnic_channel_protocol_uuid, \
-                                   "vnic", MIN_IO_CHANNEL_SIZE,        \
-                                   ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \
-                                   ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE, \
-                                   __FILE__, __LINE__, logCtx))
-#define ULTRA_VNIC_CHANNEL_OK_SERVER(actualBytes, logCtx)              \
-       (ULTRA_check_channel_server(spar_vnic_channel_protocol_uuid,    \
-                                   "vnic", MIN_IO_CHANNEL_SIZE, actualBytes, \
-                                   __FILE__, __LINE__, logCtx))
-#define ULTRA_VSWITCH_CHANNEL_OK_CLIENT(pChannel, logCtx)              \
-       (ULTRA_check_channel_client(pChannel, UltraVswitchChannelProtocolGuid, \
-                                   "vswitch", MIN_IO_CHANNEL_SIZE,     \
-                                   ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID, \
-                                   ULTRA_VSWITCH_CHANNEL_PROTOCOL_SIGNATURE, \
-                                   __FILE__, __LINE__, logCtx))
-#define ULTRA_VSWITCH_CHANNEL_OK_SERVER(actualBytes, logCtx)          \
-       (ULTRA_check_channel_server(UltraVswitchChannelProtocolGuid,    \
-                                   "vswitch", MIN_IO_CHANNEL_SIZE,     \
-                                   actualBytes,                    \
-                                   __FILE__, __LINE__, logCtx))
+#define SPAR_VHBA_CHANNEL_OK_CLIENT(pChannel, logCtx)                  \
+       (spar_check_channel_client(pChannel, spar_vhba_channel_protocol_uuid, \
+                                  "vhba", MIN_IO_CHANNEL_SIZE, \
+                                  ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \
+                                  ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE))
+#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 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))
+
 /*
 * Everything necessary to handle SCSI & NIC traffic between Guest Partition and
 * IO Partition is defined below.  */
index 76bc7140d5e7dc42b4fd4a028588d39dcbcc3c9f..7b32aa9fb90b794ddc828c5633e6e9843e043cf2 100644 (file)
@@ -43,22 +43,13 @@ static const uuid_le UltraVbusChannelProtocolGuid =
 * increment this. */
 #define ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID 1
 
-#define ULTRA_VBUS_CHANNEL_OK_CLIENT(pChannel, logCtx)       \
-       (ULTRA_check_channel_client(pChannel,                           \
-                                   UltraVbusChannelProtocolGuid,       \
-                                   "vbus",                             \
-                                   sizeof(struct ultra_vbus_channel_protocol),\
+#define SPAR_VBUS_CHANNEL_OK_CLIENT(pChannel, logCtx)       \
+       (spar_check_channel_client(pChannel,                            \
+                                  UltraVbusChannelProtocolGuid,        \
+                                  "vbus",                              \
+                                  sizeof(struct ultra_vbus_channel_protocol),\
                                    ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID, \
-                                   ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE, \
-                                   __FILE__, __LINE__, logCtx))
-
-#define ULTRA_VBUS_CHANNEL_OK_SERVER(actualBytes, logCtx)    \
-       (ULTRA_check_channel_server(UltraVbusChannelProtocolGuid,       \
-                                   "vbus",                             \
-                                   sizeof(struct ultra_vbus_channel_protocol),\
-                                   actualBytes,                        \
-                                   __FILE__, __LINE__, logCtx))
-
+                                   ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE)) \
 
 #pragma pack(push, 1)          /* both GCC and VC now allow this pragma */
 typedef struct _ULTRA_VBUS_HEADERINFO {
index 687b7db94fe5f5d53ed5241556d8efbf3a2f684e..bcb80ba40160a0d2fd82848e1b8f934df1f2e898 100644 (file)
@@ -142,7 +142,7 @@ init_vbus_channel(u64 channelAddr, u32 channelBytes)
                rc = NULL;
                goto Away;
        }
-       if (!ULTRA_VBUS_CHANNEL_OK_CLIENT(pChan, NULL)) {
+       if (!SPAR_VBUS_CHANNEL_OK_CLIENT(pChan, NULL)) {
                ERRDRV("%s channel cannot be used", __func__);
                uislib_iounmap(pChan);
                rc = NULL;
@@ -449,7 +449,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf)
                                                        __iomem *) (dev->
                                                                  chanptr))->
                                                            chtype);
-                                       if (!ULTRA_VHBA_CHANNEL_OK_CLIENT
+                                       if (!SPAR_VHBA_CHANNEL_OK_CLIENT
                                            (dev->chanptr, NULL)) {
                                                LOGERR("CONTROLVM_DEVICE_CREATE Failed:[CLIENT]VHBA dev %d chan invalid.",
                                                     devNo);
@@ -475,7 +475,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf)
                                                        __iomem *) (dev->
                                                                  chanptr))->
                                                            chtype);
-                                       if (!ULTRA_VNIC_CHANNEL_OK_CLIENT
+                                       if (!SPAR_VNIC_CHANNEL_OK_CLIENT
                                            (dev->chanptr, NULL)) {
                                                LOGERR("CONTROLVM_DEVICE_CREATE Failed: VNIC[CLIENT] dev %d chan invalid.",
                                                     devNo);
index b9694a6d40c11167671a508c6cd4ec7d9a1872bc..66da828ca35233cb9cdafb4c84ec2c82ff087c2a 100644 (file)
@@ -83,7 +83,7 @@ do_locked_client_insert(struct uisqueue_info *queueinfo,
        spin_lock_irqsave(lock, flags);
        if (!spar_channel_client_acquire_os(queueinfo->chan, channelId))
                goto unlock;
-       if (visor_signal_insert(queueinfo->chan, whichqueue, pSignal)) {
+       if (spar_signal_insert(queueinfo->chan, whichqueue, pSignal)) {
                queueinfo->packets_sent++;
                rc = 1;
        }
index e26db99c4d5876e5091a44c63cba90e947cdb077..c94d65518f46415a351cd95e3dcff8c46f682e69 100644 (file)
@@ -2382,9 +2382,8 @@ visorchipset_init(void)
                    (addr,
                     sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL),
                     UltraControlvmChannelProtocolGuid);
-               if (ULTRA_CONTROLVM_CHANNEL_OK_CLIENT
-                        (visorchannel_get_header(ControlVm_channel),
-                         NULL)) {
+               if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
+                               visorchannel_get_header(ControlVm_channel))) {
                        LOGINF("Channel %s (ControlVm) discovered",
                               visorchannel_id(ControlVm_channel, s));
                        initialize_controlvm_payload();