From 0d2005c28d581fe8f07af3577015baf9c1da6e1b Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 29 Jul 2022 17:24:47 +0900 Subject: [PATCH] exfat: Expand exfat_err() and co directly to pr_*() macro Currently the error and info messages handled by exfat_err() and co are tossed to exfat_msg() function that does nothing but passes the strings with printk() invocation. Not only that this is more overhead by the indirect calls, but also this makes harder to extend for the debug print usage; because of the direct printk() call, you cannot make it for dynamic debug or without debug like the standard helpers such as pr_debug() or dev_dbg(). For addressing the problem, this patch replaces exfat_*() macro to expand to pr_*() directly. Along with it, add the new exfat_debug() macro that is expanded to pr_debug() (which output can be gracefully suppressed via dyndbg). Reviewed-by: Petr Vorel Signed-off-by: Takashi Iwai Signed-off-by: Namjae Jeon --- exfat_fs.h | 12 +++++++----- misc.c | 17 ----------------- super.c | 8 ++++---- 3 files changed, 11 insertions(+), 26 deletions(-) diff --git a/exfat_fs.h b/exfat_fs.h index 90d42a24f3e1..f3b001c2349d 100644 --- a/exfat_fs.h +++ b/exfat_fs.h @@ -541,14 +541,16 @@ void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...) #define exfat_fs_error_ratelimit(sb, fmt, args...) \ __exfat_fs_error(sb, __ratelimit(&EXFAT_SB(sb)->ratelimit), \ fmt, ## args) -void exfat_msg(struct super_block *sb, const char *lv, const char *fmt, ...) - __printf(3, 4) __cold; + +/* expand to pr_*() with prefix */ #define exfat_err(sb, fmt, ...) \ - exfat_msg(sb, KERN_ERR, fmt, ##__VA_ARGS__) + pr_err("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__) #define exfat_warn(sb, fmt, ...) \ - exfat_msg(sb, KERN_WARNING, fmt, ##__VA_ARGS__) + pr_warn("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__) #define exfat_info(sb, fmt, ...) \ - exfat_msg(sb, KERN_INFO, fmt, ##__VA_ARGS__) + pr_info("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__) +#define exfat_debug(sb, fmt, ...) \ + pr_debug("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__) #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts, diff --git a/misc.c b/misc.c index 1b75c8b97f7d..e7ae6f629d6e 100644 --- a/misc.c +++ b/misc.c @@ -52,23 +52,6 @@ void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...) } } -/* - * exfat_msg() - print preformated EXFAT specific messages. - * All logs except what uses exfat_fs_error() should be written by exfat_msg() - */ -void exfat_msg(struct super_block *sb, const char *level, const char *fmt, ...) -{ - struct va_format vaf; - va_list args; - - va_start(args, fmt); - vaf.fmt = fmt; - vaf.va = &args; - /* level means KERN_ pacility level */ - printk("%sexFAT-fs (%s): %pV\n", level, sb->s_id, &vaf); - va_end(args); -} - #define SECS_PER_MIN (60) #define TIMEZONE_SEC(x) ((x) * 15 * SECS_PER_MIN) diff --git a/super.c b/super.c index cd6a54d0cab4..f8bce05d2b33 100644 --- a/super.c +++ b/super.c @@ -547,9 +547,9 @@ static int parse_options(struct super_block *sb, char *options, int silent, break; default: if (!silent) { - exfat_msg(sb, KERN_ERR, - "unrecognized mount option \"%s\" or missing value", - p); + exfat_err(sb, + "unrecognized mount option \"%s\" or missing value", + p); } return -EINVAL; } @@ -938,7 +938,7 @@ static int exfat_fill_super(struct super_block *sb, void *data, int silent) DEFAULT_RATELIMIT_BURST); err = parse_options(sb, data, silent, &sbi->options); if (err) { - exfat_msg(sb, KERN_ERR, "failed to parse options"); + exfat_err(sb, "failed to parse options"); goto check_nls_io; } #endif