Commit 3aa2ec58 authored by Sudip Mukherjee's avatar Sudip Mukherjee Committed by Greg Kroah-Hartman

staging: unisys: uislib: uislib.c: sparse warning of context imbalance

fixed sparse warning : context imbalance in 'destroy_device'
                        unexpected unlock
this patch will generate warning from checkpatch for
lines over 80 character , but since those are user-visible strings
so it was not modified.
Signed-off-by: default avatarSudip Mukherjee <sudip@vectorindia.org>
Tested-by: default avatarBenjamin Romer <benjamin.romer@unisys.com>
Acked-by: default avatarBenjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 635ecc5f
...@@ -685,6 +685,7 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf) ...@@ -685,6 +685,7 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf)
struct bus_info *bus; struct bus_info *bus;
struct device_info *dev; struct device_info *dev;
struct guest_msgs cmd; struct guest_msgs cmd;
int retval = CONTROLVM_RESP_SUCCESS;
busNo = msg->cmd.destroyDevice.busNo; busNo = msg->cmd.destroyDevice.busNo;
devNo = msg->cmd.destroyDevice.devNo; devNo = msg->cmd.destroyDevice.devNo;
...@@ -696,63 +697,18 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf) ...@@ -696,63 +697,18 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf)
/* make sure the device number is valid */ /* make sure the device number is valid */
if (devNo >= bus->deviceCount) { if (devNo >= bus->deviceCount) {
LOGERR("CONTROLVM_DEVICE_DESTORY Failed: device(%d) >= deviceCount(%d).", LOGERR("CONTROLVM_DEVICE_DESTORY Failed: device(%d) >= deviceCount(%d).",
devNo, bus->deviceCount); devNo, bus->deviceCount);
read_unlock(&BusListLock); retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID;
return CONTROLVM_RESP_ERROR_DEVICE_INVALID;
}
/* make sure this device exists */
dev = bus->device[devNo];
if (!dev) {
LOGERR("CONTROLVM_DEVICE_DESTROY Failed: device %d does not exist.",
devNo);
read_unlock(&BusListLock);
return CONTROLVM_RESP_ERROR_ALREADY_DONE;
}
read_unlock(&BusListLock);
/* the msg is bound for virtpci; send
* guest_msgs struct to callback
*/
if (!uuid_le_cmp(dev->channelTypeGuid,
UltraVhbaChannelProtocolGuid)) {
cmd.msgtype = GUEST_DEL_VHBA;
cmd.del_vhba.chanptr = dev->chanptr;
} else
if (!uuid_le_cmp(dev->channelTypeGuid,
UltraVnicChannelProtocolGuid)) {
cmd.msgtype = GUEST_DEL_VNIC;
cmd.del_vnic.chanptr = dev->chanptr;
} else { } else {
LOGERR("CONTROLVM_DEVICE_DESTROY Failed: unknown channelTypeGuid.\n"); /* make sure this device exists */
return dev = bus->device[devNo];
CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN; if (!dev) {
} LOGERR("CONTROLVM_DEVICE_DESTROY Failed: device %d does not exist.",
devNo);
if (!VirtControlChanFunc) { retval =
LOGERR("CONTROLVM_DEVICE_DESTORY Failed: virtpci callback not registered."); CONTROLVM_RESP_ERROR_ALREADY_DONE;
return }
CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
}
if (!VirtControlChanFunc(&cmd)) {
LOGERR("CONTROLVM_DEVICE_DESTROY Failed: virtpci GUEST_DEL_[VHBA||VNIC] returned error.");
return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
}
/* you must disable channel interrupts BEFORE you unmap the channel,
* because if you unmap first, there may still be some activity going
* on which accesses the channel and you will get a "unable to handle
* kernel paging request"
*/
if (dev->polling) {
LOGINF("calling uislib_disable_channel_interrupts");
uislib_disable_channel_interrupts(busNo, devNo);
}
/* unmap the channel memory for the device. */
if (!msg->hdr.Flags.testMessage) {
LOGINF("destroy_device, doing iounmap");
uislib_iounmap(dev->chanptr);
} }
kfree(dev);
bus->device[devNo] = NULL;
break; break;
} }
} }
...@@ -760,11 +716,54 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf) ...@@ -760,11 +716,54 @@ destroy_device(CONTROLVM_MESSAGE *msg, char *buf)
if (!bus) { if (!bus) {
LOGERR("CONTROLVM_DEVICE_DESTROY Failed: bus %d does not exist", LOGERR("CONTROLVM_DEVICE_DESTROY Failed: bus %d does not exist",
busNo); busNo);
read_unlock(&BusListLock); retval = CONTROLVM_RESP_ERROR_BUS_INVALID;
return CONTROLVM_RESP_ERROR_BUS_INVALID;
} }
read_unlock(&BusListLock);
return CONTROLVM_RESP_SUCCESS; if (retval == CONTROLVM_RESP_SUCCESS) {
/* the msg is bound for virtpci; send
* guest_msgs struct to callback
*/
if (!uuid_le_cmp(dev->channelTypeGuid,
UltraVhbaChannelProtocolGuid)) {
cmd.msgtype = GUEST_DEL_VHBA;
cmd.del_vhba.chanptr = dev->chanptr;
} else if (!uuid_le_cmp(dev->channelTypeGuid,
UltraVnicChannelProtocolGuid)) {
cmd.msgtype = GUEST_DEL_VNIC;
cmd.del_vnic.chanptr = dev->chanptr;
} else {
LOGERR("CONTROLVM_DEVICE_DESTROY Failed: unknown channelTypeGuid.\n");
return
CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN;
}
if (!VirtControlChanFunc) {
LOGERR("CONTROLVM_DEVICE_DESTORY Failed: virtpci callback not registered.");
return
CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
}
if (!VirtControlChanFunc(&cmd)) {
LOGERR("CONTROLVM_DEVICE_DESTROY Failed: virtpci GUEST_DEL_[VHBA||VNIC] returned error.");
return
CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
}
/* you must disable channel interrupts BEFORE you unmap the channel,
* because if you unmap first, there may still be some activity going
* on which accesses the channel and you will get a "unable to handle
* kernel paging request"
*/
if (dev->polling) {
LOGINF("calling uislib_disable_channel_interrupts");
uislib_disable_channel_interrupts(busNo, devNo);
}
/* unmap the channel memory for the device. */
if (!msg->hdr.Flags.testMessage) {
LOGINF("destroy_device, doing iounmap");
uislib_iounmap(dev->chanptr);
}
kfree(dev);
bus->device[devNo] = NULL;
}
return retval;
} }
static int static int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment