ID: 290 - ipmi_sol.c needs a clean-up

ipmi_sol_payload_access() - change formatting and simplify.
This commit is contained in:
Zdenek Styblik 2013-12-17 05:05:43 +00:00
parent 2d7fe32687
commit d42890ef17

View File

@ -100,13 +100,12 @@ extern int verbose;
* ipmi_sol_payload_access * ipmi_sol_payload_access
*/ */
int int
ipmi_sol_payload_access(struct ipmi_intf * intf, ipmi_sol_payload_access(struct ipmi_intf * intf, uint8_t channel,
uint8_t channel, uint8_t userid, int enable)
uint8_t userid,
int enable)
{ {
struct ipmi_rq req; struct ipmi_rq req;
struct ipmi_rs *rsp; struct ipmi_rs *rsp;
int rc = (-1);
uint8_t data[6]; uint8_t data[6];
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
@ -116,31 +115,30 @@ ipmi_sol_payload_access(struct ipmi_intf * intf,
req.msg.data_len = 6; req.msg.data_len = 6;
memset(data, 0, 6); memset(data, 0, 6);
/* channel */
data[0] = channel & 0xf; /* channel */ data[0] = channel & 0xf;
data[1] = userid & 0x3f; /* user id */ /* user id */
if (!enable) data[1] = userid & 0x3f;
data[1] |= 0x40; /* disable */ if (!enable) {
data[2] = 0x02; /* payload 1 is SOL */ /* disable */
data[1] |= 0x40;
}
/* payload 1 is SOL */
data[2] = 0x02;
rsp = intf->sendrecv(intf, &req); rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
if (NULL != rsp) { lprintf(LOG_ERR, "Error %sabling SOL payload for user %d on channel %d",
switch (rsp->ccode) { enable ? "en" : "dis", userid, channel);
case 0x00: rc = (-1);
return 0; } else if (rsp->ccode != 0) {
default:
lprintf(LOG_ERR, "Error %sabling SOL payload for user %d on channel %d: %s", lprintf(LOG_ERR, "Error %sabling SOL payload for user %d on channel %d: %s",
enable ? "en" : "dis", userid, channel, enable ? "en" : "dis", userid, channel,
val2str(rsp->ccode, completion_code_vals)); val2str(rsp->ccode, completion_code_vals));
break; rc = (-1);
}
} else { } else {
lprintf(LOG_ERR, "Error %sabling SOL payload for user %d on channel %d", rc = 0;
enable ? "en" : "dis", userid, channel);
} }
return rc;
return -1;
} }
int int