Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1497506ybt; Thu, 2 Jul 2020 07:02:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLhHkParHn8GnP/sRFhNxGJH+8dJRkgbiCHmVKVTiukMDkSIF/v0cjfiuKFmRgwrEsNM4O X-Received: by 2002:a17:906:6a4f:: with SMTP id n15mr27117264ejs.378.1593698524412; Thu, 02 Jul 2020 07:02:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593698524; cv=none; d=google.com; s=arc-20160816; b=mDWcY5a0bmphYLvc+0ZU4ZSU2Hzz18BY8/GNWUKRnTueFGtRuWDIjTzp9t5a9RETTZ GkG94T0uFRITkxC9qHR/UU3ToTUFBu24PaC4GDNRVQvzC9bBmfP8ZIlGqzZsscrbIQeE bWUngWSWSE6upINjw90xQSUcpklS33GLhkEU8nnh5hV7Fhhn46srm85LIfGzmstMdfbj Y//T/tYbYK43CV10uACLxG/bLA/LJTuForlV6Z+F9H3SchXEpOna3OwHbij2Rac/u4Ys sFFPWqTjPHm/HbXHuc5h+BRkJHzm6OdgX3kave0Z79NuB61d6LPWemE7YI8BwcgeShHp 4SLg== 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=VwgCYgbh+TmQuWs4qyX0nOgwptX5p3uLLmWFssR5TOA=; b=sP5SBAPB2s5vr/mn155RCIrnoZwyxMKr2wqBFVVJHUcdHlODzAMJ45qf1Zh7JhyUjO c7x/VrBgncWxIEZTZ4QVv2QKbNJvkEz9tMlebeWwwAt1NUIgovjYFjoAnTxmpRRst36v wdsBkatTmCqVB5nFRYCuTSiIu1zQxauGfv0Y9Ol8MoXbSJ+e0tls3J5zwM4rTB54ujJu u3Sna35ajldMK1xRZSnWVo5R5DmVVRxLAF7LDq6OFJ9uGlC2b/xi5tOMd/E6I5pBaEOm Xggo1hE3m+mRHe05CUgfNc3QhdHEu5hLX2hIVkfBESRkoFLfYcGdQTj93TdnA6fEX4XE Q9qg== 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 y7si6020158edm.24.2020.07.02.07.01.29; Thu, 02 Jul 2020 07:02:04 -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 S1729365AbgGBOBO (ORCPT + 99 others); Thu, 2 Jul 2020 10:01:14 -0400 Received: from mx3.molgen.mpg.de ([141.14.17.11]:42883 "EHLO mx1.molgen.mpg.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726343AbgGBOBN (ORCPT ); Thu, 2 Jul 2020 10:01:13 -0400 Received: from hopp.molgen.mpg.de (hopp.molgen.mpg.de [141.14.25.186]) by mx.molgen.mpg.de (Postfix) with ESMTP id A3423206442DE; Thu, 2 Jul 2020 16:01:11 +0200 (CEST) From: Paul Menzel To: Linus Torvalds , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= Cc: Paul Menzel , 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 Message-Id: <20200702140102.26129-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. 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 | 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