diff options
author | Paul Jimenez <pj@place.org> | 2008-01-30 07:30:31 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:30:31 -0500 |
commit | 2d2ee8de5f6d26ef2942e0b449aa68d9236d5777 (patch) | |
tree | 09589fa4f7386b9bc2c0ac07aa5a272396286d35 /arch/x86 | |
parent | 3e7593966be6f6d29a15138c0c96b961d437f2f5 (diff) |
x86: mtrr use type bool [RESEND AGAIN]
This is a janitorish patch to 1) remove private TRUE/FALSE #def's in
favor of using the standard enum from linux/stddef.h and 2) switch the
variables holding those values to type 'bool' (from linux/types.h)
since it both seems more appropriate and allows for potentially better
optimization.
As a truly minor aside, I removed a couple of comments documenting
a 'do_safe' parameter that seems to no longer exist.
Signed-off-by: Paul Jimenez <pj@place.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/amd.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/generic.c | 16 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/if.c | 15 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/main.c | 8 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/mtrr/mtrr.h | 6 |
5 files changed, 22 insertions, 25 deletions
diff --git a/arch/x86/kernel/cpu/mtrr/amd.c b/arch/x86/kernel/cpu/mtrr/amd.c index 0949cdbf848a..ee2331b0e58f 100644 --- a/arch/x86/kernel/cpu/mtrr/amd.c +++ b/arch/x86/kernel/cpu/mtrr/amd.c | |||
@@ -53,8 +53,6 @@ static void amd_set_mtrr(unsigned int reg, unsigned long base, | |||
53 | <base> The base address of the region. | 53 | <base> The base address of the region. |
54 | <size> The size of the region. If this is 0 the region is disabled. | 54 | <size> The size of the region. If this is 0 the region is disabled. |
55 | <type> The type of the region. | 55 | <type> The type of the region. |
56 | <do_safe> If TRUE, do the change safely. If FALSE, safety measures should | ||
57 | be done externally. | ||
58 | [RETURNS] Nothing. | 56 | [RETURNS] Nothing. |
59 | */ | 57 | */ |
60 | { | 58 | { |
diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c index 992f08dfbb6c..1c331c373a43 100644 --- a/arch/x86/kernel/cpu/mtrr/generic.c +++ b/arch/x86/kernel/cpu/mtrr/generic.c | |||
@@ -188,7 +188,7 @@ static inline void k8_enable_fixed_iorrs(void) | |||
188 | * \param changed pointer which indicates whether the MTRR needed to be changed | 188 | * \param changed pointer which indicates whether the MTRR needed to be changed |
189 | * \param msrwords pointer to the MSR values which the MSR should have | 189 | * \param msrwords pointer to the MSR values which the MSR should have |
190 | */ | 190 | */ |
191 | static void set_fixed_range(int msr, int * changed, unsigned int * msrwords) | 191 | static void set_fixed_range(int msr, bool *changed, unsigned int *msrwords) |
192 | { | 192 | { |
193 | unsigned lo, hi; | 193 | unsigned lo, hi; |
194 | 194 | ||
@@ -200,7 +200,7 @@ static void set_fixed_range(int msr, int * changed, unsigned int * msrwords) | |||
200 | ((msrwords[0] | msrwords[1]) & K8_MTRR_RDMEM_WRMEM_MASK)) | 200 | ((msrwords[0] | msrwords[1]) & K8_MTRR_RDMEM_WRMEM_MASK)) |
201 | k8_enable_fixed_iorrs(); | 201 | k8_enable_fixed_iorrs(); |
202 | mtrr_wrmsr(msr, msrwords[0], msrwords[1]); | 202 | mtrr_wrmsr(msr, msrwords[0], msrwords[1]); |
203 | *changed = TRUE; | 203 | *changed = true; |
204 | } | 204 | } |
205 | } | 205 | } |
206 | 206 | ||
@@ -260,7 +260,7 @@ static void generic_get_mtrr(unsigned int reg, unsigned long *base, | |||
260 | static int set_fixed_ranges(mtrr_type * frs) | 260 | static int set_fixed_ranges(mtrr_type * frs) |
261 | { | 261 | { |
262 | unsigned long long *saved = (unsigned long long *) frs; | 262 | unsigned long long *saved = (unsigned long long *) frs; |
263 | int changed = FALSE; | 263 | bool changed = false; |
264 | int block=-1, range; | 264 | int block=-1, range; |
265 | 265 | ||
266 | while (fixed_range_blocks[++block].ranges) | 266 | while (fixed_range_blocks[++block].ranges) |
@@ -273,17 +273,17 @@ static int set_fixed_ranges(mtrr_type * frs) | |||
273 | 273 | ||
274 | /* Set the MSR pair relating to a var range. Returns TRUE if | 274 | /* Set the MSR pair relating to a var range. Returns TRUE if |
275 | changes are made */ | 275 | changes are made */ |
276 | static int set_mtrr_var_ranges(unsigned int index, struct mtrr_var_range *vr) | 276 | static bool set_mtrr_var_ranges(unsigned int index, struct mtrr_var_range *vr) |
277 | { | 277 | { |
278 | unsigned int lo, hi; | 278 | unsigned int lo, hi; |
279 | int changed = FALSE; | 279 | bool changed = false; |
280 | 280 | ||
281 | rdmsr(MTRRphysBase_MSR(index), lo, hi); | 281 | rdmsr(MTRRphysBase_MSR(index), lo, hi); |
282 | if ((vr->base_lo & 0xfffff0ffUL) != (lo & 0xfffff0ffUL) | 282 | if ((vr->base_lo & 0xfffff0ffUL) != (lo & 0xfffff0ffUL) |
283 | || (vr->base_hi & (size_and_mask >> (32 - PAGE_SHIFT))) != | 283 | || (vr->base_hi & (size_and_mask >> (32 - PAGE_SHIFT))) != |
284 | (hi & (size_and_mask >> (32 - PAGE_SHIFT)))) { | 284 | (hi & (size_and_mask >> (32 - PAGE_SHIFT)))) { |
285 | mtrr_wrmsr(MTRRphysBase_MSR(index), vr->base_lo, vr->base_hi); | 285 | mtrr_wrmsr(MTRRphysBase_MSR(index), vr->base_lo, vr->base_hi); |
286 | changed = TRUE; | 286 | changed = true; |
287 | } | 287 | } |
288 | 288 | ||
289 | rdmsr(MTRRphysMask_MSR(index), lo, hi); | 289 | rdmsr(MTRRphysMask_MSR(index), lo, hi); |
@@ -292,7 +292,7 @@ static int set_mtrr_var_ranges(unsigned int index, struct mtrr_var_range *vr) | |||
292 | || (vr->mask_hi & (size_and_mask >> (32 - PAGE_SHIFT))) != | 292 | || (vr->mask_hi & (size_and_mask >> (32 - PAGE_SHIFT))) != |
293 | (hi & (size_and_mask >> (32 - PAGE_SHIFT)))) { | 293 | (hi & (size_and_mask >> (32 - PAGE_SHIFT)))) { |
294 | mtrr_wrmsr(MTRRphysMask_MSR(index), vr->mask_lo, vr->mask_hi); | 294 | mtrr_wrmsr(MTRRphysMask_MSR(index), vr->mask_lo, vr->mask_hi); |
295 | changed = TRUE; | 295 | changed = true; |
296 | } | 296 | } |
297 | return changed; | 297 | return changed; |
298 | } | 298 | } |
@@ -417,8 +417,6 @@ static void generic_set_mtrr(unsigned int reg, unsigned long base, | |||
417 | <base> The base address of the region. | 417 | <base> The base address of the region. |
418 | <size> The size of the region. If this is 0 the region is disabled. | 418 | <size> The size of the region. If this is 0 the region is disabled. |
419 | <type> The type of the region. | 419 | <type> The type of the region. |
420 | <do_safe> If TRUE, do the change safely. If FALSE, safety measures should | ||
421 | be done externally. | ||
422 | [RETURNS] Nothing. | 420 | [RETURNS] Nothing. |
423 | */ | 421 | */ |
424 | { | 422 | { |
diff --git a/arch/x86/kernel/cpu/mtrr/if.c b/arch/x86/kernel/cpu/mtrr/if.c index c7d8f1756745..14535686c099 100644 --- a/arch/x86/kernel/cpu/mtrr/if.c +++ b/arch/x86/kernel/cpu/mtrr/if.c | |||
@@ -37,7 +37,7 @@ const char *mtrr_attrib_to_str(int x) | |||
37 | 37 | ||
38 | static int | 38 | static int |
39 | mtrr_file_add(unsigned long base, unsigned long size, | 39 | mtrr_file_add(unsigned long base, unsigned long size, |
40 | unsigned int type, char increment, struct file *file, int page) | 40 | unsigned int type, bool increment, struct file *file, int page) |
41 | { | 41 | { |
42 | int reg, max; | 42 | int reg, max; |
43 | unsigned int *fcount = FILE_FCOUNT(file); | 43 | unsigned int *fcount = FILE_FCOUNT(file); |
@@ -55,7 +55,7 @@ mtrr_file_add(unsigned long base, unsigned long size, | |||
55 | base >>= PAGE_SHIFT; | 55 | base >>= PAGE_SHIFT; |
56 | size >>= PAGE_SHIFT; | 56 | size >>= PAGE_SHIFT; |
57 | } | 57 | } |
58 | reg = mtrr_add_page(base, size, type, 1); | 58 | reg = mtrr_add_page(base, size, type, true); |
59 | if (reg >= 0) | 59 | if (reg >= 0) |
60 | ++fcount[reg]; | 60 | ++fcount[reg]; |
61 | return reg; | 61 | return reg; |
@@ -141,7 +141,7 @@ mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos) | |||
141 | size >>= PAGE_SHIFT; | 141 | size >>= PAGE_SHIFT; |
142 | err = | 142 | err = |
143 | mtrr_add_page((unsigned long) base, (unsigned long) size, i, | 143 | mtrr_add_page((unsigned long) base, (unsigned long) size, i, |
144 | 1); | 144 | true); |
145 | if (err < 0) | 145 | if (err < 0) |
146 | return err; | 146 | return err; |
147 | return len; | 147 | return len; |
@@ -217,7 +217,7 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg) | |||
217 | if (!capable(CAP_SYS_ADMIN)) | 217 | if (!capable(CAP_SYS_ADMIN)) |
218 | return -EPERM; | 218 | return -EPERM; |
219 | err = | 219 | err = |
220 | mtrr_file_add(sentry.base, sentry.size, sentry.type, 1, | 220 | mtrr_file_add(sentry.base, sentry.size, sentry.type, true, |
221 | file, 0); | 221 | file, 0); |
222 | break; | 222 | break; |
223 | case MTRRIOC_SET_ENTRY: | 223 | case MTRRIOC_SET_ENTRY: |
@@ -226,7 +226,7 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg) | |||
226 | #endif | 226 | #endif |
227 | if (!capable(CAP_SYS_ADMIN)) | 227 | if (!capable(CAP_SYS_ADMIN)) |
228 | return -EPERM; | 228 | return -EPERM; |
229 | err = mtrr_add(sentry.base, sentry.size, sentry.type, 0); | 229 | err = mtrr_add(sentry.base, sentry.size, sentry.type, false); |
230 | break; | 230 | break; |
231 | case MTRRIOC_DEL_ENTRY: | 231 | case MTRRIOC_DEL_ENTRY: |
232 | #ifdef CONFIG_COMPAT | 232 | #ifdef CONFIG_COMPAT |
@@ -270,7 +270,7 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg) | |||
270 | if (!capable(CAP_SYS_ADMIN)) | 270 | if (!capable(CAP_SYS_ADMIN)) |
271 | return -EPERM; | 271 | return -EPERM; |
272 | err = | 272 | err = |
273 | mtrr_file_add(sentry.base, sentry.size, sentry.type, 1, | 273 | mtrr_file_add(sentry.base, sentry.size, sentry.type, true, |
274 | file, 1); | 274 | file, 1); |
275 | break; | 275 | break; |
276 | case MTRRIOC_SET_PAGE_ENTRY: | 276 | case MTRRIOC_SET_PAGE_ENTRY: |
@@ -279,7 +279,8 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg) | |||
279 | #endif | 279 | #endif |
280 | if (!capable(CAP_SYS_ADMIN)) | 280 | if (!capable(CAP_SYS_ADMIN)) |
281 | return -EPERM; | 281 | return -EPERM; |
282 | err = mtrr_add_page(sentry.base, sentry.size, sentry.type, 0); | 282 | err = |
283 | mtrr_add_page(sentry.base, sentry.size, sentry.type, false); | ||
283 | break; | 284 | break; |
284 | case MTRRIOC_DEL_PAGE_ENTRY: | 285 | case MTRRIOC_DEL_PAGE_ENTRY: |
285 | #ifdef CONFIG_COMPAT | 286 | #ifdef CONFIG_COMPAT |
diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c index beb45c9c0835..60af5ed2b5c0 100644 --- a/arch/x86/kernel/cpu/mtrr/main.c +++ b/arch/x86/kernel/cpu/mtrr/main.c | |||
@@ -311,7 +311,7 @@ static void set_mtrr(unsigned int reg, unsigned long base, | |||
311 | */ | 311 | */ |
312 | 312 | ||
313 | int mtrr_add_page(unsigned long base, unsigned long size, | 313 | int mtrr_add_page(unsigned long base, unsigned long size, |
314 | unsigned int type, char increment) | 314 | unsigned int type, bool increment) |
315 | { | 315 | { |
316 | int i, replace, error; | 316 | int i, replace, error; |
317 | mtrr_type ltype; | 317 | mtrr_type ltype; |
@@ -394,7 +394,9 @@ int mtrr_add_page(unsigned long base, unsigned long size, | |||
394 | if (likely(replace < 0)) | 394 | if (likely(replace < 0)) |
395 | usage_table[i] = 1; | 395 | usage_table[i] = 1; |
396 | else { | 396 | else { |
397 | usage_table[i] = usage_table[replace] + !!increment; | 397 | usage_table[i] = usage_table[replace]; |
398 | if (increment) | ||
399 | usage_table[i]++; | ||
398 | if (unlikely(replace != i)) { | 400 | if (unlikely(replace != i)) { |
399 | set_mtrr(replace, 0, 0, 0); | 401 | set_mtrr(replace, 0, 0, 0); |
400 | usage_table[replace] = 0; | 402 | usage_table[replace] = 0; |
@@ -460,7 +462,7 @@ static int mtrr_check(unsigned long base, unsigned long size) | |||
460 | 462 | ||
461 | int | 463 | int |
462 | mtrr_add(unsigned long base, unsigned long size, unsigned int type, | 464 | mtrr_add(unsigned long base, unsigned long size, unsigned int type, |
463 | char increment) | 465 | bool increment) |
464 | { | 466 | { |
465 | if (mtrr_check(base, size)) | 467 | if (mtrr_check(base, size)) |
466 | return -EINVAL; | 468 | return -EINVAL; |
diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h index 289dfe6030e3..54347e9a95c0 100644 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h | |||
@@ -2,10 +2,8 @@ | |||
2 | * local mtrr defines. | 2 | * local mtrr defines. |
3 | */ | 3 | */ |
4 | 4 | ||
5 | #ifndef TRUE | 5 | #include <linux/types.h> |
6 | #define TRUE 1 | 6 | #include <linux/stddef.h> |
7 | #define FALSE 0 | ||
8 | #endif | ||
9 | 7 | ||
10 | #define MTRRcap_MSR 0x0fe | 8 | #define MTRRcap_MSR 0x0fe |
11 | #define MTRRdefType_MSR 0x2ff | 9 | #define MTRRdefType_MSR 0x2ff |