Skip to content

Commit 7d83657

Browse files
paulmenzelChristianKoenigAMD
authored andcommitted
moduleparams: Add hexint type parameter
For bitmasks printing values in hex is more convenient. Prefix with `0x` to make it clear, that it’s a hex value, and pad it out. 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> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Christian König <christian.koenig@amd.com> Link: https://patchwork.freedesktop.org/patch/374726/
1 parent 31ed1b5 commit 7d83657

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

‎include/linux/moduleparam.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ struct kparam_array
118118
* you can create your own by defining those variables.
119119
*
120120
* Standard types are:
121-
* byte, short, ushort, int, uint, long, ulong
121+
* byte, hexint, short, ushort, int, uint, long, ulong
122122
* charp: a character pointer
123123
* bool: a bool, values 0/1, y/n, Y/N.
124124
* 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);
448448
extern int param_get_ullong(char *buffer, const struct kernel_param *kp);
449449
#define param_check_ullong(name, p) __param_check(name, p, unsigned long long)
450450

451+
extern const struct kernel_param_ops param_ops_hexint;
452+
extern int param_set_hexint(const char *val, const struct kernel_param *kp);
453+
extern int param_get_hexint(char *buffer, const struct kernel_param *kp);
454+
#define param_check_hexint(name, p) param_check_uint(name, p)
455+
451456
extern const struct kernel_param_ops param_ops_charp;
452457
extern int param_set_charp(const char *val, const struct kernel_param *kp);
453458
extern int param_get_charp(char *buffer, const struct kernel_param *kp);

‎kernel/params.c‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,15 @@ char *parse_args(const char *doing,
233233
EXPORT_SYMBOL(param_ops_##name)
234234

235235

236-
STANDARD_PARAM_DEF(byte, unsigned char, "%hhu", kstrtou8);
237-
STANDARD_PARAM_DEF(short, short, "%hi", kstrtos16);
238-
STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", kstrtou16);
239-
STANDARD_PARAM_DEF(int, int, "%i", kstrtoint);
240-
STANDARD_PARAM_DEF(uint, unsigned int, "%u", kstrtouint);
241-
STANDARD_PARAM_DEF(long, long, "%li", kstrtol);
242-
STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", kstrtoul);
243-
STANDARD_PARAM_DEF(ullong, unsigned long long, "%llu", kstrtoull);
236+
STANDARD_PARAM_DEF(byte, unsigned char, "%hhu", kstrtou8);
237+
STANDARD_PARAM_DEF(short, short, "%hi", kstrtos16);
238+
STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", kstrtou16);
239+
STANDARD_PARAM_DEF(int, int, "%i", kstrtoint);
240+
STANDARD_PARAM_DEF(uint, unsigned int, "%u", kstrtouint);
241+
STANDARD_PARAM_DEF(long, long, "%li", kstrtol);
242+
STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", kstrtoul);
243+
STANDARD_PARAM_DEF(ullong, unsigned long long, "%llu", kstrtoull);
244+
STANDARD_PARAM_DEF(hexint, unsigned int, "%#08x", kstrtouint);
244245

245246
int param_set_charp(const char *val, const struct kernel_param *kp)
246247
{

0 commit comments

Comments
 (0)