Commit 016c1291 authored by Artem Bityutskiy's avatar Artem Bityutskiy Committed by David Woodhouse

mtd: mtdoops: do not use mtd->panic_write directly

Instead of checking if 'mtd->panic_write' is defined, call 'mtd_panic_write()'
and check the error code - '-EOPNOTSUPP' will be returned if the function is
not defined.
Signed-off-by: default avatarArtem Bityutskiy <>
Signed-off-by: default avatarDavid Woodhouse <>
parent 4991e725
......@@ -221,10 +221,14 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic)
hdr[0] = cxt->nextcount;
if (panic)
if (panic) {
ret = mtd_panic_write(mtd, cxt->nextpage * record_size,
record_size, &retlen, cxt->oops_buf);
if (ret == -EOPNOTSUPP) {
printk(KERN_ERR "mtdoops: Cannot write from panic without panic_write\n");
} else
ret = mtd_write(mtd, cxt->nextpage * record_size,
record_size, &retlen, cxt->oops_buf);
......@@ -330,13 +334,8 @@ static void mtdoops_do_dump(struct kmsg_dumper *dumper,
memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy);
/* Panics must be written immediately */
if (reason != KMSG_DUMP_OOPS) {
if (!cxt->mtd->panic_write)
printk(KERN_ERR "mtdoops: Cannot write from panic without panic_write\n");
mtdoops_write(cxt, 1);
if (reason != KMSG_DUMP_OOPS)
mtdoops_write(cxt, 1);
/* For other cases, schedule work to write it "nicely" */
......@@ -311,6 +311,8 @@ static inline int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf)
*retlen = 0;
if (!mtd->panic_write)
return mtd->panic_write(mtd, to, len, retlen, buf);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment