Skip to content

Commit da320f0

Browse files
JoePerchesDavid Woodhouse
authored andcommitted
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>
1 parent 9c261b3 commit da320f0

17 files changed

Lines changed: 342 additions & 264 deletions

File tree

‎fs/jffs2/background.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ int jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c)
4242

4343
tsk = kthread_run(jffs2_garbage_collect_thread, c, "jffs2_gcd_mtd%d", c->mtd->index);
4444
if (IS_ERR(tsk)) {
45-
printk(KERN_WARNING "fork failed for JFFS2 garbage collect thread: %ld\n", -PTR_ERR(tsk));
45+
pr_warn("fork failed for JFFS2 garbage collect thread: %ld\n",
46+
-PTR_ERR(tsk));
4647
complete(&c->gc_thread_exit);
4748
ret = PTR_ERR(tsk);
4849
} else {
@@ -152,7 +153,7 @@ static int jffs2_garbage_collect_thread(void *_c)
152153

153154
jffs2_dbg(1, "%s(): pass\n", __func__);
154155
if (jffs2_garbage_collect_pass(c) == -ENOSPC) {
155-
printk(KERN_NOTICE "No space for garbage collection. Aborting GC thread\n");
156+
pr_notice("No space for garbage collection. Aborting GC thread\n");
156157
goto die;
157158
}
158159
}

‎fs/jffs2/compr.c‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static int jffs2_selected_compress(u8 compr, unsigned char *data_in,
7979

8080
output_buf = kmalloc(*cdatalen, GFP_KERNEL);
8181
if (!output_buf) {
82-
printk(KERN_WARNING "JFFS2: No memory for compressor allocation. Compression failed.\n");
82+
pr_warn("JFFS2: No memory for compressor allocation. Compression failed.\n");
8383
return ret;
8484
}
8585
orig_slen = *datalen;
@@ -188,7 +188,8 @@ uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
188188
tmp_buf = kmalloc(orig_slen, GFP_KERNEL);
189189
spin_lock(&jffs2_compressor_list_lock);
190190
if (!tmp_buf) {
191-
printk(KERN_WARNING "JFFS2: No memory for compressor allocation. (%d bytes)\n", orig_slen);
191+
pr_warn("JFFS2: No memory for compressor allocation. (%d bytes)\n",
192+
orig_slen);
192193
continue;
193194
}
194195
else {
@@ -235,7 +236,7 @@ uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
235236
cpage_out, datalen, cdatalen);
236237
break;
237238
default:
238-
printk(KERN_ERR "JFFS2: unknown compression mode.\n");
239+
pr_err("JFFS2: unknown compression mode\n");
239240
}
240241

241242
if (ret == JFFS2_COMPR_NONE) {
@@ -277,7 +278,8 @@ int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
277278
ret = this->decompress(cdata_in, data_out, cdatalen, datalen);
278279
spin_lock(&jffs2_compressor_list_lock);
279280
if (ret) {
280-
printk(KERN_WARNING "Decompressor \"%s\" returned %d\n", this->name, ret);
281+
pr_warn("Decompressor \"%s\" returned %d\n",
282+
this->name, ret);
281283
}
282284
else {
283285
this->stat_decompr_blocks++;
@@ -287,7 +289,8 @@ int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
287289
return ret;
288290
}
289291
}
290-
printk(KERN_WARNING "JFFS2 compression type 0x%02x not available.\n", comprtype);
292+
pr_warn("JFFS2 compression type 0x%02x not available\n",
293+
comprtype);
291294
spin_unlock(&jffs2_compressor_list_lock);
292295
return -EIO;
293296
}
@@ -299,7 +302,7 @@ int jffs2_register_compressor(struct jffs2_compressor *comp)
299302
struct jffs2_compressor *this;
300303

301304
if (!comp->name) {
302-
printk(KERN_WARNING "NULL compressor name at registering JFFS2 compressor. Failed.\n");
305+
pr_warn("NULL compressor name at registering JFFS2 compressor. Failed.\n");
303306
return -1;
304307
}
305308
comp->compr_buf_size=0;
@@ -340,7 +343,7 @@ int jffs2_unregister_compressor(struct jffs2_compressor *comp)
340343

341344
if (comp->usecount) {
342345
spin_unlock(&jffs2_compressor_list_lock);
343-
printk(KERN_WARNING "JFFS2: Compressor module is in use. Unregister failed.\n");
346+
pr_warn("JFFS2: Compressor module is in use. Unregister failed.\n");
344347
return -1;
345348
}
346349
list_del(&comp->list);

‎fs/jffs2/compr_zlib.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static int jffs2_zlib_compress(unsigned char *data_in,
7979
mutex_lock(&deflate_mutex);
8080

8181
if (Z_OK != zlib_deflateInit(&def_strm, 3)) {
82-
printk(KERN_WARNING "deflateInit failed\n");
82+
pr_warn("deflateInit failed\n");
8383
mutex_unlock(&deflate_mutex);
8484
return -1;
8585
}
@@ -169,15 +169,15 @@ static int jffs2_zlib_decompress(unsigned char *data_in,
169169

170170

171171
if (Z_OK != zlib_inflateInit2(&inf_strm, wbits)) {
172-
printk(KERN_WARNING "inflateInit failed\n");
172+
pr_warn("inflateInit failed\n");
173173
mutex_unlock(&inflate_mutex);
174174
return 1;
175175
}
176176

177177
while((ret = zlib_inflate(&inf_strm, Z_FINISH)) == Z_OK)
178178
;
179179
if (ret != Z_STREAM_END) {
180-
printk(KERN_NOTICE "inflate returned %d\n", ret);
180+
pr_notice("inflate returned %d\n", ret);
181181
}
182182
zlib_inflateEnd(&inf_strm);
183183
mutex_unlock(&inflate_mutex);

‎fs/jffs2/debug.c‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,24 +261,28 @@ void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
261261
bad += c->sector_size;
262262
}
263263

264-
#define check(sz) \
265-
if (sz != c->sz##_size) { \
266-
printk(KERN_WARNING #sz "_size mismatch counted 0x%x, c->" #sz "_size 0x%x\n", \
267-
sz, c->sz##_size); \
268-
dump = 1; \
269-
}
264+
#define check(sz) \
265+
do { \
266+
if (sz != c->sz##_size) { \
267+
pr_warn("%s_size mismatch counted 0x%x, c->%s_size 0x%x\n", \
268+
#sz, #sz, sz, c->sz##_size); \
269+
dump = 1; \
270+
} \
271+
} while (0)
272+
270273
check(free);
271274
check(dirty);
272275
check(used);
273276
check(wasted);
274277
check(unchecked);
275278
check(bad);
276279
check(erasing);
280+
277281
#undef check
278282

279283
if (nr_counted != c->nr_blocks) {
280-
printk(KERN_WARNING "%s counted only 0x%x blocks of 0x%x. Where are the others?\n",
281-
__func__, nr_counted, c->nr_blocks);
284+
pr_warn("%s counted only 0x%x blocks of 0x%x. Where are the others?\n",
285+
__func__, nr_counted, c->nr_blocks);
282286
dump = 1;
283287
}
284288

‎fs/jffs2/dir.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target,
103103
if (ino) {
104104
inode = jffs2_iget(dir_i->i_sb, ino);
105105
if (IS_ERR(inode))
106-
printk(KERN_WARNING "iget() failed for ino #%u\n", ino);
106+
pr_warn("iget() failed for ino #%u\n", ino);
107107
}
108108

109109
return d_splice_alias(inode, target);
@@ -365,7 +365,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
365365
/* We use f->target field to store the target path. */
366366
f->target = kmemdup(target, targetlen + 1, GFP_KERNEL);
367367
if (!f->target) {
368-
printk(KERN_WARNING "Can't allocate %d bytes of memory\n", targetlen + 1);
368+
pr_warn("Can't allocate %d bytes of memory\n", targetlen + 1);
369369
mutex_unlock(&f->sem);
370370
jffs2_complete_reservation(c);
371371
ret = -ENOMEM;
@@ -860,7 +860,8 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
860860
f->inocache->pino_nlink++;
861861
mutex_unlock(&f->sem);
862862

863-
printk(KERN_NOTICE "jffs2_rename(): Link succeeded, unlink failed (err %d). You now have a hard link\n", ret);
863+
pr_notice("%s(): Link succeeded, unlink failed (err %d). You now have a hard link\n",
864+
__func__, ret);
864865
/* Might as well let the VFS know */
865866
d_instantiate(new_dentry, old_dentry->d_inode);
866867
ihold(old_dentry->d_inode);

‎fs/jffs2/erase.c‎

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,
5151
jeb->offset, jeb->offset, jeb->offset + c->sector_size);
5252
instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL);
5353
if (!instr) {
54-
printk(KERN_WARNING "kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n");
54+
pr_warn("kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n");
5555
mutex_lock(&c->erase_free_sem);
5656
spin_lock(&c->erase_completion_lock);
5757
list_move(&jeb->list, &c->erase_pending_list);
@@ -99,9 +99,11 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,
9999
}
100100

101101
if (ret == -EROFS)
102-
printk(KERN_WARNING "Erase at 0x%08x failed immediately: -EROFS. Is the sector locked?\n", jeb->offset);
102+
pr_warn("Erase at 0x%08x failed immediately: -EROFS. Is the sector locked?\n",
103+
jeb->offset);
103104
else
104-
printk(KERN_WARNING "Erase at 0x%08x failed immediately: errno %d\n", jeb->offset, ret);
105+
pr_warn("Erase at 0x%08x failed immediately: errno %d\n",
106+
jeb->offset, ret);
105107

106108
jffs2_erase_failed(c, jeb, bad_offset);
107109
}
@@ -217,7 +219,7 @@ static void jffs2_erase_callback(struct erase_info *instr)
217219
struct erase_priv_struct *priv = (void *)instr->priv;
218220

219221
if(instr->state != MTD_ERASE_DONE) {
220-
printk(KERN_WARNING "Erase at 0x%08llx finished, but state != MTD_ERASE_DONE. State is 0x%x instead.\n",
222+
pr_warn("Erase at 0x%08llx finished, but state != MTD_ERASE_DONE. State is 0x%x instead.\n",
221223
(unsigned long long)instr->addr, instr->state);
222224
jffs2_erase_failed(priv->c, priv->jeb, instr->fail_addr);
223225
} else {
@@ -284,15 +286,15 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c,
284286

285287
printk(KERN_DEBUG);
286288
while(this) {
287-
printk(KERN_CONT "0x%08x(%d)->",
289+
pr_cont("0x%08x(%d)->",
288290
ref_offset(this), ref_flags(this));
289291
if (++i == 5) {
290292
printk(KERN_DEBUG);
291293
i=0;
292294
}
293295
this = this->next_in_ino;
294296
}
295-
printk(KERN_CONT "\n");
297+
pr_cont("\n");
296298
});
297299

298300
switch (ic->class) {
@@ -364,16 +366,19 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
364366
} while(--retlen);
365367
mtd_unpoint(c->mtd, jeb->offset, c->sector_size);
366368
if (retlen) {
367-
printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08tx\n",
368-
*wordebuf, jeb->offset + c->sector_size-retlen*sizeof(*wordebuf));
369+
pr_warn("Newly-erased block contained word 0x%lx at offset 0x%08tx\n",
370+
*wordebuf,
371+
jeb->offset +
372+
c->sector_size-retlen * sizeof(*wordebuf));
369373
return -EIO;
370374
}
371375
return 0;
372376
}
373377
do_flash_read:
374378
ebuf = kmalloc(PAGE_SIZE, GFP_KERNEL);
375379
if (!ebuf) {
376-
printk(KERN_WARNING "Failed to allocate page buffer for verifying erase at 0x%08x. Refiling\n", jeb->offset);
380+
pr_warn("Failed to allocate page buffer for verifying erase at 0x%08x. Refiling\n",
381+
jeb->offset);
377382
return -EAGAIN;
378383
}
379384

@@ -387,12 +392,14 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
387392

388393
ret = mtd_read(c->mtd, ofs, readlen, &retlen, ebuf);
389394
if (ret) {
390-
printk(KERN_WARNING "Read of newly-erased block at 0x%08x failed: %d. Putting on bad_list\n", ofs, ret);
395+
pr_warn("Read of newly-erased block at 0x%08x failed: %d. Putting on bad_list\n",
396+
ofs, ret);
391397
ret = -EIO;
392398
goto fail;
393399
}
394400
if (retlen != readlen) {
395-
printk(KERN_WARNING "Short read from newly-erased block at 0x%08x. Wanted %d, got %zd\n", ofs, readlen, retlen);
401+
pr_warn("Short read from newly-erased block at 0x%08x. Wanted %d, got %zd\n",
402+
ofs, readlen, retlen);
396403
ret = -EIO;
397404
goto fail;
398405
}
@@ -401,7 +408,8 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
401408
unsigned long *datum = ebuf + i;
402409
if (*datum + 1) {
403410
*bad_offset += i;
404-
printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08x\n", *datum, *bad_offset);
411+
pr_warn("Newly-erased block contained word 0x%lx at offset 0x%08x\n",
412+
*datum, *bad_offset);
405413
ret = -EIO;
406414
goto fail;
407415
}
@@ -456,10 +464,10 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
456464

457465
if (ret || retlen != sizeof(marker)) {
458466
if (ret)
459-
printk(KERN_WARNING "Write clean marker to block at 0x%08x failed: %d\n",
467+
pr_warn("Write clean marker to block at 0x%08x failed: %d\n",
460468
jeb->offset, ret);
461469
else
462-
printk(KERN_WARNING "Short write to newly-erased block at 0x%08x: Wanted %zd, got %zd\n",
470+
pr_warn("Short write to newly-erased block at 0x%08x: Wanted %zd, got %zd\n",
463471
jeb->offset, sizeof(marker), retlen);
464472

465473
goto filebad;

‎fs/jffs2/fs.c‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,16 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
320320
/* Read the device numbers from the media */
321321
if (f->metadata->size != sizeof(jdev.old_id) &&
322322
f->metadata->size != sizeof(jdev.new_id)) {
323-
printk(KERN_NOTICE "Device node has strange size %d\n", f->metadata->size);
323+
pr_notice("Device node has strange size %d\n",
324+
f->metadata->size);
324325
goto error_io;
325326
}
326327
jffs2_dbg(1, "Reading device numbers from flash\n");
327328
ret = jffs2_read_dnode(c, f, f->metadata, (char *)&jdev, 0, f->metadata->size);
328329
if (ret < 0) {
329330
/* Eep */
330-
printk(KERN_NOTICE "Read device numbers for inode %lu failed\n", (unsigned long)inode->i_ino);
331+
pr_notice("Read device numbers for inode %lu failed\n",
332+
(unsigned long)inode->i_ino);
331333
goto error;
332334
}
333335
if (f->metadata->size == sizeof(jdev.old_id))
@@ -342,7 +344,8 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
342344
break;
343345

344346
default:
345-
printk(KERN_WARNING "jffs2_read_inode(): Bogus imode %o for ino %lu\n", inode->i_mode, (unsigned long)inode->i_ino);
347+
pr_warn("%s(): Bogus i_mode %o for ino %lu\n",
348+
__func__, inode->i_mode, (unsigned long)inode->i_ino);
346349
}
347350

348351
mutex_unlock(&f->sem);
@@ -510,11 +513,11 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent)
510513

511514
#ifndef CONFIG_JFFS2_FS_WRITEBUFFER
512515
if (c->mtd->type == MTD_NANDFLASH) {
513-
printk(KERN_ERR "jffs2: Cannot operate on NAND flash unless jffs2 NAND support is compiled in.\n");
516+
pr_err("jffs2: Cannot operate on NAND flash unless jffs2 NAND support is compiled in.\n");
514517
return -EINVAL;
515518
}
516519
if (c->mtd->type == MTD_DATAFLASH) {
517-
printk(KERN_ERR "jffs2: Cannot operate on DataFlash unless jffs2 DataFlash support is compiled in.\n");
520+
pr_err("jffs2: Cannot operate on DataFlash unless jffs2 DataFlash support is compiled in.\n");
518521
return -EINVAL;
519522
}
520523
#endif
@@ -528,12 +531,13 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent)
528531
*/
529532
if ((c->sector_size * blocks) != c->flash_size) {
530533
c->flash_size = c->sector_size * blocks;
531-
printk(KERN_INFO "jffs2: Flash size not aligned to erasesize, reducing to %dKiB\n",
534+
pr_info("jffs2: Flash size not aligned to erasesize, reducing to %dKiB\n",
532535
c->flash_size / 1024);
533536
}
534537

535538
if (c->flash_size < 5*c->sector_size) {
536-
printk(KERN_ERR "jffs2: Too few erase blocks (%d)\n", c->flash_size / c->sector_size);
539+
pr_err("jffs2: Too few erase blocks (%d)\n",
540+
c->flash_size / c->sector_size);
537541
return -EINVAL;
538542
}
539543

@@ -658,8 +662,8 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c,
658662
return ERR_CAST(inode);
659663
}
660664
if (is_bad_inode(inode)) {
661-
printk(KERN_NOTICE "Eep. read_inode() failed for ino #%u. unlinked %d\n",
662-
inum, unlinked);
665+
pr_notice("Eep. read_inode() failed for ino #%u. unlinked %d\n",
666+
inum, unlinked);
663667
/* NB. This will happen again. We need to do something appropriate here. */
664668
iput(inode);
665669
return ERR_PTR(-EIO);

0 commit comments

Comments
 (0)