LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v1] x86/mtrr: Convert to use match_string() helper
@ 2018-05-03 21:12 Andy Shevchenko
2018-05-13 19:23 ` Thomas Gleixner
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2018-05-03 21:12 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel
Cc: Andy Shevchenko
The new helper returns index of the matching string in an array.
We are going to use it here.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
arch/x86/kernel/cpu/mtrr/if.c | 21 ++++++++++-----------
1 file 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)
return -EINVAL;
ptr = skip_spaces(ptr + 5);
- for (i = 0; i < MTRR_NUM_TYPES; ++i) {
- if (strcmp(ptr, mtrr_strings[i]))
- continue;
- base >>= PAGE_SHIFT;
- size >>= PAGE_SHIFT;
- err = mtrr_add_page((unsigned long)base, (unsigned long)size, i, true);
- if (err < 0)
- return err;
- return len;
- }
- return -EINVAL;
+ i = match_string(mtrr_strings, MTRR_NUM_TYPES, ptr);
+ if (i < 0)
+ return i;
+
+ base >>= PAGE_SHIFT;
+ size >>= PAGE_SHIFT;
+ err = mtrr_add_page((unsigned long)base, (unsigned long)size, i, true);
+ if (err < 0)
+ return err;
+ return len;
}
static long
--
2.17.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] x86/mtrr: Convert to use match_string() helper
2018-05-03 21:12 [PATCH v1] x86/mtrr: Convert to use match_string() helper Andy Shevchenko
@ 2018-05-13 19:23 ` Thomas Gleixner
2018-05-13 20:34 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Gleixner @ 2018-05-13 19:23 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: Ingo Molnar, H. Peter Anvin, x86, linux-kernel
On Fri, 4 May 2018, Andy Shevchenko wrote:
> The new helper returns index of the matching string in an array.
new helper? match_string() is in tree for 2 years.
> We are going to use it here.
Are we going to use it ? When?
"Replace the open coded array lookup." or something like that would be more
appropriate.
Thanks,
tglx
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] x86/mtrr: Convert to use match_string() helper
2018-05-13 19:23 ` Thomas Gleixner
@ 2018-05-13 20:34 ` Andy Shevchenko
0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2018-05-13 20:34 UTC (permalink / raw)
To: Thomas Gleixner
Cc: Andy Shevchenko, Ingo Molnar, H. Peter Anvin,
maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
Linux Kernel Mailing List
On Sun, May 13, 2018 at 10:23 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Fri, 4 May 2018, Andy Shevchenko wrote:
>
>> The new helper returns index of the matching string in an array.
>
> new helper? match_string() is in tree for 2 years.
Old template.
>> We are going to use it here.
>
> Are we going to use it ? When?
>
> "Replace the open coded array lookup." or something like that would be more
> appropriate.
Will change this.
Thanks for review!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-13 20:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-03 21:12 [PATCH v1] x86/mtrr: Convert to use match_string() helper Andy Shevchenko
2018-05-13 19:23 ` Thomas Gleixner
2018-05-13 20:34 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).