Revert "temp revert apanice change"
author黄涛 <huangtao@rock-chips.com>
Sun, 31 Jul 2011 17:49:14 +0000 (01:49 +0800)
committer黄涛 <huangtao@rock-chips.com>
Sun, 31 Jul 2011 17:49:14 +0000 (01:49 +0800)
This reverts commit 755c00cd5193c5dc18f6b8bbf9e8f43413f59513.

drivers/misc/apanic.c

index ca875f89da7a7ffe4dfde8eda532f26c800d50f9..4a9f48ac74802447b5d2397a7e819fe36ef36676 100644 (file)
@@ -193,8 +193,13 @@ static int apanic_proc_read(char *buffer, char **start, off_t offset,
                ctx->mtd->writesize,
                &len, ctx->bounce);
 
+#ifdef CONFIG_MTD_RKNAND
+       if (count > (ctx->mtd->writesize - page_offset))
+               count = ctx->mtd->writesize - page_offset;
+#else
        if (page_offset)
                count -= page_offset;
+#endif
        memcpy(buffer, ctx->bounce + page_offset, count);
 
        *start = count;
@@ -209,6 +214,11 @@ static int apanic_proc_read(char *buffer, char **start, off_t offset,
 static void mtd_panic_erase(void)
 {
        struct apanic_data *ctx = &drv_ctx;
+#ifdef CONFIG_MTD_RKNAND
+       size_t wlen;
+       memset(ctx->bounce, 0, ctx->mtd->writesize);
+       ctx->mtd->write(ctx->mtd, 0, ctx->mtd->writesize, &wlen, ctx->bounce);
+#else
        struct erase_info erase;
        DECLARE_WAITQUEUE(wait, current);
        wait_queue_head_t wait_q;
@@ -260,6 +270,7 @@ static void mtd_panic_erase(void)
                schedule();
                remove_wait_queue(&wait_q, &wait);
        }
+#endif
        printk(KERN_DEBUG "apanic: %s partition erased\n",
               CONFIG_APANIC_PLABEL);
 out:
@@ -331,14 +342,18 @@ static void mtd_panic_notify_add(struct mtd_info *mtd)
 
        if (hdr->magic != PANIC_MAGIC) {
                printk(KERN_INFO "apanic: No panic data available\n");
+#ifndef CONFIG_MTD_RKNAND
                mtd_panic_erase();
+#endif
                return;
        }
 
        if (hdr->version != PHDR_VERSION) {
                printk(KERN_INFO "apanic: Version mismatch (%d != %d)\n",
                       hdr->version, PHDR_VERSION);
+#ifndef CONFIG_MTD_RKNAND
                mtd_panic_erase();
+#endif
                return;
        }
 
@@ -378,8 +393,10 @@ static void mtd_panic_notify_add(struct mtd_info *mtd)
                }
        }
 
+#ifndef CONFIG_MTD_RKNAND
        if (!proc_entry_created)
                mtd_panic_erase();
+#endif
 
        return;
 out_err:
@@ -511,7 +528,7 @@ static int apanic(struct notifier_block *this, unsigned long event,
                printk(KERN_EMERG "Crash partition in use!\n");
                goto out;
        }
-       console_offset = ctx->mtd->writesize;
+       console_offset = ctx->mtd->erasesize;
 
        /*
         * Write out the console