Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 116038
b: refs/heads/master
c: f0482ee
h: refs/heads/master
v: v3
  • Loading branch information
Richard Purdie authored and David Woodhouse committed Oct 18, 2008
1 parent 778113b commit c490c5d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ecd5b3102322011610a2521c389ab5804c811837
refs/heads/master: f0482ee3669a78bdb1e15b9f9c58a9f1ffc5a997
32 changes: 18 additions & 14 deletions trunk/drivers/mtd/mtdoops.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <linux/interrupt.h>
#include <linux/mtd/mtd.h>

#define MTDOOPS_KERNMSG_MAGIC 0x5d005d00
#define OOPS_PAGE_SIZE 4096

static struct mtdoops_context {
Expand Down Expand Up @@ -224,31 +225,33 @@ static void find_next_position(struct mtdoops_context *cxt)
{
struct mtd_info *mtd = cxt->mtd;
int ret, page, maxpos = 0;
u32 count, maxcount = 0xffffffff;
u32 count[2], maxcount = 0xffffffff;
size_t retlen;

for (page = 0; page < cxt->oops_pages; page++) {
ret = mtd->read(mtd, page * OOPS_PAGE_SIZE, 4, &retlen, (u_char *) &count);
if ((retlen != 4) || ((ret < 0) && (ret != -EUCLEAN))) {
printk(KERN_ERR "mtdoops: Read failure at %d (%td of 4 read)"
ret = mtd->read(mtd, page * OOPS_PAGE_SIZE, 8, &retlen, (u_char *) &count[0]);
if ((retlen != 8) || ((ret < 0) && (ret != -EUCLEAN))) {
printk(KERN_ERR "mtdoops: Read failure at %d (%td of 8 read)"
", err %d.\n", page * OOPS_PAGE_SIZE, retlen, ret);
continue;
}

if (count == 0xffffffff)
if (count[1] != MTDOOPS_KERNMSG_MAGIC)
continue;
if (count[0] == 0xffffffff)
continue;
if (maxcount == 0xffffffff) {
maxcount = count;
maxcount = count[0];
maxpos = page;
} else if ((count < 0x40000000) && (maxcount > 0xc0000000)) {
maxcount = count;
} else if ((count[0] < 0x40000000) && (maxcount > 0xc0000000)) {
maxcount = count[0];
maxpos = page;
} else if ((count > maxcount) && (count < 0xc0000000)) {
maxcount = count;
} else if ((count[0] > maxcount) && (count[0] < 0xc0000000)) {
maxcount = count[0];
maxpos = page;
} else if ((count > maxcount) && (count > 0xc0000000)
} else if ((count[0] > maxcount) && (count[0] > 0xc0000000)
&& (maxcount > 0x80000000)) {
maxcount = count;
maxcount = count[0];
maxpos = page;
}
}
Expand Down Expand Up @@ -358,8 +361,9 @@ mtdoops_console_write(struct console *co, const char *s, unsigned int count)

if (cxt->writecount == 0) {
u32 *stamp = cxt->oops_buf;
*stamp = cxt->nextcount;
cxt->writecount = 4;
*stamp++ = cxt->nextcount;
*stamp = MTDOOPS_KERNMSG_MAGIC;
cxt->writecount = 8;
}

if ((count + cxt->writecount) > OOPS_PAGE_SIZE)
Expand Down

0 comments on commit c490c5d

Please sign in to comment.