Staging: unisys: Remove FAIL macro
authorKen Cox <jkc@redhat.com>
Wed, 19 Mar 2014 18:06:24 +0000 (13:06 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Mar 2014 20:56:31 +0000 (13:56 -0700)
The FAIL macro ultimately includes a goto statement which is not allowed
in the kernel.

Signed-off-by: Ken Cox <jkc@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/unisys/include/timskmod.h
drivers/staging/unisys/visorchannel/visorchannel_funcs.c
drivers/staging/unisys/visorchipset/file.c
drivers/staging/unisys/visorutil/procobjecttree.c

index 1101ecd85fc61b29914e6278f79f407682023ee0..3f8e6a2fd8c74a47032a10ec288c79bd4d73c84a 100644 (file)
@@ -126,18 +126,6 @@ typedef long VMMIO32;/**< #VMMIO pointing to 32-bit data */
  *  @param x the value to return
  */
 #define RETINT(x)  do { rc = (x); RETTRACE(x); goto Away; } while (0)
-/** Given a typedef/struct/union and a member field name,
- *  return the number of bytes occupied by that field.
- *  @param TYPE     the typedef name, or "struct xx" or "union xx"
- *  @param MEMBER   the name of the member field whose size is to be determined
- *  @return         the size of the field in bytes
- */
-#define FAIL(msg, status) do {          \
-               ERRDRV("'%s'"                                         \
-                      ": error (status=%d)\n",                       \
-                      msg, status);                                  \
-               RETINT(status);                                       \
-       } while (0)
 /** Try to evaulate the provided expression, and do a RETINT(x) iff
  *  the expression evaluates to < 0.
  *  @param x the expression to try
index 99889fd2ea1eb819b7fa3e85739d37d45035882e..8a200af3f0c8c7432e051983a63ed12f84a3b09b 100644 (file)
@@ -57,8 +57,11 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channelBytes,
        void *rc = NULL;
 
        p = kmalloc(sizeof(VISORCHANNEL), GFP_KERNEL|__GFP_NORETRY);
-       if (p == NULL)
-               FAIL("allocation failed", 0);
+       if (p == NULL) {
+               ERRDRV("allocation failed: (status=0)\n");
+               rc = NULL;
+               goto Away;
+       }
        p->memregion = NULL;
        p->needs_lock = needs_lock;
        spin_lock_init(&p->insert_lock);
@@ -73,19 +76,28 @@ visorchannel_create_guts(HOSTADDRESS physaddr, ulong channelBytes,
                    visor_memregion_create_overlapped(parent->memregion,
                                                      off,
                                                      sizeof(CHANNEL_HEADER));
-       if (p->memregion == NULL)
-               FAIL("visor_memregion_create failed", 0);
+       if (p->memregion == NULL) {
+               ERRDRV("visor_memregion_create failed failed: (status=0)\n");
+               rc = NULL;
+               goto Away;
+       }
        if (visor_memregion_read(p->memregion, 0, &p->chan_hdr,
-                                sizeof(CHANNEL_HEADER)) < 0)
-               FAIL("visor_memregion_read failed", 0);
+                                sizeof(CHANNEL_HEADER)) < 0) {
+               ERRDRV("visor_memregion_read failed: (status=0)\n");
+               rc = NULL;
+               goto Away;
+       }
        if (channelBytes == 0)
                /* we had better be a CLIENT of this channel */
                channelBytes = (ulong) p->chan_hdr.Size;
        if (STRUCTSEQUAL(guid, Guid0))
                /* we had better be a CLIENT of this channel */
                guid = p->chan_hdr.Type;
-       if (visor_memregion_resize(p->memregion, channelBytes) < 0)
-               FAIL("visor_memregion_resize failed", 0);
+       if (visor_memregion_resize(p->memregion, channelBytes) < 0) {
+               ERRDRV("visor_memregion_resize failed: (status=0)\n");
+               rc = NULL;
+               goto Away;
+       }
        p->size = channelBytes;
        p->guid = guid;
 
@@ -300,8 +312,10 @@ sig_read_header(VISORCHANNEL *channel, U32 queue,
 {
        BOOL rc = FALSE;
 
-       if (channel->chan_hdr.oChannelSpace < sizeof(CHANNEL_HEADER))
-               FAIL("oChannelSpace too small", FALSE);
+       if (channel->chan_hdr.oChannelSpace < sizeof(CHANNEL_HEADER)) {
+               ERRDRV("oChannelSpace too small: (status=%d)\n", rc);
+               goto Away;
+       }
 
        /* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */
 
@@ -310,7 +324,8 @@ sig_read_header(VISORCHANNEL *channel, U32 queue,
                                 sig_hdr, sizeof(SIGNAL_QUEUE_HEADER)) < 0) {
                ERRDRV("queue=%d SIG_QUEUE_OFFSET=%d",
                       queue, (int)SIG_QUEUE_OFFSET(&channel->chan_hdr, queue));
-               FAIL("visor_memregion_read of signal queue failed", FALSE);
+               ERRDRV("visor_memregion_read of signal queue failed: (status=%d)\n", rc);
+               goto Away;
        }
        rc = TRUE;
 Away:
@@ -327,14 +342,16 @@ sig_do_data(VISORCHANNEL *channel, U32 queue,
        if (is_write) {
                if (visor_memregion_write(channel->memregion,
                                          signal_data_offset,
-                                         data, sig_hdr->SignalSize) < 0)
-                       FAIL("visor_memregion_write of signal data failed",
-                            FALSE);
+                                         data, sig_hdr->SignalSize) < 0) {
+                       ERRDRV("visor_memregion_write of signal data failed: (status=%d)\n", rc);
+                       goto Away;
+               }
        } else {
                if (visor_memregion_read(channel->memregion, signal_data_offset,
-                                        data, sig_hdr->SignalSize) < 0)
-                       FAIL("visor_memregion_read of signal data failed",
-                            FALSE);
+                                        data, sig_hdr->SignalSize) < 0) {
+                       ERRDRV("visor_memregion_read of signal data failed: (status=%d)\n", rc);
+                       goto Away;
+               }
        }
        rc = TRUE;
 Away:
@@ -395,19 +412,25 @@ visorchannel_signalremove(VISORCHANNEL *channel, U32 queue, void *msg)
                goto Away;
        }
        sig_hdr.Tail = (sig_hdr.Tail + 1) % sig_hdr.MaxSignalSlots;
-       if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.Tail, msg))
-               FAIL("sig_read_data failed", FALSE);
+       if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.Tail, msg)) {
+               ERRDRV("sig_read_data failed: (status=%d)\n", rc);
+               goto Away;
+       }
        sig_hdr.NumSignalsReceived++;
 
        /* For each data field in SIGNAL_QUEUE_HEADER that was modified,
         * update host memory.
         */
        MEMORYBARRIER;
-       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, Tail))
-               FAIL("visor_memregion_write of Tail failed", FALSE);
-       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumSignalsReceived))
-               FAIL("visor_memregion_write of NumSignalsReceived failed",
-                    FALSE);
+       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, Tail)) {
+               ERRDRV("visor_memregion_write of Tail failed: (status=%d)\n",
+                      rc);
+               goto Away;
+       }
+       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumSignalsReceived)) {
+               ERRDRV("visor_memregion_write of NumSignalsReceived failed: (status=%d)\n", rc);
+               goto Away;
+       }
        rc = TRUE;
 Away:
        if (channel->needs_lock)
@@ -434,25 +457,33 @@ visorchannel_signalinsert(VISORCHANNEL *channel, U32 queue, void *msg)
        sig_hdr.Head = ((sig_hdr.Head + 1) % sig_hdr.MaxSignalSlots);
        if (sig_hdr.Head == sig_hdr.Tail) {
                sig_hdr.NumOverflows++;
-               if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumOverflows))
-                       FAIL("visor_memregion_write of NumOverflows failed",
-                            FALSE);
+               if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumOverflows)) {
+                       ERRDRV("visor_memregion_write of NumOverflows failed: (status=%d)\n", rc);
+                       goto Away;
+               }
                rc = FALSE;
                goto Away;
        }
 
-       if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.Head, msg))
-               FAIL("sig_write_data failed", FALSE);
+       if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.Head, msg)) {
+               ERRDRV("sig_write_data failed: (status=%d)\n", rc);
+               goto Away;
+       }
        sig_hdr.NumSignalsSent++;
 
        /* For each data field in SIGNAL_QUEUE_HEADER that was modified,
         * update host memory.
         */
        MEMORYBARRIER;
-       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, Head))
-               FAIL("visor_memregion_write of Head failed", FALSE);
-       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumSignalsSent))
-               FAIL("visor_memregion_write of NumSignalsSent failed", FALSE);
+       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, Head)) {
+               ERRDRV("visor_memregion_write of Head failed: (status=%d)\n",
+                      rc);
+               goto Away;
+       }
+       if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, NumSignalsSent)) {
+               ERRDRV("visor_memregion_write of NumSignalsSent failed: (status=%d)\n", rc);
+               goto Away;
+       }
        rc = TRUE;
 Away:
        if (channel->needs_lock)
index 7e8bc98244577b730fa99561b34580ffd3d71a89..839a943a52c8ed190ad73dda614e0a1dc39f26bd 100644 (file)
@@ -84,8 +84,11 @@ visorchipset_file_init(dev_t majorDev, VISORCHANNEL **pControlVm_channel)
                Registered = TRUE;
                INFODRV("Static major number %d registered\n", MAJOR(MajorDev));
        }
-       if (cdev_add(&Cdev, MKDEV(MAJOR(MajorDev), 0), 1) < 0)
-               FAIL("failed to create char device", -1);
+       if (cdev_add(&Cdev, MKDEV(MAJOR(MajorDev), 0), 1) < 0) {
+               ERRDRV("failed to create char device: (status=-1)\n");
+               rc = -1;
+               goto Away;
+       }
        INFODRV("Registered char device for %s (major=%d)",
                MYDRVNAME, MAJOR(MajorDev));
        RETINT(0);
index 6a082b952066c09efe1ebc6bc6363bdb0976f057..67a19e1c7b0206bde456773e687682ec27540da8 100644 (file)
@@ -136,13 +136,19 @@ MYPROCTYPE *visor_proc_CreateType(struct proc_dir_entry *procDirRoot,
        MYPROCTYPE *rc = NULL, *type = NULL;
        struct proc_dir_entry *parent = NULL;
 
-       if (procDirRoot == NULL)
-               FAIL("procDirRoot cannot be NULL!", 0);
-       if (name == NULL || name[0] == NULL)
-               FAIL("name must contain at least 1 node name!", 0);
+       if (procDirRoot == NULL) {
+               ERRDRV("procDirRoot cannot be NULL!\n");
+               goto Away;
+       }
+       if (name == NULL || name[0] == NULL) {
+               ERRDRV("name must contain at least 1 node name!\n");
+               goto Away;
+       }
        type = kzalloc(sizeof(MYPROCTYPE), GFP_KERNEL | __GFP_NORETRY);
-       if (type == NULL)
-               FAIL("out of memory", 0);
+       if (type == NULL) {
+               ERRDRV("out of memory\n");
+               goto Away;
+       }
        type->name = name;
        type->propertyNames = propertyNames;
        type->nProperties = 0;
@@ -157,8 +163,10 @@ MYPROCTYPE *visor_proc_CreateType(struct proc_dir_entry *procDirRoot,
        type->procDirs = kzalloc((type->nNames + 1) *
                                 sizeof(struct proc_dir_entry *),
                                 GFP_KERNEL | __GFP_NORETRY);
-       if (type->procDirs == NULL)
-               FAIL("out of memory", 0);
+       if (type->procDirs == NULL) {
+               ERRDRV("out of memory\n");
+               goto Away;
+       }
        parent = procDirRoot;
        for (i = 0; i < type->nNames; i++) {
                type->procDirs[i] = createProcDir(type->name[i], parent);
@@ -215,11 +223,15 @@ MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type,
        MYPROCOBJECT *obj = NULL, *rc = NULL;
        int i = 0;
 
-       if (type == NULL)
-               FAIL("type cannot be NULL", 0);
+       if (type == NULL) {
+               ERRDRV("type cannot be NULL\n");
+               goto Away;
+       }
        obj = kzalloc(sizeof(MYPROCOBJECT), GFP_KERNEL | __GFP_NORETRY);
-       if (obj == NULL)
-               FAIL("out of memory", 0);
+       if (obj == NULL) {
+               ERRDRV("out of memory\n");
+               goto Away;
+       }
        obj->type = type;
        obj->context = context;
        if (name == NULL) {
@@ -230,25 +242,29 @@ MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type,
                obj->name = kmalloc(obj->namesize, GFP_KERNEL | __GFP_NORETRY);
                if (obj->name == NULL) {
                        obj->namesize = 0;
-                       FAIL("out of memory", 0);
+                       ERRDRV("out of memory\n");
+                       goto Away;
                }
                strcpy(obj->name, name);
                obj->procDir = createProcDir(obj->name, type->procDir);
                if (obj->procDir == NULL) {
-                       rc = NULL;
                        goto Away;
                }
        }
        obj->procDirPropertyContexts =
                kzalloc((type->nProperties + 1) * sizeof(PROCDIRENTRYCONTEXT),
                        GFP_KERNEL | __GFP_NORETRY);
-       if (obj->procDirPropertyContexts == NULL)
-               FAIL("out of memory", 0);
+       if (obj->procDirPropertyContexts == NULL) {
+               ERRDRV("out of memory\n");
+               goto Away;
+       }
        obj->procDirProperties =
                kzalloc((type->nProperties + 1) * sizeof(struct proc_dir_entry *),
                        GFP_KERNEL | __GFP_NORETRY);
-       if (obj->procDirProperties == NULL)
-               FAIL("out of memory", 0);
+       if (obj->procDirProperties == NULL) {
+               ERRDRV("out of memory\n");
+               goto Away;
+       }
        for (i = 0; i < type->nProperties; i++) {
                obj->procDirPropertyContexts[i].procObject = obj;
                obj->procDirPropertyContexts[i].propertyIndex = i;