[PATCH 4/9] mm/damon/dbgfs: make debugfs interface deprecation message a macro

From: SeongJae Park
Date: Mon Jan 29 2024 - 20:36:36 EST


DAMON debugfs interface deprecation message is written twice, once for
the warning, and again for DEPRECATED file's read output. De-duplicate
those by defining the message as a macro and reuse.

Signed-off-by: SeongJae Park <sj@xxxxxxxxxx>
---
mm/damon/dbgfs.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c
index fc6ece5a9f37..fbc0cd63f34c 100644
--- a/mm/damon/dbgfs.c
+++ b/mm/damon/dbgfs.c
@@ -15,6 +15,11 @@
#include <linux/page_idle.h>
#include <linux/slab.h>

+#define DAMON_DBGFS_DEPRECATION_NOTICE \
+ "DAMON debugfs interface is deprecated, so users should move " \
+ "to DAMON_SYSFS. If you cannot, please report your usecase to " \
+ "damon@xxxxxxxxxxxxxxx and linux-mm@xxxxxxxxx.\n"
+
static struct damon_ctx **dbgfs_ctxs;
static int dbgfs_nr_ctxs;
static struct dentry **dbgfs_dirs;
@@ -22,10 +27,7 @@ static DEFINE_MUTEX(damon_dbgfs_lock);

static void damon_dbgfs_warn_deprecation(void)
{
- pr_warn_once("DAMON debugfs interface is deprecated, "
- "so users should move to DAMON_SYSFS. If you cannot, "
- "please report your usecase to damon@xxxxxxxxxxxxxxx and "
- "linux-mm@xxxxxxxxx.\n");
+ pr_warn_once(DAMON_DBGFS_DEPRECATION_NOTICE);
}

/*
@@ -808,10 +810,7 @@ static void dbgfs_destroy_ctx(struct damon_ctx *ctx)
static ssize_t damon_dbgfs_deprecated_read(struct file *file,
char __user *buf, size_t count, loff_t *ppos)
{
- char kbuf[512] = "DAMON debugfs interface is deprecated, "
- "so users should move to DAMON_SYSFS. If you cannot, "
- "please report your usecase to damon@xxxxxxxxxxxxxxx and "
- "linux-mm@xxxxxxxxx.\n";
+ char kbuf[512] = DAMON_DBGFS_DEPRECATION_NOTICE;
int len = strnlen(kbuf, 1024);

return simple_read_from_buffer(buf, count, ppos, kbuf, len);
--
2.39.2