Skip to content

Commit 90655ee

Browse files
Gou Haohsiangkao
authored andcommitted
erofs: simplify definition of the log functions
Use printk instead of pr_info/err to reduce redundant code. Signed-off-by: Gou Hao <[email protected]> Reviewed-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Gao Xiang <[email protected]>
1 parent db80b98 commit 90655ee

File tree

2 files changed

+11
-32
lines changed

2 files changed

+11
-32
lines changed

fs/erofs/internal.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,12 @@
2020
#include <linux/iomap.h>
2121
#include "erofs_fs.h"
2222

23-
/* redefine pr_fmt "erofs: " */
24-
#undef pr_fmt
25-
#define pr_fmt(fmt) "erofs: " fmt
26-
27-
__printf(3, 4) void _erofs_err(struct super_block *sb,
28-
const char *function, const char *fmt, ...);
23+
__printf(2, 3) void _erofs_printk(struct super_block *sb, const char *fmt, ...);
2924
#define erofs_err(sb, fmt, ...) \
30-
_erofs_err(sb, __func__, fmt "\n", ##__VA_ARGS__)
31-
__printf(3, 4) void _erofs_info(struct super_block *sb,
32-
const char *function, const char *fmt, ...);
25+
_erofs_printk(sb, KERN_ERR fmt "\n", ##__VA_ARGS__)
3326
#define erofs_info(sb, fmt, ...) \
34-
_erofs_info(sb, __func__, fmt "\n", ##__VA_ARGS__)
27+
_erofs_printk(sb, KERN_INFO fmt "\n", ##__VA_ARGS__)
28+
3529
#ifdef CONFIG_EROFS_FS_DEBUG
3630
#define DBG_BUGON BUG_ON
3731
#else

fs/erofs/super.c

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,22 @@
1818

1919
static struct kmem_cache *erofs_inode_cachep __read_mostly;
2020

21-
void _erofs_err(struct super_block *sb, const char *func, const char *fmt, ...)
21+
void _erofs_printk(struct super_block *sb, const char *fmt, ...)
2222
{
2323
struct va_format vaf;
2424
va_list args;
25+
int level;
2526

2627
va_start(args, fmt);
2728

28-
vaf.fmt = fmt;
29+
level = printk_get_level(fmt);
30+
vaf.fmt = printk_skip_level(fmt);
2931
vaf.va = &args;
30-
31-
if (sb)
32-
pr_err("(device %s): %s: %pV", sb->s_id, func, &vaf);
33-
else
34-
pr_err("%s: %pV", func, &vaf);
35-
va_end(args);
36-
}
37-
38-
void _erofs_info(struct super_block *sb, const char *func, const char *fmt, ...)
39-
{
40-
struct va_format vaf;
41-
va_list args;
42-
43-
va_start(args, fmt);
44-
45-
vaf.fmt = fmt;
46-
vaf.va = &args;
47-
4832
if (sb)
49-
pr_info("(device %s): %pV", sb->s_id, &vaf);
33+
printk("%c%cerofs (device %s): %pV",
34+
KERN_SOH_ASCII, level, sb->s_id, &vaf);
5035
else
51-
pr_info("%pV", &vaf);
36+
printk("%c%cerofs: %pV", KERN_SOH_ASCII, level, &vaf);
5237
va_end(args);
5338
}
5439

0 commit comments

Comments
 (0)