Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2337817ybt; Fri, 3 Jul 2020 06:51:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIn5S0S9QlYrQ4zbjBYp2IQQv9HK/6zZBRuY9+eiBv+rDtLqHfulk1yaL4fjTizm4c6RQg X-Received: by 2002:aa7:c450:: with SMTP id n16mr36447646edr.53.1593784279023; Fri, 03 Jul 2020 06:51:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593784279; cv=none; d=google.com; s=arc-20160816; b=gXfgGcx9hZXaI6wr4FCUAmhVZRrxwRyUXYCDfNbwO+ic1BfGo7NefJ/10CmfjtCzRp pbwh1ApUsOiNjar0bVUj8ujyn3Wbd7SQcTbjZyfsQm5C/rr3zLRVydKxVCT2vz1S858E T9Pa4bJuo8NiSAv7zp0/lMAmMaICFdkAMwlrbpMOdKzPzu69lpGsTgKiCqOiOL4v1bTJ jyxMvJfMzrcDM2pRFHZxw+CCu4zFqw4G/6eDChUU/3THFAhPNJHL8+C2Wi0pUHvA6F3B 3CnXG2qMr/wl1IGkL7SQ3WIUmKUnxifmasA1TxT3K6l/sE7/trOKnRa7xHIUlTGP69xk SoWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=bAPejRA1W3IqlgS2BYNuEBV6nvMf5CKuMxnnqrhkzQU=; b=ln0gq+szYFYMJ66t7fN9UEY3t+co5nMYxqxG419fxK829SOeu5A7hWJ2iWmZJ9jVK9 JBlQL2asuRgtYaRRlvolxMoXzskrBLPs9uGMcyYwPr3093TYJuCuWZFWU7qhnRPjZv2T r7ovbwfTiZh/Q8qTLjLU+rJshxodGKNPJ5fpl9PYcpckd6Ko5Qqt3wTTDEEDOZlvu3Pr 7FDIOCE8/OM9GC8h5hdDAq1asni0vLrLJROd+XLRYDQmncv5qYYZbSmX03ytAj4GYg9M Vh7nzH90RyINZb91Q0/F34oJC7XUOQyMMJunyPLv0Th9C+9eqx15jRfyq1dKdNzTUNKv 0kNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id be11si5728098edb.482.2020.07.03.06.50.55; Fri, 03 Jul 2020 06:51:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726140AbgGCNtp (ORCPT + 99 others); Fri, 3 Jul 2020 09:49:45 -0400 Received: from mx3.molgen.mpg.de ([141.14.17.11]:57467 "EHLO mx1.molgen.mpg.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726035AbgGCNtp (ORCPT ); Fri, 3 Jul 2020 09:49:45 -0400 Received: from hopp.molgen.mpg.de (hopp.molgen.mpg.de [141.14.25.186]) by mx.molgen.mpg.de (Postfix) with ESMTP id 9D27E20646DD8; Fri, 3 Jul 2020 15:49:42 +0200 (CEST) From: Paul Menzel To: Linus Torvalds , =?UTF-8?q?Christian=20K=C3=B6nig?= Cc: Paul Menzel , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org Subject: [PATCH v2 1/2] moduleparams: Add hexint type parameter Date: Fri, 3 Jul 2020 15:49:39 +0200 Message-Id: <20200703134940.27054-1-pmenzel@molgen.mpg.de> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); int param_set_charp(const char *val, const struct kernel_param *kp) { -- 2.26.2