Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Ray Zhang <sgzhang@google.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20221010045549.2221965-2-sgzhang@google.com

authored by

Ray Zhang and committed by
Miquel Raynal
43cfba56 2df11f00

+27 -25
+27 -25
drivers/mtd/mtdoops.c
··· 7 7 * Author: Richard Purdie <rpurdie@openedhand.com> 8 8 */ 9 9 10 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 11 + 10 12 #include <linux/kernel.h> 11 13 #include <linux/module.h> 12 14 #include <linux/console.h> ··· 95 93 96 94 ret = mtd_erase(mtd, &erase); 97 95 if (ret) { 98 - printk(KERN_WARNING "mtdoops: erase of region [0x%llx, 0x%llx] on \"%s\" failed\n", 99 - (unsigned long long)erase.addr, 100 - (unsigned long long)erase.len, mtddev); 96 + pr_warn("erase of region [0x%llx, 0x%llx] on \"%s\" failed\n", 97 + (unsigned long long)erase.addr, 98 + (unsigned long long)erase.len, mtddev); 101 99 return ret; 102 100 } 103 101 ··· 122 120 return; 123 121 } 124 122 125 - printk(KERN_DEBUG "mtdoops: ready %d, %d (no erase)\n", 126 - cxt->nextpage, cxt->nextcount); 123 + pr_debug("ready %d, %d (no erase)\n", 124 + cxt->nextpage, cxt->nextcount); 127 125 } 128 126 129 127 /* Scheduled work - when we can't proceed without erasing a block */ ··· 147 145 148 146 while ((ret = mtd_block_isbad(mtd, cxt->nextpage * record_size)) > 0) { 149 147 badblock: 150 - printk(KERN_WARNING "mtdoops: bad block at %08lx\n", 151 - cxt->nextpage * record_size); 148 + pr_warn("bad block at %08lx\n", 149 + cxt->nextpage * record_size); 152 150 i++; 153 151 cxt->nextpage = cxt->nextpage + (mtd->erasesize / record_size); 154 152 if (cxt->nextpage >= cxt->oops_pages) 155 153 cxt->nextpage = 0; 156 154 if (i == cxt->oops_pages / (mtd->erasesize / record_size)) { 157 - printk(KERN_ERR "mtdoops: all blocks bad!\n"); 155 + pr_err("all blocks bad!\n"); 158 156 return; 159 157 } 160 158 } 161 159 162 160 if (ret < 0) { 163 - printk(KERN_ERR "mtdoops: mtd_block_isbad failed, aborting\n"); 161 + pr_err("mtd_block_isbad failed, aborting\n"); 164 162 return; 165 163 } 166 164 ··· 168 166 ret = mtdoops_erase_block(cxt, cxt->nextpage * record_size); 169 167 170 168 if (ret >= 0) { 171 - printk(KERN_DEBUG "mtdoops: ready %d, %d\n", 172 - cxt->nextpage, cxt->nextcount); 169 + pr_debug("ready %d, %d\n", 170 + cxt->nextpage, cxt->nextcount); 173 171 return; 174 172 } 175 173 176 174 if (ret == -EIO) { 177 175 ret = mtd_block_markbad(mtd, cxt->nextpage * record_size); 178 176 if (ret < 0 && ret != -EOPNOTSUPP) { 179 - printk(KERN_ERR "mtdoops: block_markbad failed, aborting\n"); 177 + pr_err("block_markbad failed, aborting\n"); 180 178 return; 181 179 } 182 180 } ··· 203 201 ret = mtd_panic_write(mtd, cxt->nextpage * record_size, 204 202 record_size, &retlen, cxt->oops_buf); 205 203 if (ret == -EOPNOTSUPP) { 206 - printk(KERN_ERR "mtdoops: Cannot write from panic without panic_write\n"); 204 + pr_err("Cannot write from panic without panic_write\n"); 207 205 goto out; 208 206 } 209 207 } else ··· 211 209 record_size, &retlen, cxt->oops_buf); 212 210 213 211 if (retlen != record_size || ret < 0) 214 - printk(KERN_ERR "mtdoops: write failure at %ld (%td of %ld written), error %d\n", 212 + pr_err("write failure at %ld (%td of %ld written), error %d\n", 215 213 cxt->nextpage * record_size, retlen, record_size, ret); 216 214 mark_page_used(cxt, cxt->nextpage); 217 215 memset(cxt->oops_buf, 0xff, record_size); ··· 246 244 &retlen, (u_char *)&hdr); 247 245 if (retlen != sizeof(hdr) || 248 246 (ret < 0 && !mtd_is_bitflip(ret))) { 249 - printk(KERN_ERR "mtdoops: read failure at %ld (%zu of %zu read), err %d\n", 247 + pr_err("read failure at %ld (%zu of %zu read), err %d\n", 250 248 page * record_size, retlen, sizeof(hdr), ret); 251 249 continue; 252 250 } ··· 326 324 return; 327 325 328 326 if (mtd->size < mtd->erasesize * 2) { 329 - printk(KERN_ERR "mtdoops: MTD partition %d not big enough for mtdoops\n", 327 + pr_err("MTD partition %d not big enough for mtdoops\n", 330 328 mtd->index); 331 329 return; 332 330 } 333 331 if (mtd->erasesize < record_size) { 334 - printk(KERN_ERR "mtdoops: eraseblock size of MTD partition %d too small\n", 332 + pr_err("eraseblock size of MTD partition %d too small\n", 335 333 mtd->index); 336 334 return; 337 335 } 338 336 if (mtd->size > MTDOOPS_MAX_MTD_SIZE) { 339 - printk(KERN_ERR "mtdoops: mtd%d is too large (limit is %d MiB)\n", 337 + pr_err("mtd%d is too large (limit is %d MiB)\n", 340 338 mtd->index, MTDOOPS_MAX_MTD_SIZE / 1024 / 1024); 341 339 return; 342 340 } ··· 347 345 DIV_ROUND_UP(mtdoops_pages, 348 346 BITS_PER_LONG))); 349 347 if (!cxt->oops_page_used) { 350 - printk(KERN_ERR "mtdoops: could not allocate page array\n"); 348 + pr_err("could not allocate page array\n"); 351 349 return; 352 350 } 353 351 ··· 355 353 cxt->dump.dump = mtdoops_do_dump; 356 354 err = kmsg_dump_register(&cxt->dump); 357 355 if (err) { 358 - printk(KERN_ERR "mtdoops: registering kmsg dumper failed, error %d\n", err); 356 + pr_err("registering kmsg dumper failed, error %d\n", err); 359 357 vfree(cxt->oops_page_used); 360 358 cxt->oops_page_used = NULL; 361 359 return; ··· 364 362 cxt->mtd = mtd; 365 363 cxt->oops_pages = (int)mtd->size / record_size; 366 364 find_next_position(cxt); 367 - printk(KERN_INFO "mtdoops: Attached to MTD device %d\n", mtd->index); 365 + pr_info("Attached to MTD device %d\n", mtd->index); 368 366 } 369 367 370 368 static void mtdoops_notify_remove(struct mtd_info *mtd) ··· 375 373 return; 376 374 377 375 if (kmsg_dump_unregister(&cxt->dump) < 0) 378 - printk(KERN_WARNING "mtdoops: could not unregister kmsg_dumper\n"); 376 + pr_warn("could not unregister kmsg_dumper\n"); 379 377 380 378 cxt->mtd = NULL; 381 379 flush_work(&cxt->work_erase); ··· 395 393 char *endp; 396 394 397 395 if (strlen(mtddev) == 0) { 398 - printk(KERN_ERR "mtdoops: mtd device (mtddev=name/number) must be supplied\n"); 396 + pr_err("mtd device (mtddev=name/number) must be supplied\n"); 399 397 return -EINVAL; 400 398 } 401 399 if ((record_size & 4095) != 0) { 402 - printk(KERN_ERR "mtdoops: record_size must be a multiple of 4096\n"); 400 + pr_err("record_size must be a multiple of 4096\n"); 403 401 return -EINVAL; 404 402 } 405 403 if (record_size < 4096) { 406 - printk(KERN_ERR "mtdoops: record_size must be over 4096 bytes\n"); 404 + pr_err("record_size must be over 4096 bytes\n"); 407 405 return -EINVAL; 408 406 } 409 407