aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/scan.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-02-15 18:56:44 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-03-26 19:39:40 -0400
commitda320f055a8818269c008e30b887cdcf09d8e4bd (patch)
treedeaead9c0bd0ed473e633fca2d66460b3b0ec99d /fs/jffs2/scan.c
parent9c261b33a9c417ccaf07f41796be278d09d02d49 (diff)
jffs2: Convert printks to pr_<level>
Use the more current logging style. Coalesce formats, align arguments. Convert uses of embedded function names to %s, __func__. A couple of long line checkpatch errors I don't care about exist. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'fs/jffs2/scan.c')
-rw-r--r--fs/jffs2/scan.c84
1 files changed, 46 insertions, 38 deletions
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index b6c3d883b7d7..078cede67141 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -22,15 +22,15 @@
22 22
23#define DEFAULT_EMPTY_SCAN_SIZE 256 23#define DEFAULT_EMPTY_SCAN_SIZE 256
24 24
25#define noisy_printk(noise, args...) do { \ 25#define noisy_printk(noise, fmt, ...) \
26 if (*(noise)) { \ 26do { \
27 printk(KERN_NOTICE args); \ 27 if (*(noise)) { \
28 (*(noise))--; \ 28 pr_notice(fmt, ##__VA_ARGS__); \
29 if (!(*(noise))) { \ 29 (*(noise))--; \
30 printk(KERN_NOTICE "Further such events for this erase block will not be printed\n"); \ 30 if (!(*(noise))) \
31 } \ 31 pr_notice("Further such events for this erase block will not be printed\n"); \
32 } \ 32 } \
33} while(0) 33} while (0)
34 34
35static uint32_t pseudo_random; 35static uint32_t pseudo_random;
36 36
@@ -233,7 +233,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
233 bad_blocks++; 233 bad_blocks++;
234 break; 234 break;
235 default: 235 default:
236 printk(KERN_WARNING "jffs2_scan_medium(): unknown block state\n"); 236 pr_warn("%s(): unknown block state\n", __func__);
237 BUG(); 237 BUG();
238 } 238 }
239 } 239 }
@@ -261,8 +261,9 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
261#endif 261#endif
262 if (c->nr_erasing_blocks) { 262 if (c->nr_erasing_blocks) {
263 if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) { 263 if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) {
264 printk(KERN_NOTICE "Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n"); 264 pr_notice("Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n");
265 printk(KERN_NOTICE "empty_blocks %d, bad_blocks %d, c->nr_blocks %d\n",empty_blocks,bad_blocks,c->nr_blocks); 265 pr_notice("empty_blocks %d, bad_blocks %d, c->nr_blocks %d\n",
266 empty_blocks, bad_blocks, c->nr_blocks);
266 ret = -EIO; 267 ret = -EIO;
267 goto out; 268 goto out;
268 } 269 }
@@ -611,12 +612,13 @@ scan_more:
611 cond_resched(); 612 cond_resched();
612 613
613 if (ofs & 3) { 614 if (ofs & 3) {
614 printk(KERN_WARNING "Eep. ofs 0x%08x not word-aligned!\n", ofs); 615 pr_warn("Eep. ofs 0x%08x not word-aligned!\n", ofs);
615 ofs = PAD(ofs); 616 ofs = PAD(ofs);
616 continue; 617 continue;
617 } 618 }
618 if (ofs == prevofs) { 619 if (ofs == prevofs) {
619 printk(KERN_WARNING "ofs 0x%08x has already been seen. Skipping\n", ofs); 620 pr_warn("ofs 0x%08x has already been seen. Skipping\n",
621 ofs);
620 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) 622 if ((err = jffs2_scan_dirty_space(c, jeb, 4)))
621 return err; 623 return err;
622 ofs += 4; 624 ofs += 4;
@@ -660,8 +662,8 @@ scan_more:
660 inbuf_ofs = ofs - buf_ofs; 662 inbuf_ofs = ofs - buf_ofs;
661 while (inbuf_ofs < scan_end) { 663 while (inbuf_ofs < scan_end) {
662 if (unlikely(*(uint32_t *)(&buf[inbuf_ofs]) != 0xffffffff)) { 664 if (unlikely(*(uint32_t *)(&buf[inbuf_ofs]) != 0xffffffff)) {
663 printk(KERN_WARNING "Empty flash at 0x%08x ends at 0x%08x\n", 665 pr_warn("Empty flash at 0x%08x ends at 0x%08x\n",
664 empty_start, ofs); 666 empty_start, ofs);
665 if ((err = jffs2_scan_dirty_space(c, jeb, ofs-empty_start))) 667 if ((err = jffs2_scan_dirty_space(c, jeb, ofs-empty_start)))
666 return err; 668 return err;
667 goto scan_more; 669 goto scan_more;
@@ -708,7 +710,8 @@ scan_more:
708 } 710 }
709 711
710 if (ofs == jeb->offset && je16_to_cpu(node->magic) == KSAMTIB_CIGAM_2SFFJ) { 712 if (ofs == jeb->offset && je16_to_cpu(node->magic) == KSAMTIB_CIGAM_2SFFJ) {
711 printk(KERN_WARNING "Magic bitmask is backwards at offset 0x%08x. Wrong endian filesystem?\n", ofs); 713 pr_warn("Magic bitmask is backwards at offset 0x%08x. Wrong endian filesystem?\n",
714 ofs);
712 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) 715 if ((err = jffs2_scan_dirty_space(c, jeb, 4)))
713 return err; 716 return err;
714 ofs += 4; 717 ofs += 4;
@@ -722,8 +725,8 @@ scan_more:
722 continue; 725 continue;
723 } 726 }
724 if (je16_to_cpu(node->magic) == JFFS2_OLD_MAGIC_BITMASK) { 727 if (je16_to_cpu(node->magic) == JFFS2_OLD_MAGIC_BITMASK) {
725 printk(KERN_WARNING "Old JFFS2 bitmask found at 0x%08x\n", ofs); 728 pr_warn("Old JFFS2 bitmask found at 0x%08x\n", ofs);
726 printk(KERN_WARNING "You cannot use older JFFS2 filesystems with newer kernels\n"); 729 pr_warn("You cannot use older JFFS2 filesystems with newer kernels\n");
727 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) 730 if ((err = jffs2_scan_dirty_space(c, jeb, 4)))
728 return err; 731 return err;
729 ofs += 4; 732 ofs += 4;
@@ -731,7 +734,8 @@ scan_more:
731 } 734 }
732 if (je16_to_cpu(node->magic) != JFFS2_MAGIC_BITMASK) { 735 if (je16_to_cpu(node->magic) != JFFS2_MAGIC_BITMASK) {
733 /* OK. We're out of possibilities. Whinge and move on */ 736 /* OK. We're out of possibilities. Whinge and move on */
734 noisy_printk(&noise, "jffs2_scan_eraseblock(): Magic bitmask 0x%04x not found at 0x%08x: 0x%04x instead\n", 737 noisy_printk(&noise, "%s(): Magic bitmask 0x%04x not found at 0x%08x: 0x%04x instead\n",
738 __func__,
735 JFFS2_MAGIC_BITMASK, ofs, 739 JFFS2_MAGIC_BITMASK, ofs,
736 je16_to_cpu(node->magic)); 740 je16_to_cpu(node->magic));
737 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) 741 if ((err = jffs2_scan_dirty_space(c, jeb, 4)))
@@ -746,7 +750,8 @@ scan_more:
746 hdr_crc = crc32(0, &crcnode, sizeof(crcnode)-4); 750 hdr_crc = crc32(0, &crcnode, sizeof(crcnode)-4);
747 751
748 if (hdr_crc != je32_to_cpu(node->hdr_crc)) { 752 if (hdr_crc != je32_to_cpu(node->hdr_crc)) {
749 noisy_printk(&noise, "jffs2_scan_eraseblock(): Node at 0x%08x {0x%04x, 0x%04x, 0x%08x) has invalid CRC 0x%08x (calculated 0x%08x)\n", 753 noisy_printk(&noise, "%s(): Node at 0x%08x {0x%04x, 0x%04x, 0x%08x) has invalid CRC 0x%08x (calculated 0x%08x)\n",
754 __func__,
750 ofs, je16_to_cpu(node->magic), 755 ofs, je16_to_cpu(node->magic),
751 je16_to_cpu(node->nodetype), 756 je16_to_cpu(node->nodetype),
752 je32_to_cpu(node->totlen), 757 je32_to_cpu(node->totlen),
@@ -760,9 +765,9 @@ scan_more:
760 765
761 if (ofs + je32_to_cpu(node->totlen) > jeb->offset + c->sector_size) { 766 if (ofs + je32_to_cpu(node->totlen) > jeb->offset + c->sector_size) {
762 /* Eep. Node goes over the end of the erase block. */ 767 /* Eep. Node goes over the end of the erase block. */
763 printk(KERN_WARNING "Node at 0x%08x with length 0x%08x would run over the end of the erase block\n", 768 pr_warn("Node at 0x%08x with length 0x%08x would run over the end of the erase block\n",
764 ofs, je32_to_cpu(node->totlen)); 769 ofs, je32_to_cpu(node->totlen));
765 printk(KERN_WARNING "Perhaps the file system was created with the wrong erase size?\n"); 770 pr_warn("Perhaps the file system was created with the wrong erase size?\n");
766 if ((err = jffs2_scan_dirty_space(c, jeb, 4))) 771 if ((err = jffs2_scan_dirty_space(c, jeb, 4)))
767 return err; 772 return err;
768 ofs += 4; 773 ofs += 4;
@@ -854,13 +859,15 @@ scan_more:
854 case JFFS2_NODETYPE_CLEANMARKER: 859 case JFFS2_NODETYPE_CLEANMARKER:
855 jffs2_dbg(1, "CLEANMARKER node found at 0x%08x\n", ofs); 860 jffs2_dbg(1, "CLEANMARKER node found at 0x%08x\n", ofs);
856 if (je32_to_cpu(node->totlen) != c->cleanmarker_size) { 861 if (je32_to_cpu(node->totlen) != c->cleanmarker_size) {
857 printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x has totlen 0x%x != normal 0x%x\n", 862 pr_notice("CLEANMARKER node found at 0x%08x has totlen 0x%x != normal 0x%x\n",
858 ofs, je32_to_cpu(node->totlen), c->cleanmarker_size); 863 ofs, je32_to_cpu(node->totlen),
864 c->cleanmarker_size);
859 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node))))) 865 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node)))))
860 return err; 866 return err;
861 ofs += PAD(sizeof(struct jffs2_unknown_node)); 867 ofs += PAD(sizeof(struct jffs2_unknown_node));
862 } else if (jeb->first_node) { 868 } else if (jeb->first_node) {
863 printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x, not first node in block (0x%08x)\n", ofs, jeb->offset); 869 pr_notice("CLEANMARKER node found at 0x%08x, not first node in block (0x%08x)\n",
870 ofs, jeb->offset);
864 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node))))) 871 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node)))))
865 return err; 872 return err;
866 ofs += PAD(sizeof(struct jffs2_unknown_node)); 873 ofs += PAD(sizeof(struct jffs2_unknown_node));
@@ -882,7 +889,8 @@ scan_more:
882 default: 889 default:
883 switch (je16_to_cpu(node->nodetype) & JFFS2_COMPAT_MASK) { 890 switch (je16_to_cpu(node->nodetype) & JFFS2_COMPAT_MASK) {
884 case JFFS2_FEATURE_ROCOMPAT: 891 case JFFS2_FEATURE_ROCOMPAT:
885 printk(KERN_NOTICE "Read-only compatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs); 892 pr_notice("Read-only compatible feature node (0x%04x) found at offset 0x%08x\n",
893 je16_to_cpu(node->nodetype), ofs);
886 c->flags |= JFFS2_SB_FLAG_RO; 894 c->flags |= JFFS2_SB_FLAG_RO;
887 if (!(jffs2_is_readonly(c))) 895 if (!(jffs2_is_readonly(c)))
888 return -EROFS; 896 return -EROFS;
@@ -892,7 +900,8 @@ scan_more:
892 break; 900 break;
893 901
894 case JFFS2_FEATURE_INCOMPAT: 902 case JFFS2_FEATURE_INCOMPAT:
895 printk(KERN_NOTICE "Incompatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs); 903 pr_notice("Incompatible feature node (0x%04x) found at offset 0x%08x\n",
904 je16_to_cpu(node->nodetype), ofs);
896 return -EINVAL; 905 return -EINVAL;
897 906
898 case JFFS2_FEATURE_RWCOMPAT_DELETE: 907 case JFFS2_FEATURE_RWCOMPAT_DELETE:
@@ -954,7 +963,7 @@ struct jffs2_inode_cache *jffs2_scan_make_ino_cache(struct jffs2_sb_info *c, uin
954 963
955 ic = jffs2_alloc_inode_cache(); 964 ic = jffs2_alloc_inode_cache();
956 if (!ic) { 965 if (!ic) {
957 printk(KERN_NOTICE "jffs2_scan_make_inode_cache(): allocation of inode cache failed\n"); 966 pr_notice("%s(): allocation of inode cache failed\n", __func__);
958 return NULL; 967 return NULL;
959 } 968 }
960 memset(ic, 0, sizeof(*ic)); 969 memset(ic, 0, sizeof(*ic));
@@ -987,9 +996,8 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc
987 /* Check the node CRC in any case. */ 996 /* Check the node CRC in any case. */
988 crc = crc32(0, ri, sizeof(*ri)-8); 997 crc = crc32(0, ri, sizeof(*ri)-8);
989 if (crc != je32_to_cpu(ri->node_crc)) { 998 if (crc != je32_to_cpu(ri->node_crc)) {
990 printk(KERN_NOTICE "jffs2_scan_inode_node(): CRC failed on " 999 pr_notice("%s(): CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
991 "node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", 1000 __func__, ofs, je32_to_cpu(ri->node_crc), crc);
992 ofs, je32_to_cpu(ri->node_crc), crc);
993 /* 1001 /*
994 * We believe totlen because the CRC on the node 1002 * We believe totlen because the CRC on the node
995 * _header_ was OK, just the node itself failed. 1003 * _header_ was OK, just the node itself failed.
@@ -1038,8 +1046,8 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
1038 crc = crc32(0, rd, sizeof(*rd)-8); 1046 crc = crc32(0, rd, sizeof(*rd)-8);
1039 1047
1040 if (crc != je32_to_cpu(rd->node_crc)) { 1048 if (crc != je32_to_cpu(rd->node_crc)) {
1041 printk(KERN_NOTICE "jffs2_scan_dirent_node(): Node CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", 1049 pr_notice("%s(): Node CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
1042 ofs, je32_to_cpu(rd->node_crc), crc); 1050 __func__, ofs, je32_to_cpu(rd->node_crc), crc);
1043 /* We believe totlen because the CRC on the node _header_ was OK, just the node itself failed. */ 1051 /* We believe totlen because the CRC on the node _header_ was OK, just the node itself failed. */
1044 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rd->totlen))))) 1052 if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rd->totlen)))))
1045 return err; 1053 return err;
@@ -1051,7 +1059,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
1051 /* Should never happen. Did. (OLPC trac #4184)*/ 1059 /* Should never happen. Did. (OLPC trac #4184)*/
1052 checkedlen = strnlen(rd->name, rd->nsize); 1060 checkedlen = strnlen(rd->name, rd->nsize);
1053 if (checkedlen < rd->nsize) { 1061 if (checkedlen < rd->nsize) {
1054 printk(KERN_ERR "Dirent at %08x has zeroes in name. Truncating to %d chars\n", 1062 pr_err("Dirent at %08x has zeroes in name. Truncating to %d chars\n",
1055 ofs, checkedlen); 1063 ofs, checkedlen);
1056 } 1064 }
1057 fd = jffs2_alloc_full_dirent(checkedlen+1); 1065 fd = jffs2_alloc_full_dirent(checkedlen+1);
@@ -1063,8 +1071,8 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
1063 1071
1064 crc = crc32(0, fd->name, rd->nsize); 1072 crc = crc32(0, fd->name, rd->nsize);
1065 if (crc != je32_to_cpu(rd->name_crc)) { 1073 if (crc != je32_to_cpu(rd->name_crc)) {
1066 printk(KERN_NOTICE "jffs2_scan_dirent_node(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", 1074 pr_notice("%s(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
1067 ofs, je32_to_cpu(rd->name_crc), crc); 1075 __func__, ofs, je32_to_cpu(rd->name_crc), crc);
1068 jffs2_dbg(1, "Name for which CRC failed is (now) '%s', ino #%d\n", 1076 jffs2_dbg(1, "Name for which CRC failed is (now) '%s', ino #%d\n",
1069 fd->name, je32_to_cpu(rd->ino)); 1077 fd->name, je32_to_cpu(rd->ino));
1070 jffs2_free_full_dirent(fd); 1078 jffs2_free_full_dirent(fd);