mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Paul Menzel <pmenzel@molgen.mpg.de>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 1/2] moduleparams: Add hexint type parameter
Date: Fri, 3 Jul 2020 15:52:35 +0200	[thread overview]
Message-ID: <73fce393-45a5-180e-307a-4f399a31c858@amd.com> (raw)
In-Reply-To: <20200703134940.27054-1-pmenzel@molgen.mpg.de>

Am 03.07.20 um 15:49 schrieb Paul Menzel:
> 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>
> ---
> v2: Address review comments: Rename hex to hexint, and pad sizes
>
>   include/linux/moduleparam.h |  7 ++++++-
>   kernel/params.c             | 17 +++++++++--------
>   2 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
> index 3ef917ff0964..cff7261e98bb 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, hexint, 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_hexint;
> +extern int param_set_hexint(const char *val, const struct kernel_param *kp);
> +extern int param_get_hexint(char *buffer, const struct kernel_param *kp);
> +#define param_check_hexint(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..487261eb836f 100644
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -233,14 +233,15 @@ char *parse_args(const char *doing,
>   	EXPORT_SYMBOL(param_ops_##name)
>   
>   
> -STANDARD_PARAM_DEF(byte,	unsigned char,		"%hhu", kstrtou8);
> -STANDARD_PARAM_DEF(short,	short,			"%hi",  kstrtos16);
> -STANDARD_PARAM_DEF(ushort,	unsigned short,		"%hu",  kstrtou16);
> -STANDARD_PARAM_DEF(int,		int,			"%i",   kstrtoint);
> -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(byte,	unsigned char,		"%hhu",  kstrtou8);
> +STANDARD_PARAM_DEF(short,	short,			"%hi",   kstrtos16);
> +STANDARD_PARAM_DEF(ushort,	unsigned short,		"%hu",   kstrtou16);
> +STANDARD_PARAM_DEF(int,		int,			"%i",    kstrtoint);
> +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(hexint,	unsigned int,		"%#08x", kstrtouint);

All other indentations uses tabs, only the last one seems to use a 
space. If you touch this, then maybe make it consistent as well.

Apart from that looks good to me,
Christian.

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


      parent reply	other threads:[~2020-07-03 13:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-03 13:49 Paul Menzel
2020-07-03 13:49 ` [PATCH v2 2/2] drm/amdgpu: Change type of module param `ppfeaturemask` to hexint Paul Menzel
2020-07-03 13:52 ` Christian König [this message]

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=73fce393-45a5-180e-307a-4f399a31c858@amd.com \
    --to=christian.koenig@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmenzel@molgen.mpg.de \
    --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®