From 22ad57ba5eacf2611a086379aaa18e456bf2ffbc Mon Sep 17 00:00:00 2001 From: Ken Cox Date: Wed, 19 Mar 2014 13:06:25 -0500 Subject: [PATCH] Staging: unisys: Remove RETINT macro The RETINT macro included a goto statement which is not allowed in the kernel. Signed-off-by: Ken Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/include/timskmod.h | 4 -- drivers/staging/unisys/uislib/uisqueue.c | 9 +-- .../unisys/visorchannel/visorchannel_funcs.c | 10 +-- drivers/staging/unisys/visorchipset/file.c | 33 +++++----- .../unisys/visorchipset/visorchipset_main.c | 62 ++++++++++++------- drivers/staging/unisys/visorutil/charqueue.c | 11 ++-- 6 files changed, 68 insertions(+), 61 deletions(-) diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h index 3f8e6a2fd8c7..5fd5ad514464 100644 --- a/drivers/staging/unisys/include/timskmod.h +++ b/drivers/staging/unisys/include/timskmod.h @@ -122,10 +122,6 @@ typedef long VMMIO32;/**< #VMMIO pointing to 32-bit data */ #define RETTRACE(x) #endif -/** return from an int function, using a common exit point "Away" - * @param x the value to return - */ -#define RETINT(x) do { rc = (x); RETTRACE(x); goto Away; } 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 diff --git a/drivers/staging/unisys/uislib/uisqueue.c b/drivers/staging/unisys/uislib/uisqueue.c index 91b03ed829ef..40598ff1f4f2 100644 --- a/drivers/staging/unisys/uislib/uisqueue.c +++ b/drivers/staging/unisys/uislib/uisqueue.c @@ -28,8 +28,6 @@ #define CURRENT_FILE_PC UISLIB_PC_uisqueue_c #define __MYFILE__ "uisqueue.c" -#define RETINT(x) do { rc = (x); goto Away; } while (0) - #define CHECK_CACHE_ALIGN 0 /*****************************************************/ @@ -91,13 +89,13 @@ do_locked_client_insert(struct uisqueue_info *queueinfo, locked = 1; if (!ULTRA_CHANNEL_CLIENT_ACQUIRE_OS(queueinfo->chan, channelId, NULL)) - RETINT(0); + goto Away; acquired = 1; queueWasEmpty = visor_signalqueue_empty(queueinfo->chan, whichqueue); if (!visor_signal_insert(queueinfo->chan, whichqueue, pSignal)) - RETINT(0); + goto Away; ULTRA_CHANNEL_CLIENT_RELEASE_OS(queueinfo->chan, channelId, NULL); acquired = 0; spin_unlock_irqrestore(lock, flags); @@ -105,8 +103,7 @@ do_locked_client_insert(struct uisqueue_info *queueinfo, queueinfo->packets_sent++; - RETINT(1); - + rc = 1; Away: if (acquired) { ULTRA_CHANNEL_CLIENT_RELEASE_OS(queueinfo->chan, channelId, diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c index 8a200af3f0c8..053681616ba3 100644 --- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c +++ b/drivers/staging/unisys/visorchannel/visorchannel_funcs.c @@ -250,7 +250,7 @@ visorchannel_clear(VISORCHANNEL *channel, ulong offset, U8 ch, ulong nbytes) if (buf == NULL) { ERRDRV("%s failed memory allocation", __func__); - RETINT(-1); + goto Away; } memset(buf, ch, bufsize); while (nbytes > 0) { @@ -260,12 +260,14 @@ visorchannel_clear(VISORCHANNEL *channel, ulong offset, U8 ch, ulong nbytes) thisbytes = nbytes; x = visor_memregion_write(channel->memregion, offset + written, buf, thisbytes); - if (x < 0) - RETINT(x); + if (x < 0) { + rc = x; + goto Away; + } written += thisbytes; nbytes -= thisbytes; } - RETINT(0); + rc = 0; Away: if (buf != NULL) { diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c index 839a943a52c8..e214a1153282 100644 --- a/drivers/staging/unisys/visorchipset/file.c +++ b/drivers/staging/unisys/visorchipset/file.c @@ -71,7 +71,7 @@ visorchipset_file_init(dev_t majorDev, VISORCHANNEL **pControlVm_channel) if (alloc_chrdev_region(&MajorDev, 0, 1, MYDRVNAME) < 0) { ERRDRV("Unable to allocate+register char device %s", MYDRVNAME); - RETINT(-1); + goto Away; } Registered = TRUE; INFODRV("New major number %d registered\n", MAJOR(MajorDev)); @@ -79,19 +79,18 @@ visorchipset_file_init(dev_t majorDev, VISORCHANNEL **pControlVm_channel) /* static major device number registration required */ if (register_chrdev_region(MajorDev, 1, MYDRVNAME) < 0) { ERRDRV("Unable to register char device %s", MYDRVNAME); - RETINT(-1); + goto Away; } Registered = TRUE; INFODRV("Static major number %d registered\n", MAJOR(MajorDev)); } if (cdev_add(&Cdev, MKDEV(MAJOR(MajorDev), 0), 1) < 0) { - ERRDRV("failed to create char device: (status=-1)\n"); - rc = -1; + ERRDRV("failed to create char device: (status=%d)\n", rc); goto Away; } INFODRV("Registered char device for %s (major=%d)", MYDRVNAME, MAJOR(MajorDev)); - RETINT(0); + rc = 0; Away: return rc; } @@ -119,9 +118,9 @@ visorchipset_open(struct inode *inode, struct file *file) DEBUGDRV("%s", __func__); if (minor_number != 0) - RETINT(-ENODEV); + goto Away; file->private_data = NULL; - RETINT(0); + rc = 0; Away: if (rc < 0) ERRDRV("%s minor=%d failed", __func__, minor_number); @@ -131,11 +130,8 @@ Away: static int visorchipset_release(struct inode *inode, struct file *file) { - int rc = -1; DEBUGDRV("%s", __func__); - RETINT(0); -Away: - return rc; + return 0; } static int @@ -202,25 +198,28 @@ visorchipset_ioctl(struct inode *inode, struct file *file, /* get the physical rtc offset */ vrtc_offset = Issue_VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET(); if (copy_to_user - ((void __user *)arg, &vrtc_offset, sizeof(vrtc_offset))) - RETINT(-EFAULT); + ((void __user *)arg, &vrtc_offset, sizeof(vrtc_offset))) { + rc = -EFAULT; + goto Away; + } DBGINF("insde visorchipset_ioctl, cmd=%d, vrtc_offset=%lld", cmd, vrtc_offset); break; case VMCALL_UPDATE_PHYSICAL_TIME: if (copy_from_user - (&adjustment, (void __user *)arg, sizeof(adjustment))) - RETINT(-EFAULT); + (&adjustment, (void __user *)arg, sizeof(adjustment))) { + rc = -EFAULT; + goto Away; + } DBGINF("insde visorchipset_ioctl, cmd=%d, adjustment=%lld", cmd, adjustment); rc = Issue_VMCALL_UPDATE_PHYSICAL_TIME(adjustment); break; default: LOGERR("visorchipset_ioctl received invalid command"); - RETINT(-EFAULT); + rc = -EFAULT; break; } - RETINT(rc); Away: DBGINF("exiting %d!", rc); return rc; diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c index b2355d930488..8252ca14695d 100644 --- a/drivers/staging/unisys/visorchipset/visorchipset_main.c +++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c @@ -631,7 +631,8 @@ chipset_init(CONTROLVM_MESSAGE *inmsg) POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC, POSTCODE_SEVERITY_INFO); if (chipset_inited) { LOGERR("CONTROLVM_CHIPSET_INIT Failed: Already Done."); - RETINT(-CONTROLVM_RESP_ERROR_ALREADY_DONE); + rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; + goto Away; } chipset_inited = 1; POSTCODE_LINUX_2(CHIPSET_INIT_EXIT_PC, POSTCODE_SEVERITY_INFO); @@ -1079,7 +1080,8 @@ bus_create(CONTROLVM_MESSAGE *inmsg) busNo); POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo, POSTCODE_SEVERITY_ERR); - RETINT(-CONTROLVM_RESP_ERROR_ALREADY_DONE); + rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; + goto Away; } pBusInfo = kzalloc(sizeof(VISORCHIPSET_BUS_INFO), GFP_KERNEL); if (pBusInfo == NULL) { @@ -1087,7 +1089,8 @@ bus_create(CONTROLVM_MESSAGE *inmsg) busNo); POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, busNo, POSTCODE_SEVERITY_ERR); - RETINT(-CONTROLVM_RESP_ERROR_KMALLOC_FAILED); + rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED; + goto Away; } INIT_LIST_HEAD(&pBusInfo->entry); @@ -1127,12 +1130,14 @@ bus_destroy(CONTROLVM_MESSAGE *inmsg) pBusInfo = findbus(&BusInfoList, busNo); if (!pBusInfo) { LOGERR("CONTROLVM_BUS_DESTROY Failed: bus %lu invalid", busNo); - RETINT(-CONTROLVM_RESP_ERROR_BUS_INVALID); + rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; + goto Away; } if (pBusInfo->state.created == 0) { LOGERR("CONTROLVM_BUS_DESTROY Failed: bus %lu already destroyed", busNo); - RETINT(-CONTROLVM_RESP_ERROR_ALREADY_DONE); + rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; + goto Away; } Away: @@ -1158,14 +1163,16 @@ bus_configure(CONTROLVM_MESSAGE *inmsg, PARSER_CONTEXT *parser_ctx) busNo); POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo, POSTCODE_SEVERITY_ERR); - RETINT(-CONTROLVM_RESP_ERROR_BUS_INVALID); + rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; + goto Away; } if (pBusInfo->state.created == 0) { LOGERR("CONTROLVM_BUS_CONFIGURE Failed: Invalid bus %lu - not created yet", busNo); POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo, POSTCODE_SEVERITY_ERR); - RETINT(-CONTROLVM_RESP_ERROR_BUS_INVALID); + rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; + goto Away; } /* TBD - add this check to other commands also... */ if (pBusInfo->pendingMsgHdr.Id != CONTROLVM_INVALID) { @@ -1173,7 +1180,8 @@ bus_configure(CONTROLVM_MESSAGE *inmsg, PARSER_CONTEXT *parser_ctx) busNo, (uint) pBusInfo->pendingMsgHdr.Id); POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo, POSTCODE_SEVERITY_ERR); - RETINT(-CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT); + rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT; + goto Away; } pBusInfo->partitionHandle = cmd->configureBus.guestHandle; @@ -1189,7 +1197,8 @@ bus_configure(CONTROLVM_MESSAGE *inmsg, PARSER_CONTEXT *parser_ctx) busNo); POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, busNo, POSTCODE_SEVERITY_ERR); - RETINT(-CONTROLVM_RESP_ERROR_KMALLOC_FAILED); + rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED; + goto Away; } POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, busNo, POSTCODE_SEVERITY_INFO); Away: @@ -1213,7 +1222,8 @@ my_device_create(CONTROLVM_MESSAGE *inmsg) busNo, devNo); POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, POSTCODE_SEVERITY_ERR); - RETINT(-CONTROLVM_RESP_ERROR_ALREADY_DONE); + rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; + goto Away; } pBusInfo = findbus(&BusInfoList, busNo); if (!pBusInfo) { @@ -1221,14 +1231,16 @@ my_device_create(CONTROLVM_MESSAGE *inmsg) busNo); POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, POSTCODE_SEVERITY_ERR); - RETINT(-CONTROLVM_RESP_ERROR_BUS_INVALID); + rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; + goto Away; } if (pBusInfo->state.created == 0) { LOGERR("CONTROLVM_DEVICE_CREATE Failed: Invalid bus %lu - not created yet", busNo); POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, POSTCODE_SEVERITY_ERR); - RETINT(-CONTROLVM_RESP_ERROR_BUS_INVALID); + rc = -CONTROLVM_RESP_ERROR_BUS_INVALID; + goto Away; } pDevInfo = kzalloc(sizeof(VISORCHIPSET_DEVICE_INFO), GFP_KERNEL); if (pDevInfo == NULL) { @@ -1236,7 +1248,8 @@ my_device_create(CONTROLVM_MESSAGE *inmsg) busNo, devNo); POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, devNo, busNo, POSTCODE_SEVERITY_ERR); - RETINT(-CONTROLVM_RESP_ERROR_KMALLOC_FAILED); + rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED; + goto Away; } INIT_LIST_HEAD(&pDevInfo->entry); @@ -1287,14 +1300,15 @@ my_device_changestate(CONTROLVM_MESSAGE *inmsg) busNo, devNo); POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, devNo, busNo, POSTCODE_SEVERITY_ERR); - RETINT(-CONTROLVM_RESP_ERROR_DEVICE_INVALID); + rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID; + goto Away; } if (pDevInfo->state.created == 0) { LOGERR("CONTROLVM_DEVICE_CHANGESTATE Failed: busNo=%lu, devNo=%lu invalid (not created)", busNo, devNo); POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, devNo, busNo, POSTCODE_SEVERITY_ERR); - RETINT(-CONTROLVM_RESP_ERROR_DEVICE_INVALID); + rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID; } Away: if ((rc >= CONTROLVM_RESP_SUCCESS) && pDevInfo) @@ -1317,12 +1331,13 @@ my_device_destroy(CONTROLVM_MESSAGE *inmsg) if (!pDevInfo) { LOGERR("CONTROLVM_DEVICE_DESTROY Failed: busNo=%lu, devNo=%lu invalid", busNo, devNo); - RETINT(-CONTROLVM_RESP_ERROR_DEVICE_INVALID); + rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID; + goto Away; } if (pDevInfo->state.created == 0) { LOGERR("CONTROLVM_DEVICE_DESTROY Failed: busNo=%lu, devNo=%lu already destroyed", busNo, devNo); - RETINT(-CONTROLVM_RESP_ERROR_ALREADY_DONE); + rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE; } Away: @@ -1349,19 +1364,22 @@ initialize_controlvm_payload_info(HOSTADDRESS phys_addr, U64 offset, U32 bytes, if (info == NULL) { LOGERR("HUH ? CONTROLVM_PAYLOAD_INIT Failed : Programmer check at %s:%d", __FILE__, __LINE__); - RETINT(-CONTROLVM_RESP_ERROR_PAYLOAD_INVALID); + rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID; + goto Away; } memset(info, 0, sizeof(CONTROLVM_PAYLOAD_INFO)); if ((offset == 0) || (bytes == 0)) { LOGERR("CONTROLVM_PAYLOAD_INIT Failed: RequestPayloadOffset=%llu RequestPayloadBytes=%llu!", (u64) offset, (u64) bytes); - RETINT(-CONTROLVM_RESP_ERROR_PAYLOAD_INVALID); + rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID; + goto Away; } payload = ioremap_cache(phys_addr + offset, bytes); if (payload == NULL) { LOGERR("CONTROLVM_PAYLOAD_INIT Failed: ioremap_cache %llu for %llu bytes failed", (u64) offset, (u64) bytes); - RETINT(-CONTROLVM_RESP_ERROR_IOREMAP_FAILED); + rc = -CONTROLVM_RESP_ERROR_IOREMAP_FAILED; + goto Away; } info->offset = offset; @@ -2796,10 +2814,8 @@ visorchipset_init(void) } LOGINF("visorchipset device created"); POSTCODE_LINUX_2(CHIPSET_INIT_SUCCESS_PC, POSTCODE_SEVERITY_INFO); - RETINT(0); - + rc = 0; Away: - if (rc) { LOGERR("visorchipset_init failed"); POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc, diff --git a/drivers/staging/unisys/visorutil/charqueue.c b/drivers/staging/unisys/visorutil/charqueue.c index c1375ed1c098..0ceede129e87 100644 --- a/drivers/staging/unisys/visorutil/charqueue.c +++ b/drivers/staging/unisys/visorutil/charqueue.c @@ -98,11 +98,10 @@ static int charqueue_dequeue_1(CHARQUEUE *charqueue) int charqueue_dequeue(CHARQUEUE *charqueue) { - int rc = -1; + int rc; spin_lock(&charqueue->lock); - RETINT(charqueue_dequeue_1(charqueue)); -Away: + rc = charqueue_dequeue_1(charqueue); spin_unlock(&charqueue->lock); return rc; } @@ -111,7 +110,7 @@ Away: int visor_charqueue_dequeue_n(CHARQUEUE *charqueue, unsigned char *buf, int n) { - int rc = -1, counter = 0, c; + int rc, counter = 0, c; spin_lock(&charqueue->lock); for (;;) { @@ -125,9 +124,7 @@ int visor_charqueue_dequeue_n(CHARQUEUE *charqueue, unsigned char *buf, int n) n--; counter++; } - RETINT(counter); - -Away: + rc = counter; spin_unlock(&charqueue->lock); return rc; } -- 2.20.1