提交 43cfba56 编写于 作者: R Ray Zhang 提交者: Miquel Raynal

mtd: mtdoops: change printk() to counterpart pr_ functions

To comply with latest kernel code requirement, change printk() to
counterpart pr_ functions in mtdoops driver:
- change printk(INFO) to pr_info()
- change printk(DEBUG) to pr_debug()
- change printk(WARNING) to pr_warn()
- change printk(ERR) to pr_err()

Note that only if dynamic debugging is enabled or DEBUG is defined,
printk(KERN_DEBUG) and pr_debug() are equivalent; Otherwise pr_debug()
is no-op, causing different behavior.
Signed-off-by: NRay Zhang <sgzhang@google.com>
Signed-off-by: NMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20221010045549.2221965-2-sgzhang@google.com
上级 2df11f00
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
* Author: Richard Purdie <rpurdie@openedhand.com> * Author: Richard Purdie <rpurdie@openedhand.com>
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/console.h> #include <linux/console.h>
...@@ -93,9 +95,9 @@ static int mtdoops_erase_block(struct mtdoops_context *cxt, int offset) ...@@ -93,9 +95,9 @@ static int mtdoops_erase_block(struct mtdoops_context *cxt, int offset)
ret = mtd_erase(mtd, &erase); ret = mtd_erase(mtd, &erase);
if (ret) { if (ret) {
printk(KERN_WARNING "mtdoops: erase of region [0x%llx, 0x%llx] on \"%s\" failed\n", pr_warn("erase of region [0x%llx, 0x%llx] on \"%s\" failed\n",
(unsigned long long)erase.addr, (unsigned long long)erase.addr,
(unsigned long long)erase.len, mtddev); (unsigned long long)erase.len, mtddev);
return ret; return ret;
} }
...@@ -120,8 +122,8 @@ static void mtdoops_inc_counter(struct mtdoops_context *cxt) ...@@ -120,8 +122,8 @@ static void mtdoops_inc_counter(struct mtdoops_context *cxt)
return; return;
} }
printk(KERN_DEBUG "mtdoops: ready %d, %d (no erase)\n", pr_debug("ready %d, %d (no erase)\n",
cxt->nextpage, cxt->nextcount); cxt->nextpage, cxt->nextcount);
} }
/* Scheduled work - when we can't proceed without erasing a block */ /* Scheduled work - when we can't proceed without erasing a block */
...@@ -145,20 +147,20 @@ static void mtdoops_workfunc_erase(struct work_struct *work) ...@@ -145,20 +147,20 @@ static void mtdoops_workfunc_erase(struct work_struct *work)
while ((ret = mtd_block_isbad(mtd, cxt->nextpage * record_size)) > 0) { while ((ret = mtd_block_isbad(mtd, cxt->nextpage * record_size)) > 0) {
badblock: badblock:
printk(KERN_WARNING "mtdoops: bad block at %08lx\n", pr_warn("bad block at %08lx\n",
cxt->nextpage * record_size); cxt->nextpage * record_size);
i++; i++;
cxt->nextpage = cxt->nextpage + (mtd->erasesize / record_size); cxt->nextpage = cxt->nextpage + (mtd->erasesize / record_size);
if (cxt->nextpage >= cxt->oops_pages) if (cxt->nextpage >= cxt->oops_pages)
cxt->nextpage = 0; cxt->nextpage = 0;
if (i == cxt->oops_pages / (mtd->erasesize / record_size)) { if (i == cxt->oops_pages / (mtd->erasesize / record_size)) {
printk(KERN_ERR "mtdoops: all blocks bad!\n"); pr_err("all blocks bad!\n");
return; return;
} }
} }
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "mtdoops: mtd_block_isbad failed, aborting\n"); pr_err("mtd_block_isbad failed, aborting\n");
return; return;
} }
...@@ -166,15 +168,15 @@ static void mtdoops_workfunc_erase(struct work_struct *work) ...@@ -166,15 +168,15 @@ static void mtdoops_workfunc_erase(struct work_struct *work)
ret = mtdoops_erase_block(cxt, cxt->nextpage * record_size); ret = mtdoops_erase_block(cxt, cxt->nextpage * record_size);
if (ret >= 0) { if (ret >= 0) {
printk(KERN_DEBUG "mtdoops: ready %d, %d\n", pr_debug("ready %d, %d\n",
cxt->nextpage, cxt->nextcount); cxt->nextpage, cxt->nextcount);
return; return;
} }
if (ret == -EIO) { if (ret == -EIO) {
ret = mtd_block_markbad(mtd, cxt->nextpage * record_size); ret = mtd_block_markbad(mtd, cxt->nextpage * record_size);
if (ret < 0 && ret != -EOPNOTSUPP) { if (ret < 0 && ret != -EOPNOTSUPP) {
printk(KERN_ERR "mtdoops: block_markbad failed, aborting\n"); pr_err("block_markbad failed, aborting\n");
return; return;
} }
} }
...@@ -201,7 +203,7 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic) ...@@ -201,7 +203,7 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic)
ret = mtd_panic_write(mtd, cxt->nextpage * record_size, ret = mtd_panic_write(mtd, cxt->nextpage * record_size,
record_size, &retlen, cxt->oops_buf); record_size, &retlen, cxt->oops_buf);
if (ret == -EOPNOTSUPP) { if (ret == -EOPNOTSUPP) {
printk(KERN_ERR "mtdoops: Cannot write from panic without panic_write\n"); pr_err("Cannot write from panic without panic_write\n");
goto out; goto out;
} }
} else } else
...@@ -209,7 +211,7 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic) ...@@ -209,7 +211,7 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic)
record_size, &retlen, cxt->oops_buf); record_size, &retlen, cxt->oops_buf);
if (retlen != record_size || ret < 0) if (retlen != record_size || ret < 0)
printk(KERN_ERR "mtdoops: write failure at %ld (%td of %ld written), error %d\n", pr_err("write failure at %ld (%td of %ld written), error %d\n",
cxt->nextpage * record_size, retlen, record_size, ret); cxt->nextpage * record_size, retlen, record_size, ret);
mark_page_used(cxt, cxt->nextpage); mark_page_used(cxt, cxt->nextpage);
memset(cxt->oops_buf, 0xff, record_size); memset(cxt->oops_buf, 0xff, record_size);
...@@ -244,7 +246,7 @@ static void find_next_position(struct mtdoops_context *cxt) ...@@ -244,7 +246,7 @@ static void find_next_position(struct mtdoops_context *cxt)
&retlen, (u_char *)&hdr); &retlen, (u_char *)&hdr);
if (retlen != sizeof(hdr) || if (retlen != sizeof(hdr) ||
(ret < 0 && !mtd_is_bitflip(ret))) { (ret < 0 && !mtd_is_bitflip(ret))) {
printk(KERN_ERR "mtdoops: read failure at %ld (%zu of %zu read), err %d\n", pr_err("read failure at %ld (%zu of %zu read), err %d\n",
page * record_size, retlen, sizeof(hdr), ret); page * record_size, retlen, sizeof(hdr), ret);
continue; continue;
} }
...@@ -324,17 +326,17 @@ static void mtdoops_notify_add(struct mtd_info *mtd) ...@@ -324,17 +326,17 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
return; return;
if (mtd->size < mtd->erasesize * 2) { if (mtd->size < mtd->erasesize * 2) {
printk(KERN_ERR "mtdoops: MTD partition %d not big enough for mtdoops\n", pr_err("MTD partition %d not big enough for mtdoops\n",
mtd->index); mtd->index);
return; return;
} }
if (mtd->erasesize < record_size) { if (mtd->erasesize < record_size) {
printk(KERN_ERR "mtdoops: eraseblock size of MTD partition %d too small\n", pr_err("eraseblock size of MTD partition %d too small\n",
mtd->index); mtd->index);
return; return;
} }
if (mtd->size > MTDOOPS_MAX_MTD_SIZE) { if (mtd->size > MTDOOPS_MAX_MTD_SIZE) {
printk(KERN_ERR "mtdoops: mtd%d is too large (limit is %d MiB)\n", pr_err("mtd%d is too large (limit is %d MiB)\n",
mtd->index, MTDOOPS_MAX_MTD_SIZE / 1024 / 1024); mtd->index, MTDOOPS_MAX_MTD_SIZE / 1024 / 1024);
return; return;
} }
...@@ -345,7 +347,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd) ...@@ -345,7 +347,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
DIV_ROUND_UP(mtdoops_pages, DIV_ROUND_UP(mtdoops_pages,
BITS_PER_LONG))); BITS_PER_LONG)));
if (!cxt->oops_page_used) { if (!cxt->oops_page_used) {
printk(KERN_ERR "mtdoops: could not allocate page array\n"); pr_err("could not allocate page array\n");
return; return;
} }
...@@ -353,7 +355,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd) ...@@ -353,7 +355,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
cxt->dump.dump = mtdoops_do_dump; cxt->dump.dump = mtdoops_do_dump;
err = kmsg_dump_register(&cxt->dump); err = kmsg_dump_register(&cxt->dump);
if (err) { if (err) {
printk(KERN_ERR "mtdoops: registering kmsg dumper failed, error %d\n", err); pr_err("registering kmsg dumper failed, error %d\n", err);
vfree(cxt->oops_page_used); vfree(cxt->oops_page_used);
cxt->oops_page_used = NULL; cxt->oops_page_used = NULL;
return; return;
...@@ -362,7 +364,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd) ...@@ -362,7 +364,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
cxt->mtd = mtd; cxt->mtd = mtd;
cxt->oops_pages = (int)mtd->size / record_size; cxt->oops_pages = (int)mtd->size / record_size;
find_next_position(cxt); find_next_position(cxt);
printk(KERN_INFO "mtdoops: Attached to MTD device %d\n", mtd->index); pr_info("Attached to MTD device %d\n", mtd->index);
} }
static void mtdoops_notify_remove(struct mtd_info *mtd) static void mtdoops_notify_remove(struct mtd_info *mtd)
...@@ -373,7 +375,7 @@ static void mtdoops_notify_remove(struct mtd_info *mtd) ...@@ -373,7 +375,7 @@ static void mtdoops_notify_remove(struct mtd_info *mtd)
return; return;
if (kmsg_dump_unregister(&cxt->dump) < 0) if (kmsg_dump_unregister(&cxt->dump) < 0)
printk(KERN_WARNING "mtdoops: could not unregister kmsg_dumper\n"); pr_warn("could not unregister kmsg_dumper\n");
cxt->mtd = NULL; cxt->mtd = NULL;
flush_work(&cxt->work_erase); flush_work(&cxt->work_erase);
...@@ -393,15 +395,15 @@ static int __init mtdoops_init(void) ...@@ -393,15 +395,15 @@ static int __init mtdoops_init(void)
char *endp; char *endp;
if (strlen(mtddev) == 0) { if (strlen(mtddev) == 0) {
printk(KERN_ERR "mtdoops: mtd device (mtddev=name/number) must be supplied\n"); pr_err("mtd device (mtddev=name/number) must be supplied\n");
return -EINVAL; return -EINVAL;
} }
if ((record_size & 4095) != 0) { if ((record_size & 4095) != 0) {
printk(KERN_ERR "mtdoops: record_size must be a multiple of 4096\n"); pr_err("record_size must be a multiple of 4096\n");
return -EINVAL; return -EINVAL;
} }
if (record_size < 4096) { if (record_size < 4096) {
printk(KERN_ERR "mtdoops: record_size must be over 4096 bytes\n"); pr_err("record_size must be over 4096 bytes\n");
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册