summaryrefslogtreecommitdiff
path: root/drivers/char
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2021-04-02 20:43:30 +0300
committerCorey Minyard <cminyard@mvista.com>2021-04-02 12:53:32 -0500
commit59cdb2e7c849656a1509b8c20cab2be1743631b2 (patch)
tree92834eb554ebffd2a20497c6ddd1cdc3c459e1b2 /drivers/char
parent649a7d46d0840fc44d181cc6b3e608b46c77a86d (diff)
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Message-Id: <20210402174334.13466-7-andriy.shevchenko@linux.intel.com> Signed-off-by: Corey Minyard <cminyard@mvista.com>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/ipmi/ipmi_si.h6
-rw-r--r--drivers/char/ipmi/ipmi_si_hardcode.c23
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c3
3 files changed, 16 insertions, 16 deletions
diff --git a/drivers/char/ipmi/ipmi_si.h b/drivers/char/ipmi/ipmi_si.h
index bac0ff86e48e..9492c53eba86 100644
--- a/drivers/char/ipmi/ipmi_si.h
+++ b/drivers/char/ipmi/ipmi_si.h
@@ -18,10 +18,14 @@
#define DEFAULT_REGSPACING 1
#define DEFAULT_REGSIZE 1
+/* Numbers in this enumerator should be mapped to si_to_str[] */
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 {
IPMI_IO_ADDR_SPACE, IPMI_MEM_ADDR_SPACE
};
diff --git a/drivers/char/ipmi/ipmi_si_hardcode.c b/drivers/char/ipmi/ipmi_si_hardcode.c
index f6ece7569504..bbcf7483d569 100644
--- a/drivers/char/ipmi/ipmi_si_hardcode.c
+++ b/drivers/char/ipmi/ipmi_si_hardcode.c
@@ -80,26 +80,21 @@ static void __init ipmi_hardcode_init_one(const char *si_type_str,
enum ipmi_addr_space addr_space)
{
struct ipmi_plat_data p;
+ int t;
memset(&p, 0, sizeof(p));
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;
- } 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 {
- pr_warn("Interface type specified for interface %d, was invalid: %s\n",
- i, si_type_str);
- return;
+ 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",
+ i, si_type_str);
+ return;
+ }
+ p.type = t;
}
p.regsize = regsizes[i];
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index be41a473e3c2..d6ecf88636c4 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -70,7 +70,8 @@ enum si_intf_state {
#define IPMI_BT_INTMASK_CLEAR_IRQ_BIT 2
#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;