From: Paul Menzel <pmenzel@molgen.mpg.de>
To: "Linus Torvalds" <torvalds@linux-foundation.org>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>
Cc: Paul Menzel <pmenzel@molgen.mpg.de>,
linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org
Subject: [PATCH 1/2] moduleparams: Add hex type parameter
Date: Thu, 2 Jul 2020 16:01:01 +0200 [thread overview]
Message-ID: <20200702140102.26129-1-pmenzel@molgen.mpg.de> (raw)
For bitmasks printing values in hex is more convenient.
Prefix with 0x (#) to make it clear, that it’s a hex value.
Using the helper for `amdgpu.ppfeaturemask`, it will look like below.
Before:
$ more /sys/module/amdgpu/parameters/ppfeaturemask
4294950911
After:
$ more /sys/module/amdgpu/parameters/ppfeaturemask
0xffffbfff
Cc: linux-kernel@vger.kernel.org
Cc: amd-gfx@lists.freedesktop.org
Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
---
include/linux/moduleparam.h | 7 ++++++-
kernel/params.c | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 3ef917ff0964..408978fcfe27 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -118,7 +118,7 @@ struct kparam_array
* you can create your own by defining those variables.
*
* Standard types are:
- * byte, short, ushort, int, uint, long, ulong
+ * byte, hex, short, ushort, int, uint, long, ulong
* charp: a character pointer
* bool: a bool, values 0/1, y/n, Y/N.
* invbool: the above, only sense-reversed (N = true).
@@ -448,6 +448,11 @@ extern int param_set_ullong(const char *val, const struct kernel_param *kp);
extern int param_get_ullong(char *buffer, const struct kernel_param *kp);
#define param_check_ullong(name, p) __param_check(name, p, unsigned long long)
+extern const struct kernel_param_ops param_ops_hex;
+extern int param_set_hex(const char *val, const struct kernel_param *kp);
+extern int param_get_hex(char *buffer, const struct kernel_param *kp);
+#define param_check_hex(name, p) param_check_uint(name, p)
+
extern const struct kernel_param_ops param_ops_charp;
extern int param_set_charp(const char *val, const struct kernel_param *kp);
extern int param_get_charp(char *buffer, const struct kernel_param *kp);
diff --git a/kernel/params.c b/kernel/params.c
index 8e56f8b12d8f..ceca8394dac5 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -241,6 +241,7 @@ STANDARD_PARAM_DEF(uint, unsigned int, "%u", kstrtouint);
STANDARD_PARAM_DEF(long, long, "%li", kstrtol);
STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", kstrtoul);
STANDARD_PARAM_DEF(ullong, unsigned long long, "%llu", kstrtoull);
+STANDARD_PARAM_DEF(hex, unsigned int, "%#x", kstrtouint);
int param_set_charp(const char *val, const struct kernel_param *kp)
{
--
2.26.2
next reply other threads:[~2020-07-02 14:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 14:01 Paul Menzel [this message]
2020-07-02 14:01 ` [PATCH 2/2] drm/amdgpu: Change type of module param `ppfeaturemask` to hex Paul Menzel
2020-07-02 14:42 ` [PATCH 1/2] moduleparams: Add hex type parameter Christian König
2020-07-02 19:42 ` Linus Torvalds
2020-07-03 13:52 ` Paul Menzel
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=20200702140102.26129-1-pmenzel@molgen.mpg.de \
--to=pmenzel@molgen.mpg.de \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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®