]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
erofs: simplify definition of the log functions
authorGou Hao <gouhao@uniontech.com>
Thu, 14 Nov 2024 01:32:47 +0000 (09:32 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Mon, 18 Nov 2024 10:50:13 +0000 (18:50 +0800)
Use printk instead of pr_info/err to reduce
redundant code.

Signed-off-by: Gou Hao <gouhao@uniontech.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20241114013247.30821-1-gouhao@uniontech.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
fs/erofs/internal.h
fs/erofs/super.c

index 0328e6b98c1b6f2c2f9881b1ed1b606581b6d26c..9aa4cb3d0b65d9560b982672712be9b270f671bc 100644 (file)
 #include <linux/iomap.h>
 #include "erofs_fs.h"
 
-/* redefine pr_fmt "erofs: " */
-#undef pr_fmt
-#define pr_fmt(fmt) "erofs: " fmt
-
-__printf(3, 4) void _erofs_err(struct super_block *sb,
-                              const char *function, const char *fmt, ...);
+__printf(2, 3) void _erofs_printk(struct super_block *sb, const char *fmt, ...);
 #define erofs_err(sb, fmt, ...)        \
-       _erofs_err(sb, __func__, fmt "\n", ##__VA_ARGS__)
-__printf(3, 4) void _erofs_info(struct super_block *sb,
-                              const char *function, const char *fmt, ...);
+       _erofs_printk(sb, KERN_ERR fmt "\n", ##__VA_ARGS__)
 #define erofs_info(sb, fmt, ...) \
-       _erofs_info(sb, __func__, fmt "\n", ##__VA_ARGS__)
+       _erofs_printk(sb, KERN_INFO fmt "\n", ##__VA_ARGS__)
+
 #ifdef CONFIG_EROFS_FS_DEBUG
 #define DBG_BUGON               BUG_ON
 #else
index bed3dbe5b7cb8bbc21dcceed4c6978e9f0940028..961ee47e2b4d8c294927153993ecde4504624ca3 100644 (file)
 
 static struct kmem_cache *erofs_inode_cachep __read_mostly;
 
-void _erofs_err(struct super_block *sb, const char *func, const char *fmt, ...)
+void _erofs_printk(struct super_block *sb, const char *fmt, ...)
 {
        struct va_format vaf;
        va_list args;
+       int level;
 
        va_start(args, fmt);
 
-       vaf.fmt = fmt;
+       level = printk_get_level(fmt);
+       vaf.fmt = printk_skip_level(fmt);
        vaf.va = &args;
-
-       if (sb)
-               pr_err("(device %s): %s: %pV", sb->s_id, func, &vaf);
-       else
-               pr_err("%s: %pV", func, &vaf);
-       va_end(args);
-}
-
-void _erofs_info(struct super_block *sb, const char *func, const char *fmt, ...)
-{
-       struct va_format vaf;
-       va_list args;
-
-       va_start(args, fmt);
-
-       vaf.fmt = fmt;
-       vaf.va = &args;
-
        if (sb)
-               pr_info("(device %s): %pV", sb->s_id, &vaf);
+               printk("%c%cerofs (device %s): %pV",
+                               KERN_SOH_ASCII, level, sb->s_id, &vaf);
        else
-               pr_info("%pV", &vaf);
+               printk("%c%cerofs: %pV", KERN_SOH_ASCII, level, &vaf);
        va_end(args);
 }