From: Gou Hao <gouhao@uniontech.com>
To: xiang@kernel.org, chao@kernel.org
Cc: linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org,
gouhaojake@163.com
Subject: [PATCH] erofs: simplify definition of the log functions
Date: Fri, 18 Oct 2024 11:35:00 +0800 [thread overview]
Message-ID: <20241018033500.13833-1-gouhao@uniontech.com> (raw)
using printk instead of pr_info/err, reduce
redundant code.
Signed-off-by: Gou Hao <gouhao@uniontech.com>
---
fs/erofs/internal.h | 9 ++++-----
fs/erofs/super.c | 28 +++++++---------------------
2 files changed, 11 insertions(+), 26 deletions(-)
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 4efd578d7c62..ae87e855e815 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -24,14 +24,13 @@
#undef pr_fmt
#define pr_fmt(fmt) "erofs: " fmt
-__printf(3, 4) void _erofs_err(struct super_block *sb,
+__printf(3, 4) void _erofs_printk(struct super_block *sb,
const char *function, 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, __func__, KERN_ERR fmt "\n", ##__VA_ARGS__)
#define erofs_info(sb, fmt, ...) \
- _erofs_info(sb, __func__, fmt "\n", ##__VA_ARGS__)
+ _erofs_printk(sb, __func__, KERN_INFO fmt "\n", ##__VA_ARGS__)
+
#ifdef CONFIG_EROFS_FS_DEBUG
#define DBG_BUGON BUG_ON
#else
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 666873f745da..64c3258ddf9a 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -18,37 +18,23 @@
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 *func, 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);
+ printk("%c%c(device %s): %s: %pV",
+ KERN_SOH_ASCII, level, 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);
- else
- pr_info("%pV", &vaf);
+ printk("%c%c%s: %pV", KERN_SOH_ASCII, level, func, &vaf);
va_end(args);
}
--
2.43.0
next reply other threads:[~2024-10-18 3:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-18 3:35 Gou Hao [this message]
2024-11-13 3:42 ` Gao Xiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241018033500.13833-1-gouhao@uniontech.com \
--to=gouhao@uniontech.com \
--cc=chao@kernel.org \
--cc=gouhaojake@163.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®