[PATCH 10/12] x86, mce: cleanup mce_read
From: Hidetoshi Seto
Date: Fri May 27 2011 - 00:11:54 EST
Use temporary local entry to make code simple.
No change in logic.
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@xxxxxxxxxxxxxx>
---
arch/x86/kernel/cpu/mcheck/mce.c | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 9fe9e6e..4ba4040 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1533,18 +1533,17 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize,
do {
for (i = prev; i < next; i++) {
unsigned long start = jiffies;
+ struct mce *entry = &mcelog.entry[i];
- while (!mcelog.entry[i].finished) {
+ while (!entry->finished) {
if (time_after_eq(jiffies, start + 2)) {
- memset(mcelog.entry + i, 0,
- sizeof(struct mce));
+ memset(entry, 0, sizeof(struct mce));
goto timeout;
}
cpu_relax();
}
smp_rmb();
- err |= copy_to_user(buf, mcelog.entry + i,
- sizeof(struct mce));
+ err |= copy_to_user(buf, entry, sizeof(struct mce));
buf += sizeof(struct mce);
timeout:
;
@@ -1565,13 +1564,13 @@ timeout:
on_each_cpu(collect_tscs, cpu_tsc, 1);
for (i = next; i < MCE_LOG_LEN; i++) {
- if (mcelog.entry[i].finished &&
- mcelog.entry[i].tsc < cpu_tsc[mcelog.entry[i].cpu]) {
- err |= copy_to_user(buf, mcelog.entry+i,
- sizeof(struct mce));
+ struct mce *entry = &mcelog.entry[i];
+
+ if (entry->finished && entry->tsc < cpu_tsc[entry->cpu]) {
+ err |= copy_to_user(buf, entry, sizeof(struct mce));
smp_rmb();
buf += sizeof(struct mce);
- memset(&mcelog.entry[i], 0, sizeof(struct mce));
+ memset(entry, 0, sizeof(struct mce));
}
}
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/