aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2019-01-28 06:57:28 -0500
committerBjorn Helgaas <bhelgaas@google.com>2019-01-29 17:32:17 -0500
commit807ffb1e1eabbcdcd46494ee415317aa80ed415c (patch)
treecbfaaac0ff9e4d92fdddfaf5d7a431db263e8b22
parentbfeffd155283772bbe78c6a05dec7c0128ee500c (diff)
PCI/AER: Use match_string() helper to simplify the code
match_string() returns the array index of a matching string. Use it instead of the open-coded implementation. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r--drivers/pci/pcie/aer.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index fed29de783e0..f8fc2114ad39 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -117,7 +117,7 @@ bool pci_aer_available(void)
117 117
118static int ecrc_policy = ECRC_POLICY_DEFAULT; 118static int ecrc_policy = ECRC_POLICY_DEFAULT;
119 119
120static const char *ecrc_policy_str[] = { 120static const char * const ecrc_policy_str[] = {
121 [ECRC_POLICY_DEFAULT] = "bios", 121 [ECRC_POLICY_DEFAULT] = "bios",
122 [ECRC_POLICY_OFF] = "off", 122 [ECRC_POLICY_OFF] = "off",
123 [ECRC_POLICY_ON] = "on" 123 [ECRC_POLICY_ON] = "on"
@@ -203,11 +203,8 @@ void pcie_ecrc_get_policy(char *str)
203{ 203{
204 int i; 204 int i;
205 205
206 for (i = 0; i < ARRAY_SIZE(ecrc_policy_str); i++) 206 i = match_string(ecrc_policy_str, ARRAY_SIZE(ecrc_policy_str), str);
207 if (!strncmp(str, ecrc_policy_str[i], 207 if (i < 0)
208 strlen(ecrc_policy_str[i])))
209 break;
210 if (i >= ARRAY_SIZE(ecrc_policy_str))
211 return; 208 return;
212 209
213 ecrc_policy = i; 210 ecrc_policy = i;