From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA97A22F767; Thu, 19 Jun 2025 12:31:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750336288; cv=none; b=fezbrr0y5lnbCfY4WVjy8Nd38SihRHP3ZacDQGLYlSVEYL9BCb6+69JJR6EOSNMt8yt9uiLpwVGq2vR/Op/V5Gs6lNHd7TSMSqsq2pg5IDvSAkoY8OwBVLN1x99CNXy7/20RNKYIJJ4LrjPOYCWLgzKpn1ULmfkk99JimsPOiXQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750336288; c=relaxed/simple; bh=eOI3Qqo9VLysUZBeVHSaVKRloh7GQ7rxLZNcn2x5424=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=n4ssy4dlav8oqd2EAg+HTvRIrBWKPz0hMVR72lMBp28lEqBKv8Ghb8lXG8bOpCcQOKSHIeTUTG4sju9s9Qs3FSEmSVvf2iB6FFb53QC8DEC5A1g1Vd14T3lp+xazDCJU0htAXlewO0FkHk7mQi37UqPYOgB9EzlZcO2RMvjKakM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dgxU7pzz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dgxU7pzz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C4CCC4CEEA; Thu, 19 Jun 2025 12:31:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750336287; bh=eOI3Qqo9VLysUZBeVHSaVKRloh7GQ7rxLZNcn2x5424=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=dgxU7pzzZ3WWd0ISj22p+9vX0cooSQh0p2gcP5ZLQ7bl5+CEOLjP8q12fSM0l2/ZZ xqJpwq2AaGlFMbadNxz6M4mU7G9e4crwZTYrAfGH0dN8n+YDV4AQrCgzKzxMKPSja6 Qh7Sh3iKfufuI96p3Vk6w7AyshlVlEQwXls8OnJNHDqU4iWHwZdHgHroFHjrRmUVtH ZpixivlEs5sbITlxH9u1a+fywE9qbNshNkpMgTBYS3Dy59pK/bhcrBfzw+odtI29mk 5O4d3E6SgPE339/OrXYejpfZ572gEcuqLaxfDbNvAp3M/sHW08PKZz3Pc82c44MkcH Po5jktPMoja6Q== From: Andreas Hindborg To: "Benno Lossin" Cc: "Miguel Ojeda" , "Alex Gaynor" , "Boqun Feng" , "Gary Guo" , =?utf-8?Q?Bj=C3=B6rn?= Roy Baron , "Alice Ryhl" , "Masahiro Yamada" , "Nathan Chancellor" , "Luis Chamberlain" , "Danilo Krummrich" , "Nicolas Schier" , "Trevor Gross" , "Adam Bratschi-Kaye" , , , , "Petr Pavlu" , "Sami Tolvanen" , "Daniel Gomez" , "Simona Vetter" , "Greg KH" , "Fiona Behrens" , "Daniel Almeida" , Subject: Re: [PATCH v13 4/6] rust: module: update the module macro with module parameter support In-Reply-To: (Benno Lossin's message of "Wed, 18 Jun 2025 23:07:30 +0200") References: <20250612-module-params-v3-v13-0-bc219cd1a3f8@kernel.org> <20250612-module-params-v3-v13-4-bc219cd1a3f8@kernel.org> User-Agent: mu4e 1.12.9; emacs 30.1 Date: Thu, 19 Jun 2025 14:31:15 +0200 Message-ID: <87plez7w18.fsf@kernel.org> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain "Benno Lossin" writes: > On Thu Jun 12, 2025 at 3:40 PM CEST, Andreas Hindborg wrote: >> + >> + fn emit_params(&mut self, info: &ModuleInfo) { >> + let Some(params) = &info.params else { >> + return; >> + }; >> + >> + for param in params { >> + let ops = param_ops_path(¶m.ptype); >> + >> + // Note: The spelling of these fields is dictated by the user space >> + // tool `modinfo`. >> + self.emit_param("parmtype", ¶m.name, ¶m.ptype); >> + self.emit_param("parm", ¶m.name, ¶m.description); > > I just read this part again and I want to voice my dissatisfaction with > these key names. (not that you can do anything about that :) > >> + >> + write!( >> + self.param_buffer, >> + " >> + pub(crate) static {param_name}: > > Does this need to be accessed by anything else except the static below? > If no, then can we move it inside of that static? So > > #[link_section = \"__param\"] > #[used] > static __{module_name}_{param_name}_struct: ::kernel::module_param::RacyKernelParam = { > static {param_name}: > ::kernel::module_param::ModuleParamAccess<{param_type}> = > ::kernel::module_param::ModuleParamAccess::new({param_default}); > // ... > }; It is used to access the value of the parameter from the module. If you reduce visibility you will get an error when trying to read the parameter value: RUSTC samples/rust/rust_minimal.o error[E0425]: cannot find value `test_parameter` in module `module_parameters` --> /home/aeh/src/linux-rust/module-params/samples/rust/rust_minimal.rs:31:33 | 31 | *module_parameters::test_parameter.get() | ^^^^^^^^^^^^^^ not found in `module_parameters` error: aborting due to 1 previous error Best regards, Andreas Hindborg