Hook ipmi_set_alert_enable() to _ipmi_*()

Commit hooks ipmi_set_alert_enable() to _ipmi_*() functions and is sort of
rewrite of that function with the same functionality.
This commit is contained in:
Zdenek Styblik 2015-02-03 11:47:38 +01:00
parent 5a30d18af2
commit 4725cfd6d9

View File

@ -935,75 +935,51 @@ ipmi_lan_set_password(struct ipmi_intf *intf,
return 0; return 0;
} }
/* ipmi_set_alert_enable - enable/disable PEF alerting for given channel.
*
* @channel - IPMI channel
* @enable - whether to enable/disable PEF alerting for given channel
*
* returns - 0 on success, (-1) on error.
*/
static int static int
ipmi_set_alert_enable(struct ipmi_intf * intf, uint8_t channel, uint8_t enable) ipmi_set_alert_enable(struct ipmi_intf *intf, uint8_t channel, uint8_t enable)
{ {
struct ipmi_rs * rsp; struct channel_access_t channel_access;
struct ipmi_rq req; int ccode = 0;
uint8_t rqdata[3]; memset(&channel_access, 0, sizeof(channel_access));
channel_access.channel = channel;
memset(&req, 0, sizeof(req)); ccode = _ipmi_get_channel_access(intf, &channel_access, 0);
if (eval_ccode(ccode) != 0) {
/* update non-volatile access */ lprintf(LOG_ERR,
rqdata[0] = channel; "Unable to Get Channel Access(non-volatile) for channel %d",
rqdata[1] = 0x40; channel);
return (-1);
req.msg.netfn = IPMI_NETFN_APP;
req.msg.cmd = 0x41; /* Get Channel Access ??? */
req.msg.data = rqdata;
req.msg.data_len = 2;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to Get Channel Access for channel %d", channel);
return -1;
} }
if (rsp->ccode > 0) { if (enable != 0) {
lprintf(LOG_ERR, "Get Channel Access for channel %d failed: %s", channel_access.alerting = 1;
channel, val2str(rsp->ccode, completion_code_vals)); } else {
return -1; channel_access.alerting = 0;
} }
/* non-volatile */
/* SAVE TO NVRAM */ ccode = _ipmi_set_channel_access(intf, channel_access, 1, 0);
memset(rqdata, 0, 3); if (eval_ccode(ccode) != 0) {
rqdata[0] = channel & 0xf; lprintf(LOG_ERR,
rqdata[1] = rsp->data[0]; "Unable to Set Channel Access(non-volatile) for channel %d",
if (enable != 0) channel);
rqdata[1] &= ~0x20; return (-1);
else
rqdata[1] |= 0x20;
rqdata[1] |= 0x40;
rqdata[2] = 0;
req.msg.cmd = 0x40; /* Set Channel Access ??? */
req.msg.data_len = 3;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to Set Channel Access for channel %d", channel);
return -1;
} }
if (rsp->ccode > 0) { /* volatile */
lprintf(LOG_ERR, "Set Channel Access for channel %d failed: %s", ccode = _ipmi_set_channel_access(intf, channel_access, 2, 0);
channel, val2str(rsp->ccode, completion_code_vals)); if (eval_ccode(ccode) != 0) {
return -1; lprintf(LOG_ERR,
"Unable to Set Channel Access(volatile) for channel %d",
channel);
return (-1);
} }
printf("PEF alerts for channel %d %s.\n",
/* SAVE TO CURRENT */ channel,
rqdata[1] &= 0xc0; (enable) ? "enabled" : "disabled");
rqdata[1] |= 0x80;
rsp = intf->sendrecv(intf, &req);
if (rsp == NULL) {
lprintf(LOG_ERR, "Unable to Set Channel Access for channel %d", channel);
return -1;
}
if (rsp->ccode > 0) {
lprintf(LOG_ERR, "Set Channel Access for channel %d failed: %s",
channel, val2str(rsp->ccode, completion_code_vals));
return -1;
}
return 0; return 0;
} }