From: Ivan Tverdohleb <mbkchelofficialdev@gmail.com>
To: Luis Chamberlain <mcgrof@kernel.org>, Miguel Ojeda <ojeda@kernel.org>
Cc: Petr Pavlu <petr.pavlu@suse.com>,
Daniel Gomez <da.gomez@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
rust-for-linux@vger.kernel.org, linux-modules@vger.kernel.org,
linux-kernel@vger.kernel.org,
Ivan Tverdohleb <mbkchelofficialdev@gmail.com>
Subject: [PATCH] rust: macros: document emit_base in ModInfoBuilder
Date: Wed, 28 Oct 2026 17:50:05 +0200 [thread overview]
Message-ID: <20261028155005.174417-1-mbkchelofficialdev@gmail.com> (raw)
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 Tverdohleb <mbkchelofficialdev@gmail.com>
---
rust/macros/module.rs | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/rust/macros/module.rs b/rust/macros/module.rs
index 0a7b9e24c..6f361013f 100644
--- a/rust/macros/module.rs
+++ b/rust/macros/module.rs
@@ -49,6 +49,16 @@ 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. For built-in modules (`builtin == true`), the string
+ /// is prefixed with the module name (`module.field=content\0`) to avoid naming
+ /// collisions in the final monolithic kernel binary.
+ ///
+ /// It automatically generates a unique static identifier using an internal counter
+ /// and applies appropriate conditional compilation attributes (`#[cfg(MODULE)]` or
+ /// `#[cfg(not(MODULE))]`) based on the target type.
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.0
next reply other threads:[~2026-10-28 15:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 15:50 Ivan Tverdohleb [this message]
[not found] ` <CA+YDrKA1hTM-Yh+qsCz7Q_O9f4m_JWqyxkm4izaz4uAao_Jz5Q@mail.gmail.com>
2026-10-28 20:05 ` [PATCH] rust: macros: document emit_base in ModInfoBuilder MBKCHEL
2026-10-28 20:07 ` MBKCHEL
2026-10-28 20:13 ` MBKCHEL
2026-10-29 13:33 ` MBKCHEL
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261028155005.174417-1-mbkchelofficialdev@gmail.com \
--to=mbkchelofficialdev@gmail.com \
--cc=da.gomez@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=ojeda@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=samitolvanen@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox