Commit 59cdb2e7 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Corey Minyard

ipmi_si: Reuse si_to_str[] array in ipmi_hardcode_init_one()

Instead of making the comparison one by one, reuse si_to_str[] array
in ipmi_hardcode_init_one() in conjunction with match_string() API.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Message-Id: <20210402174334.13466-7-andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
parent 649a7d46
...@@ -18,10 +18,14 @@ ...@@ -18,10 +18,14 @@
#define DEFAULT_REGSPACING 1 #define DEFAULT_REGSPACING 1
#define DEFAULT_REGSIZE 1 #define DEFAULT_REGSIZE 1
/* Numbers in this enumerator should be mapped to si_to_str[] */
enum si_type { enum si_type {
SI_TYPE_INVALID, SI_KCS, SI_SMIC, SI_BT SI_TYPE_INVALID, SI_KCS, SI_SMIC, SI_BT, SI_TYPE_MAX
}; };
/* Array is defined in the ipmi_si_intf.c */
extern const char *const si_to_str[];
enum ipmi_addr_space { enum ipmi_addr_space {
IPMI_IO_ADDR_SPACE, IPMI_MEM_ADDR_SPACE IPMI_IO_ADDR_SPACE, IPMI_MEM_ADDR_SPACE
}; };
......
...@@ -80,27 +80,22 @@ static void __init ipmi_hardcode_init_one(const char *si_type_str, ...@@ -80,27 +80,22 @@ static void __init ipmi_hardcode_init_one(const char *si_type_str,
enum ipmi_addr_space addr_space) enum ipmi_addr_space addr_space)
{ {
struct ipmi_plat_data p; struct ipmi_plat_data p;
int t;
memset(&p, 0, sizeof(p)); memset(&p, 0, sizeof(p));
p.iftype = IPMI_PLAT_IF_SI; p.iftype = IPMI_PLAT_IF_SI;
if (!si_type_str || !*si_type_str || strcmp(si_type_str, "kcs") == 0) { if (!si_type_str || !*si_type_str) {
p.type = SI_KCS; p.type = SI_KCS;
} else if (strcmp(si_type_str, "smic") == 0) {
p.type = SI_SMIC;
} else if (strcmp(si_type_str, "bt") == 0) {
p.type = SI_BT;
} else if (strcmp(si_type_str, "invalid") == 0) {
/*
* Allow a firmware-specified interface to be
* disabled.
*/
p.type = SI_TYPE_INVALID;
} else { } else {
t = match_string(si_to_str, -1, si_type_str);
if (t < 0) {
pr_warn("Interface type specified for interface %d, was invalid: %s\n", pr_warn("Interface type specified for interface %d, was invalid: %s\n",
i, si_type_str); i, si_type_str);
return; return;
} }
p.type = t;
}
p.regsize = regsizes[i]; p.regsize = regsizes[i];
p.slave_addr = slave_addrs[i]; p.slave_addr = slave_addrs[i];
......
...@@ -70,7 +70,8 @@ enum si_intf_state { ...@@ -70,7 +70,8 @@ enum si_intf_state {
#define IPMI_BT_INTMASK_CLEAR_IRQ_BIT 2 #define IPMI_BT_INTMASK_CLEAR_IRQ_BIT 2
#define IPMI_BT_INTMASK_ENABLE_IRQ_BIT 1 #define IPMI_BT_INTMASK_ENABLE_IRQ_BIT 1
static const char * const si_to_str[] = { "invalid", "kcs", "smic", "bt" }; /* 'invalid' to allow a firmware-specified interface to be disabled */
const char *const si_to_str[] = { "invalid", "kcs", "smic", "bt", NULL };
static bool initialized; static bool initialized;
......
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