x86, mce: Cleanup mce_read()

Use a temporary local variable m to simplify the code. No change in
logic.

Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Acked-by: Tony Luck <tony.luck@intel.com>
Link: http://lkml.kernel.org/r/4DEED7A8.8020307@jp.fujitsu.com
Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
This commit is contained in:
Hidetoshi Seto 2011-06-08 11:00:08 +09:00 committed by Borislav Petkov
parent f6783c4234
commit 559faa6be1

View File

@ -1537,19 +1537,18 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize,
do { do {
for (i = prev; i < next; i++) { for (i = prev; i < next; i++) {
unsigned long start = jiffies; unsigned long start = jiffies;
struct mce *m = &mcelog.entry[i];
while (!mcelog.entry[i].finished) { while (!m->finished) {
if (time_after_eq(jiffies, start + 2)) { if (time_after_eq(jiffies, start + 2)) {
memset(mcelog.entry + i, 0, memset(m, 0, sizeof(*m));
sizeof(struct mce));
goto timeout; goto timeout;
} }
cpu_relax(); cpu_relax();
} }
smp_rmb(); smp_rmb();
err |= copy_to_user(buf, mcelog.entry + i, err |= copy_to_user(buf, m, sizeof(*m));
sizeof(struct mce)); buf += sizeof(*m);
buf += sizeof(struct mce);
timeout: timeout:
; ;
} }
@ -1569,13 +1568,13 @@ timeout:
on_each_cpu(collect_tscs, cpu_tsc, 1); on_each_cpu(collect_tscs, cpu_tsc, 1);
for (i = next; i < MCE_LOG_LEN; i++) { for (i = next; i < MCE_LOG_LEN; i++) {
if (mcelog.entry[i].finished && struct mce *m = &mcelog.entry[i];
mcelog.entry[i].tsc < cpu_tsc[mcelog.entry[i].cpu]) {
err |= copy_to_user(buf, mcelog.entry+i, if (m->finished && m->tsc < cpu_tsc[m->cpu]) {
sizeof(struct mce)); err |= copy_to_user(buf, m, sizeof(*m));
smp_rmb(); smp_rmb();
buf += sizeof(struct mce); buf += sizeof(*m);
memset(&mcelog.entry[i], 0, sizeof(struct mce)); memset(m, 0, sizeof(*m));
} }
} }