All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] rust: macros: document emit_base in ModInfoBuilder
@ 2026-11-20  8:20 Ivan Tverdokhleb
  0 siblings, 0 replies; only message in thread
From: Ivan Tverdokhleb @ 2026-11-20  8:20 UTC (permalink / raw)
  To: rust-for-linux
  Cc: Luis Chamberlain, Petr Pavlu, Daniel Gomez, Sami Tolvanen,
	Aaron Tomlin, Miguel Ojeda, Boqun Feng, Gary Guo,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan, linux-modules, linux-kernel

Add documentation for the emit_base method within the ModInfoBuilder
struct. Explain its role in formatting metadata strings, handling the
differentiation between built-in and loadable modules, and managing
linker sections and conditional compilation.

Signed-off-by: Ivan Tverdokhleb <mbkchelofficialdev@gmail.com>
---
Changes in v2:
  - Fixed the typo in my last name in the From and Signed-off-by lines.
  - Reworded the documentation: dropped an unverified claim about the
    reason for the module name prefix, and documented the `param`
    argument.

v1: https://lore.kernel.org/rust-for-linux/20261028155005.174417-1-mbkchelofficialdev@gmail.com/

 rust/macros/module.rs | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/rust/macros/module.rs b/rust/macros/module.rs
index 0a7b9e24c..6f4aacfe7 100644
--- a/rust/macros/module.rs
+++ b/rust/macros/module.rs
@@ -49,6 +49,20 @@ fn new(module: &'a str) -> Self {
         }
     }
 
+    /// Emits a single metadata entry into the module information table.
+    ///
+    /// This method formats a `field=content\0` byte string and places it into the
+    /// `.modinfo` linker section, except on macOS where `link_section` is omitted.
+    /// For built-in modules (`builtin == true`), the string is prefixed with
+    /// `<module>.`; for loadable modules, it is emitted without a prefix.
+    ///
+    /// The `param` flag selects which token stream receives the generated item: when
+    /// `true`, the entry is appended to `param_ts` (used for module parameters via
+    /// [`Self::emit_param`] and placed inside `mod module_parameters`); when
+    /// `false`, it is appended to `ts` in the main generated module code.
+    ///
+    /// The method also generates a unique static identifier using an internal counter
+    /// and applies `#[cfg(not(MODULE))]` or `#[cfg(MODULE)]` based on `builtin`.
     fn emit_base(&mut self, field: &str, content: &str, builtin: bool, param: bool) {
         let string = if builtin {
             // Built-in modules prefix their modinfo strings by `module.`.
-- 
2.56.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-20  8:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20  8:20 [PATCH v2] rust: macros: document emit_base in ModInfoBuilder Ivan Tverdokhleb

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.