Commit 4c0e65f8 authored by David Kershner's avatar David Kershner Committed by Greg Kroah-Hartman

staging: unisys: visorbus: combine response functions into a single one

There are several different controlvm response functions, consolidate them
to one so we can simplify error handling.
Signed-off-by: default avatarDavid Kershner <david.kershner@unisys.com>
Reviewed-by: default avatarTim Sell <timothy.sell@unisys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0743ce59
...@@ -441,7 +441,8 @@ chipset_init(struct controlvm_message *inmsg) ...@@ -441,7 +441,8 @@ chipset_init(struct controlvm_message *inmsg)
} }
static int static int
controlvm_respond(struct controlvm_message_header *msg_hdr, int response) controlvm_respond(struct controlvm_message_header *msg_hdr, int response,
struct spar_segment_state *state)
{ {
struct controlvm_message outmsg; struct controlvm_message outmsg;
...@@ -449,19 +450,11 @@ controlvm_respond(struct controlvm_message_header *msg_hdr, int response) ...@@ -449,19 +450,11 @@ controlvm_respond(struct controlvm_message_header *msg_hdr, int response)
if (outmsg.hdr.flags.test_message == 1) if (outmsg.hdr.flags.test_message == 1)
return -EINVAL; return -EINVAL;
return visorchannel_signalinsert(chipset_dev->controlvm_channel, if (state) {
CONTROLVM_QUEUE_REQUEST, &outmsg); outmsg.cmd.device_change_state.state = *state;
} outmsg.cmd.device_change_state.flags.phys_device = 1;
}
static int controlvm_respond_physdev_changestate(
struct controlvm_message_header *msg_hdr, int response,
struct spar_segment_state state)
{
struct controlvm_message outmsg;
controlvm_init_response(&outmsg, msg_hdr, response);
outmsg.cmd.device_change_state.state = state;
outmsg.cmd.device_change_state.flags.phys_device = 1;
return visorchannel_signalinsert(chipset_dev->controlvm_channel, return visorchannel_signalinsert(chipset_dev->controlvm_channel,
CONTROLVM_QUEUE_REQUEST, &outmsg); CONTROLVM_QUEUE_REQUEST, &outmsg);
} }
...@@ -547,7 +540,7 @@ controlvm_responder(enum controlvm_id cmd_id, ...@@ -547,7 +540,7 @@ controlvm_responder(enum controlvm_id cmd_id,
if (pending_msg_hdr->id != (u32)cmd_id) if (pending_msg_hdr->id != (u32)cmd_id)
return -EINVAL; return -EINVAL;
return controlvm_respond(pending_msg_hdr, response); return controlvm_respond(pending_msg_hdr, response, NULL);
} }
static int static int
...@@ -1096,9 +1089,9 @@ parahotplug_request_complete(int id, u16 active) ...@@ -1096,9 +1089,9 @@ parahotplug_request_complete(int id, u16 active)
spin_unlock(&parahotplug_request_list_lock); spin_unlock(&parahotplug_request_list_lock);
req->msg.cmd.device_change_state.state.active = active; req->msg.cmd.device_change_state.state.active = active;
if (req->msg.hdr.flags.response_expected) if (req->msg.hdr.flags.response_expected)
controlvm_respond_physdev_changestate( controlvm_respond(
&req->msg.hdr, CONTROLVM_RESP_SUCCESS, &req->msg.hdr, CONTROLVM_RESP_SUCCESS,
req->msg.cmd.device_change_state.state); &req->msg.cmd.device_change_state.state);
parahotplug_request_destroy(req); parahotplug_request_destroy(req);
return 0; return 0;
} }
...@@ -1259,10 +1252,8 @@ parahotplug_process_message(struct controlvm_message *inmsg) ...@@ -1259,10 +1252,8 @@ parahotplug_process_message(struct controlvm_message *inmsg)
err = parahotplug_request_kickoff(req); err = parahotplug_request_kickoff(req);
if (err) if (err)
goto err_respond; goto err_respond;
controlvm_respond_physdev_changestate controlvm_respond(&inmsg->hdr, CONTROLVM_RESP_SUCCESS,
(&inmsg->hdr, &inmsg->cmd.device_change_state.state);
CONTROLVM_RESP_SUCCESS,
inmsg->cmd.device_change_state.state);
parahotplug_request_destroy(req); parahotplug_request_destroy(req);
return 0; return 0;
} }
...@@ -1283,9 +1274,8 @@ parahotplug_process_message(struct controlvm_message *inmsg) ...@@ -1283,9 +1274,8 @@ parahotplug_process_message(struct controlvm_message *inmsg)
return 0; return 0;
err_respond: err_respond:
controlvm_respond_physdev_changestate controlvm_respond(&inmsg->hdr, err,
(&inmsg->hdr, err, &inmsg->cmd.device_change_state.state);
inmsg->cmd.device_change_state.state);
return err; return err;
} }
...@@ -1305,7 +1295,7 @@ chipset_ready_uevent(struct controlvm_message_header *msg_hdr) ...@@ -1305,7 +1295,7 @@ chipset_ready_uevent(struct controlvm_message_header *msg_hdr)
KOBJ_ONLINE); KOBJ_ONLINE);
if (msg_hdr->flags.response_expected) if (msg_hdr->flags.response_expected)
controlvm_respond(msg_hdr, res); controlvm_respond(msg_hdr, res, NULL);
return res; return res;
} }
...@@ -1329,7 +1319,7 @@ chipset_selftest_uevent(struct controlvm_message_header *msg_hdr) ...@@ -1329,7 +1319,7 @@ chipset_selftest_uevent(struct controlvm_message_header *msg_hdr)
KOBJ_CHANGE, envp); KOBJ_CHANGE, envp);
if (msg_hdr->flags.response_expected) if (msg_hdr->flags.response_expected)
controlvm_respond(msg_hdr, res); controlvm_respond(msg_hdr, res, NULL);
return res; return res;
} }
...@@ -1349,7 +1339,7 @@ chipset_notready_uevent(struct controlvm_message_header *msg_hdr) ...@@ -1349,7 +1339,7 @@ chipset_notready_uevent(struct controlvm_message_header *msg_hdr)
res = kobject_uevent(&chipset_dev->acpi_device->dev.kobj, res = kobject_uevent(&chipset_dev->acpi_device->dev.kobj,
KOBJ_OFFLINE); KOBJ_OFFLINE);
if (msg_hdr->flags.response_expected) if (msg_hdr->flags.response_expected)
controlvm_respond(msg_hdr, res); controlvm_respond(msg_hdr, res, NULL);
return res; return res;
} }
...@@ -1715,7 +1705,8 @@ handle_command(struct controlvm_message inmsg, u64 channel_addr) ...@@ -1715,7 +1705,8 @@ handle_command(struct controlvm_message inmsg, u64 channel_addr)
case CONTROLVM_DEVICE_CONFIGURE: case CONTROLVM_DEVICE_CONFIGURE:
/* no op just send a respond that we passed */ /* no op just send a respond that we passed */
if (inmsg.hdr.flags.response_expected) if (inmsg.hdr.flags.response_expected)
controlvm_respond(&inmsg.hdr, CONTROLVM_RESP_SUCCESS); controlvm_respond(&inmsg.hdr, CONTROLVM_RESP_SUCCESS,
NULL);
break; break;
case CONTROLVM_CHIPSET_READY: case CONTROLVM_CHIPSET_READY:
err = chipset_ready_uevent(&inmsg.hdr); err = chipset_ready_uevent(&inmsg.hdr);
...@@ -1730,7 +1721,7 @@ handle_command(struct controlvm_message inmsg, u64 channel_addr) ...@@ -1730,7 +1721,7 @@ handle_command(struct controlvm_message inmsg, u64 channel_addr)
err = -ENOMSG; err = -ENOMSG;
if (inmsg.hdr.flags.response_expected) if (inmsg.hdr.flags.response_expected)
controlvm_respond(&inmsg.hdr, controlvm_respond(&inmsg.hdr,
-CONTROLVM_RESP_ID_UNKNOWN); -CONTROLVM_RESP_ID_UNKNOWN, NULL);
break; break;
} }
...@@ -1787,10 +1778,10 @@ parahotplug_process_list(void) ...@@ -1787,10 +1778,10 @@ parahotplug_process_list(void)
list_del(pos); list_del(pos);
if (req->msg.hdr.flags.response_expected) if (req->msg.hdr.flags.response_expected)
controlvm_respond_physdev_changestate( controlvm_respond(
&req->msg.hdr, &req->msg.hdr,
CONTROLVM_RESP_DEVICE_UDEV_TIMEOUT, CONTROLVM_RESP_DEVICE_UDEV_TIMEOUT,
req->msg.cmd.device_change_state.state); &req->msg.cmd.device_change_state.state);
parahotplug_request_destroy(req); parahotplug_request_destroy(req);
} }
......
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