[PATCH v3 1/3] mtd: mtdoops: change printk() to counterpart pr_ functions
Joe Perches
joe at perches.com
Sat Oct 8 00:25:07 PDT 2022
On Fri, 2022-10-07 at 21:50 +0000, Ray Zhang wrote:
> 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.
Another thing possible is to add
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
before any #include
> diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
[]
> @@ -93,9 +93,9 @@ static int mtdoops_erase_block(struct mtdoops_context *cxt, int offset)
>
> ret = mtd_erase(mtd, &erase);
> if (ret) {
> - printk(KERN_WARNING "mtdoops: erase of region [0x%llx, 0x%llx] on \"%s\" failed\n",
> - (unsigned long long)erase.addr,
> - (unsigned long long)erase.len, mtddev);
> + pr_warn("mtdoops: erase of region [0x%llx, 0x%llx] on \"%s\" failed\n",
> + (unsigned long long)erase.addr,
> + (unsigned long long)erase.len, mtddev);
And remove the "mtdoops: " prefixes from all the output formats
pr_warn("erase of region [0x%llx, 0x%llx] on \"%s\" failed\n",
(unsigned long long)erase.addr,
(unsigned long long)erase.len, mtddev);
> @@ -120,8 +120,8 @@ static void mtdoops_inc_counter(struct mtdoops_context *cxt)
> return;
> }
>
> - printk(KERN_DEBUG "mtdoops: ready %d, %d (no erase)\n",
> - cxt->nextpage, cxt->nextcount);
> + pr_debug("mtdoops: ready %d, %d (no erase)\n",
> + cxt->nextpage, cxt->nextcount);
pr_debug("ready %d, %d (no erase)\n", cxt->nextpage, cxt->nextcount);
etc...
More information about the linux-mtd
mailing list