diff options
Diffstat (limited to 'drivers/char/ipmi/ipmi_msghandler.c')
-rw-r--r-- | drivers/char/ipmi/ipmi_msghandler.c | 60 |
1 files changed, 22 insertions, 38 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index c44ad18464f1..8a0e97b33cae 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -49,11 +49,17 @@ static int handle_one_recv_msg(struct ipmi_smi *intf, static bool initialized; static bool drvregistered; +/* Numbers in this enumerator should be mapped to ipmi_panic_event_str */ enum ipmi_panic_event_op { IPMI_SEND_PANIC_EVENT_NONE, IPMI_SEND_PANIC_EVENT, - IPMI_SEND_PANIC_EVENT_STRING + IPMI_SEND_PANIC_EVENT_STRING, + IPMI_SEND_PANIC_EVENT_MAX }; + +/* Indices in this array should be mapped to enum ipmi_panic_event_op */ +static const char *const ipmi_panic_event_str[] = { "none", "event", "string", NULL }; + #ifdef CONFIG_IPMI_PANIC_STRING #define IPMI_PANIC_DEFAULT IPMI_SEND_PANIC_EVENT_STRING #elif defined(CONFIG_IPMI_PANIC_EVENT) @@ -68,46 +74,27 @@ static int panic_op_write_handler(const char *val, const struct kernel_param *kp) { char valcp[16]; - char *s; - - strncpy(valcp, val, 15); - valcp[15] = '\0'; + int e; - s = strstrip(valcp); - - if (strcmp(s, "none") == 0) - ipmi_send_panic_event = IPMI_SEND_PANIC_EVENT_NONE; - else if (strcmp(s, "event") == 0) - ipmi_send_panic_event = IPMI_SEND_PANIC_EVENT; - else if (strcmp(s, "string") == 0) - ipmi_send_panic_event = IPMI_SEND_PANIC_EVENT_STRING; - else - return -EINVAL; + strscpy(valcp, val, sizeof(valcp)); + e = match_string(ipmi_panic_event_str, -1, strstrip(valcp)); + if (e < 0) + return e; + ipmi_send_panic_event = e; return 0; } static int panic_op_read_handler(char *buffer, const struct kernel_param *kp) { - switch (ipmi_send_panic_event) { - case IPMI_SEND_PANIC_EVENT_NONE: - strcpy(buffer, "none\n"); - break; - - case IPMI_SEND_PANIC_EVENT: - strcpy(buffer, "event\n"); - break; - - case IPMI_SEND_PANIC_EVENT_STRING: - strcpy(buffer, "string\n"); - break; + const char *event_str; - default: - strcpy(buffer, "???\n"); - break; - } + if (ipmi_send_panic_event >= IPMI_SEND_PANIC_EVENT_MAX) + event_str = "???"; + else + event_str = ipmi_panic_event_str[ipmi_send_panic_event]; - return strlen(buffer); + return sprintf(buffer, "%s\n", event_str); } static const struct kernel_param_ops panic_op_ops = { @@ -2447,10 +2434,8 @@ retry: wait_event(intf->waitq, bmc->dyn_id_set != 2); if (!bmc->dyn_id_set) { - if ((bmc->cc == IPMI_DEVICE_IN_FW_UPDATE_ERR - || bmc->cc == IPMI_DEVICE_IN_INIT_ERR - || bmc->cc == IPMI_NOT_IN_MY_STATE_ERR) - && ++retry_count <= GET_DEVICE_ID_MAX_RETRY) { + if (bmc->cc != IPMI_CC_NO_ERROR && + ++retry_count <= GET_DEVICE_ID_MAX_RETRY) { msleep(500); dev_warn(intf->si_dev, "BMC returned 0x%2.2x, retry get bmc device id\n", @@ -5224,7 +5209,6 @@ module_exit(cleanup_ipmi); module_init(ipmi_init_msghandler_mod); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Corey Minyard <minyard@mvista.com>"); -MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI" - " interface."); +MODULE_DESCRIPTION("Incoming and outgoing message routing for an IPMI interface."); MODULE_VERSION(IPMI_DRIVER_VERSION); MODULE_SOFTDEP("post: ipmi_devintf"); |