aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2018-05-15 13:57:59 -0400
committerIngo Molnar <mingo@kernel.org>2018-05-16 03:47:22 -0400
commit13a4db9d75ec5dbca4bd6229e149e061ef7a6bf0 (patch)
treeb5ea135939f1c519b52828fa70910c7e12a426e5
parent67b8d5c7081221efa252e111cd52532ec6d4266f (diff)
x86/mtrr: Convert to use match_string() helper
The helper returns index of the matching string in an array. Replace the open coded array lookup with match_string(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Luis R. Rodriguez <mcgrof@suse.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Toshi Kani <toshi.kani@hp.com> Link: http://lkml.kernel.org/r/20180515175759.89315-1-andriy.shevchenko@linux.intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/kernel/cpu/mtrr/if.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/arch/x86/kernel/cpu/mtrr/if.c b/arch/x86/kernel/cpu/mtrr/if.c
index 558444b23923..42b4f2f3b557 100644
--- a/arch/x86/kernel/cpu/mtrr/if.c
+++ b/arch/x86/kernel/cpu/mtrr/if.c
@@ -149,17 +149,16 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
149 return -EINVAL; 149 return -EINVAL;
150 ptr = skip_spaces(ptr + 5); 150 ptr = skip_spaces(ptr + 5);
151 151
152 for (i = 0; i < MTRR_NUM_TYPES; ++i) { 152 i = match_string(mtrr_strings, MTRR_NUM_TYPES, ptr);
153 if (strcmp(ptr, mtrr_strings[i])) 153 if (i < 0)
154 continue; 154 return i;
155 base >>= PAGE_SHIFT; 155
156 size >>= PAGE_SHIFT; 156 base >>= PAGE_SHIFT;
157 err = mtrr_add_page((unsigned long)base, (unsigned long)size, i, true); 157 size >>= PAGE_SHIFT;
158 if (err < 0) 158 err = mtrr_add_page((unsigned long)base, (unsigned long)size, i, true);
159 return err; 159 if (err < 0)
160 return len; 160 return err;
161 } 161 return len;
162 return -EINVAL;
163} 162}
164 163
165static long 164static long