Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp887976pxb; Fri, 13 Aug 2021 08:28:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7dnQd190aVYTBsvNMNR+dacSGakVfTt9l+WI/u8FS4IGQ0ge8MJIBcyzcyTYg9ZUOna3R X-Received: by 2002:aa7:dc02:: with SMTP id b2mr3748133edu.46.1628868511455; Fri, 13 Aug 2021 08:28:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628868511; cv=none; d=google.com; s=arc-20160816; b=Orl+atwZVglF0vaNvbtvPUzK00KPEInY127H3n5DnPFTwf4RfrCpzQEpVLKJgg5Fe6 OoBmr4vFrpWdQRpQ2KMrRfDdyLDIxmvZR21ugqjRgpOlBIEkEy6Ih30Fow1E3qsPcxCK 3HItC9cCkr03pyMvIBrGBJQxVY3iEPPlVftXHyQGpNoCcZ5K1+pMPgzruzqGViUeY9zd AuPzP+08PLCmqq/9oFqabHhfwiqxBxuYbJhBj2LC2JWU8yA/OZdrpotwqht2waO3K2h5 5viL0zk9riguy2ux6NLn4bvV1eckC74mLZfgiTZaAFMljIhQRlNzriha30/u1ZrY4t99 xChA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=y3NByVIzuR3Rg/aPLIKVF1n0drDE97HGQ1NdBQG6G8o=; b=vlt9L3uGxb5G3VtsGrbRSdjYgclAjAhxP5pxOmIZW78PrOzTMUN1XGPMODPmL75ZGt SkufOd4jB8s1GDYuvucVT5aLvHcJAUgiKnXw0bwDNWVq91lj7cRm33UJweE6UDMyJWZ2 99l3t9IqWPy8JM/3Sr5+4AdOaKI83+Wyw9AP47S4+THML9Ik+E5LIJLBR+dGiogQbhk6 Pm024pgCpXBQxyG86zma+mQBj4TaoygGeH3i0wAA2G7EvL7svn7ZuFHEYDiKFmG01ZQo mMp/eFJ804uDkdDXywJic9Fa2gC2YA4kUjqL+ifDVKszrJv82MCkNOyRpfiUKefcmXlr bD5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QnpkQH2H; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v12si1872567eds.540.2021.08.13.08.28.07; Fri, 13 Aug 2021 08:28:31 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QnpkQH2H; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242573AbhHMP0M (ORCPT + 99 others); Fri, 13 Aug 2021 11:26:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243471AbhHMPYZ (ORCPT ); Fri, 13 Aug 2021 11:24:25 -0400 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B522C0258D6 for ; Fri, 13 Aug 2021 08:18:44 -0700 (PDT) Received: by mail-il1-x12f.google.com with SMTP id v16so430948ilo.10 for ; Fri, 13 Aug 2021 08:18:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=y3NByVIzuR3Rg/aPLIKVF1n0drDE97HGQ1NdBQG6G8o=; b=QnpkQH2HVm3ojYjzdiaaChBK+Emp8SfXFNRUbvXdbvrp78tb/00b1DQhs7B7tZTZhH BRp7vLkfbTBajWqS8jLdZfKMk2ScXlSjh5ecWh4jeqANdgxBVMzwUr/rRL4tyanLlCZ4 Tip74R9NTZ/HieXKcZU6WmEeFZNBWhphySMvkzJcRdMhA9w27jGqAjk4W4XTbTz68xZ/ h5Ck0SmVxzK9MUbFSPJCc98suiMsDXQ6P5NNzrsjptDlWSLSNyenlt2KhI8PVIFwLAgo rD5180F/GONDqegJeaNyY47boYZsGgshH8p5lewH5/lxWtPEEaiG8RPUFJr55uU/K56v VKjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y3NByVIzuR3Rg/aPLIKVF1n0drDE97HGQ1NdBQG6G8o=; b=Mz/72Qi8DkHiVVOR3SZdj7NdvnrMoaLkh0pjmQ4RSJYi1QFmh9JSMs1VcWj9BHYXrP H0Q21Lv0wy2eZfYlL7LXFUju656P5vuXcq+LQaLaYwJNbVGtPlG0+vxm5Qwz1nF7tb/u HUerUE/fsUlRCOyfO1FDm3uhjwbPeyHrxwsActu0eprphRL3gku1i/aSo//G5HnmVsHg UOuu/CYP0QHJizD0FzgWlNPCXHjPIlyO+r1RkCG6DldQS9awMhr9aq15zKJDHy/GY3E5 CpM/pcidRiJWxqZT4JJhGytOZBFElezkCTJgX4viq4EedvFkCv5s8KM1iW2Pi0KeUCwi H8HA== X-Gm-Message-State: AOAM530hjYy8nI4yY2aJ5DBTh+P7qq3580baOcPWix+JAnWliEUERHvk 6l6eUiIBx7P/Vm7VEboyOWc= X-Received: by 2002:a05:6e02:6d2:: with SMTP id p18mr2153126ils.44.1628867923564; Fri, 13 Aug 2021 08:18:43 -0700 (PDT) Received: from frodo.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id d4sm921145ilo.29.2021.08.13.08.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Aug 2021 08:18:43 -0700 (PDT) From: Jim Cromie To: gregkh@linuxfoundation.org, seanpaul@chromium.org, Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , Harry Wentland , Leo Li , Zhenyu Wang , Zhi Wang , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Jason Baron , Hawking Zhang , Tao Zhou , Huang Rui , Likun Gao , Chengming Gui , Aaron Liu , Jim Cromie , John Clements , Kevin Wang , Ashley Thomas , Qingqing Zhuo , Wyatt Wood , Aurabindo Pillai , Johan Hovold , Jessica Yu , Nick Desaulniers , Joe Perches , Miguel Ojeda , Andrew Morton , Masahiro Yamada , Peter Zijlstra , Andy Shevchenko , "Paul E. McKenney" , Tetsuo Handa , Thomas Gleixner , Vitor Massaru Iha , Sedat Dilek , Zhen Lei , Marco Elver , Jarkko Sakkinen , Alexander Potapenko , Palmer Dabbelt , Patricia Alfonso , Jiri Olsa , James Bottomley , Arvind Sankar , Johannes Berg , Arnd Bergmann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Subject: [PATCH v5 2/9] moduleparam: add data member to struct kernel_param Date: Fri, 13 Aug 2021 09:17:10 -0600 Message-Id: <20210813151734.1236324-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210813151734.1236324-1-jim.cromie@gmail.com> References: <20210813151734.1236324-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a const void* data member to the struct, to allow attaching private data that will be used soon by a setter method (via kp->data) to perform more elaborate actions. To attach the data at compile time, add new macros: module_param_cbd() derives from module_param_cb(), adding data param, and latter is redefined to use former. It calls __module_param_call_wdata(), which accepts a new data param and inits .data with it. Re-define __module_param_call() to use it. Use of this new data member will be rare, it might be worth redoing this as a separate/sub-type to de-bloat the base case. --- v4+: . const void* data - Signed-off-by: Jim Cromie --- include/linux/moduleparam.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index eed280fae433..878387e0b2d9 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -78,6 +78,7 @@ struct kernel_param { const struct kparam_string *str; const struct kparam_array *arr; }; + const void *data; }; extern const struct kernel_param __start___param[], __stop___param[]; @@ -175,6 +176,9 @@ struct kparam_array #define module_param_cb(name, ops, arg, perm) \ __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0) +#define module_param_cbd(name, ops, arg, perm, data) \ + __module_param_call_wdata(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0, data) + #define module_param_cb_unsafe(name, ops, arg, perm) \ __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, \ KERNEL_PARAM_FL_UNSAFE) @@ -284,14 +288,17 @@ struct kparam_array /* This is the fundamental function for registering boot/module parameters. */ -#define __module_param_call(prefix, name, ops, arg, perm, level, flags) \ +#define __module_param_call(prefix, name, ops, arg, perm, level, flags) \ + __module_param_call_wdata(prefix, name, ops, arg, perm, level, flags, NULL) + +#define __module_param_call_wdata(prefix, name, ops, arg, perm, level, flags, data) \ /* Default value instead of permissions? */ \ static const char __param_str_##name[] = prefix #name; \ static struct kernel_param __moduleparam_const __param_##name \ __used __section("__param") \ __aligned(__alignof__(struct kernel_param)) \ = { __param_str_##name, THIS_MODULE, ops, \ - VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } } + VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg }, data } /* Obsolete - use module_param_cb() */ #define module_param_call(name, _set, _get, arg, perm) \ -- 2.31.1