Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2367384ybt; Fri, 3 Jul 2020 07:30:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxWtQNNqTKbB54eMLGLMLj2lahZ3flLisulxr3rVusf6TfajcCDffiQ0nckMK9R17o3OS9 X-Received: by 2002:a17:906:9716:: with SMTP id k22mr13501512ejx.200.1593786615309; Fri, 03 Jul 2020 07:30:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593786615; cv=none; d=google.com; s=arc-20160816; b=nyUGBlcdBPk6EQvastrtffOoypX1dkm3kO4dXhBEY065gbkM9e4zmZ0v7sHvNcDl9v NnZBSQFi3KDeAWTzwvTdDnQpbTjMpuzC1uadL5n+IXiSelOrGPoCl3WJtelwAMzcc+9N KZunS+AtmDcJzfAaRItbvXc0bzhGrveb8AHQ5P+Wdc4nknHsKT2r2YQ48SOFVqKdJaQz HoL6xISkQ6kTEhYMWP+ol/cYKPWZI76PHrAHXUiErueiNK/QFtYUy3/ifGK9Zzavu5NB XKww2LWdt+54fU5WOKvvImRRBlwwKbxTxdp6UclVRkE9UUHVx1uRZ6xrj2MPp8e8WS3N Znfw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=pemyvQzANbvB9WgwUOMY1JMJwQVAxXilV1Ovjq+wPTE=; b=UBK2D5s5kFHWROWMjVrgL13PS1QNoFcRYsqDMgnk4xcUKuq4GDpsiTcqH2a41rJfCE SxTsDU1Rj2IgQNwHpBQuuQBf+5kzBEFmcx6DlYm4L7tMIEvxOHDYQTU0+STt03FZTCHG bEwonBwwMexeMeSk/tY4hIV2/BiKYx7SYGfxpyOY99BaVhDzrEl0HHNSR/6n6eGKoYDD uT/A9a2zW1SRYLmGc+iyxlwTohqES6i6yxfRXylGSAqqcVcwNVe/X9+dIb+5Or6bmRxE 9b2Op87kpftiNR/hN40y4fAZvnivwWskoDpDOIcJqeQKK4s19sNTUufFss85TOcmPFQ2 uZnQ== 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 u17si7640432edy.254.2020.07.03.07.29.52; Fri, 03 Jul 2020 07:30:15 -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 S1726474AbgGCO3o (ORCPT + 99 others); Fri, 3 Jul 2020 10:29:44 -0400 Received: from mx3.molgen.mpg.de ([141.14.17.11]:39343 "EHLO mx1.molgen.mpg.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726048AbgGCO3n (ORCPT ); Fri, 3 Jul 2020 10:29:43 -0400 Received: from hopp.molgen.mpg.de (hopp.molgen.mpg.de [141.14.25.186]) by mx.molgen.mpg.de (Postfix) with ESMTP id ABAB0206442E7; Fri, 3 Jul 2020 16:29:41 +0200 (CEST) From: Paul Menzel To: Linus Torvalds , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher Cc: Paul Menzel , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org Subject: [PATCH v3 2/3] moduleparams: Add hexint type parameter Date: Fri, 3 Jul 2020 16:29:38 +0200 Message-Id: <20200703142939.28663-2-pmenzel@molgen.mpg.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200703142939.28663-1-pmenzel@molgen.mpg.de> References: <20200703142939.28663-1-pmenzel@molgen.mpg.de> 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 --- 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 111eee82b999..3835fb82c64b 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