Skip to content

Commit

Permalink
Staging: unisys: Remove RETINT macro
Browse files Browse the repository at this point in the history
The RETINT macro included 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>
  • Loading branch information
Ken Cox authored and Greg Kroah-Hartman committed Mar 19, 2014
1 parent 5e54c97 commit 22ad57b
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 61 deletions.
4 changes: 0 additions & 4 deletions drivers/staging/unisys/include/timskmod.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions drivers/staging/unisys/uislib/uisqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

/*****************************************************/
Expand Down Expand Up @@ -91,22 +89,21 @@ 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);
locked = 0;

queueinfo->packets_sent++;

RETINT(1);

rc = 1;
Away:
if (acquired) {
ULTRA_CHANNEL_CLIENT_RELEASE_OS(queueinfo->chan, channelId,
Expand Down
10 changes: 6 additions & 4 deletions drivers/staging/unisys/visorchannel/visorchannel_funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
33 changes: 16 additions & 17 deletions drivers/staging/unisys/visorchipset/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,26 @@ 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));
} else {
/* 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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -131,11 +130,8 @@ visorchipset_open(struct inode *inode, struct file *file)
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
Expand Down Expand Up @@ -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;
Expand Down
62 changes: 39 additions & 23 deletions drivers/staging/unisys/visorchipset/visorchipset_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1079,15 +1080,17 @@ 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) {
LOGERR("CONTROLVM_BUS_CREATE Failed: bus %lu kzalloc failed",
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);
Expand Down Expand Up @@ -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:
Expand All @@ -1158,22 +1163,25 @@ 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) {
LOGERR("CONTROLVM_BUS_CONFIGURE Failed: bus %lu MsgId=%u outstanding",
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;
Expand All @@ -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:
Expand All @@ -1213,30 +1222,34 @@ 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) {
LOGERR("CONTROLVM_DEVICE_CREATE Failed: Invalid bus %lu - out of range",
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) {
LOGERR("CONTROLVM_DEVICE_CREATE Failed: busNo=%lu, devNo=%lu kmaloc failed",
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);
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 4 additions & 7 deletions drivers/staging/unisys/visorutil/charqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -111,7 +110,7 @@ int charqueue_dequeue(CHARQUEUE *charqueue)

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 (;;) {
Expand All @@ -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;
}
Expand Down

0 comments on commit 22ad57b

Please sign in to comment.