Commit 81e4c97e authored by Benjamin Romer's avatar Benjamin Romer Committed by Greg Kroah-Hartman

staging: unisys: simplify destroy_bus() in uislib.c

The destroy_bus() function is heavily indented and many lines extend past the
right margin. This patch simplifies the function without changing its effects.
Signed-off-by: default avatarBenjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ddc9f84b
......@@ -276,17 +276,29 @@ destroy_bus(CONTROLVM_MESSAGE *msg, char *buf)
{
int i;
struct bus_info *bus, *prev = NULL;
struct guest_msgs cmd;
u32 busNo;
busNo = msg->cmd.destroyBus.busNo;
/* find and delete the bus */
read_lock(&BusListLock);
for (bus = BusListHead; bus; prev = bus, bus = bus->next) {
if (bus->busNo == busNo) {
/* found the bus - ensure that all device
* slots are NULL
*/
bus = BusListHead;
while (bus) {
if (bus->busNo == busNo)
break;
prev = bus;
bus = bus->next;
}
if (!bus) {
LOGERR("CONTROLVM_BUS_DESTROY Failed: failed to find bus %d.\n",
busNo);
read_unlock(&BusListLock);
return CONTROLVM_RESP_ERROR_ALREADY_DONE;
}
/* verify that this bus has no devices. */
for (i = 0; i < bus->deviceCount; i++) {
if (bus->device[i] != NULL) {
LOGERR("CONTROLVM_BUS_DESTROY Failed: device %i attached to bus %d.",
......@@ -296,12 +308,12 @@ destroy_bus(CONTROLVM_MESSAGE *msg, char *buf)
}
}
read_unlock(&BusListLock);
/* the msg is bound for virtpci; send
* guest_msgs struct to callback
*/
if (!msg->hdr.Flags.server) {
struct guest_msgs cmd;
if (msg->hdr.Flags.server)
goto remove;
/* client messages require us to call the virtpci callback associated
with this bus. */
cmd.msgtype = GUEST_DEL_VBUS;
cmd.del_vbus.busNo = busNo;
if (!VirtControlChanFunc) {
......@@ -312,8 +324,9 @@ destroy_bus(CONTROLVM_MESSAGE *msg, char *buf)
LOGERR("CONTROLVM_BUS_DESTROY Failed: virtpci GUEST_DEL_VBUS returned error.");
return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
}
}
/* remove the bus from the list */
/* finally, remove the bus from the list */
remove:
write_lock(&BusListLock);
if (prev) /* not at head */
prev->next = bus->next;
......@@ -321,16 +334,7 @@ destroy_bus(CONTROLVM_MESSAGE *msg, char *buf)
BusListHead = bus->next;
BusListCount--;
write_unlock(&BusListLock);
break;
}
}
if (!bus) {
LOGERR("CONTROLVM_BUS_DESTROY Failed: failed to find bus %d.\n",
busNo);
read_unlock(&BusListLock);
return CONTROLVM_RESP_ERROR_ALREADY_DONE;
}
if (bus->pBusChannel) {
uislib_iounmap(bus->pBusChannel);
bus->pBusChannel = NULL;
......
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