* [PATCH 0/4] Introduce import_ns support for Rust
[not found] <CGME20251028122315eucas1p159b65037cf6f3f710c1917e2464399b5@eucas1p1.samsung.com>
@ 2025-10-28 12:22 ` Michal Wilczynski
[not found] ` <CGME20251028122316eucas1p2733987cd4c1eb8f83d6572d542e76d2a@eucas1p2.samsung.com>
` (4 more replies)
0 siblings, 5 replies; 20+ messages in thread
From: Michal Wilczynski @ 2025-10-28 12:22 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Michal Wilczynski, Drew Fustini,
Guo Ren, Fu Wei, Uwe Kleine-König
Cc: Stephen Rothwell, rust-for-linux, linux-kernel, linux-pwm,
linux-riscv
This series addresses build warnings reported by `modpost` for the Rust
PWM driver (`pwm_th1520`) in linux-next:
WARNING: modpost: module pwm_th1520 uses symbol pwmchip_release from
namespace PWM, but does not import it.
These warnings occur because Rust modules, like C modules, need to
declare their dependencies on C symbols exported to specific namespaces
(using `EXPORT_SYMBOL_NS` in C). This is done by embedding
"import_ns=<NAMESPACE>" tags into the module's `.modinfo` section, which
`modpost` verifies. The C macro `MODULE_IMPORT_NS()` handles this, but
the Rust `module!` macro lacked equivalent functionality.
This series introduces the necessary support:
Patch 1 extends the core `module!` macro in `rust/macros/module.rs`
to parse an optional `imports_ns: [...]` field and generate the required
`import_ns` tags in the `.modinfo` section.
Patch 2 adds a convenience macro `module_pwm_platform_driver!` to
`rust/kernel/pwm.rs`. This macro wraps the standard
`module_platform_driver!` and automatically adds `imports_ns: ["PWM"]`,
simplifying module declaration for PWM driver authors.
Patch 3 updates the `pwm_th1520` driver to use the new helper macro,
fixing the build warnings.
Patch 4 includes a minor clippy style fix for the `pwm_th1520` driver.
Thanks to Stephen Rothwell for reporting the build warnings.
---
Michal Wilczynski (4):
rust: macros: Add support for 'imports_ns' to module!
rust: pwm: Add module_pwm_platform_driver! macro
pwm: th1520: Use module_pwm_platform_driver! macro
pwm: th1520: Fix clippy warning for redundant struct field init
drivers/pwm/pwm_th1520.rs | 4 ++--
rust/kernel/pwm.rs | 23 +++++++++++++++++++++++
rust/macros/module.rs | 8 ++++++++
3 files changed, 33 insertions(+), 2 deletions(-)
---
base-commit: cb6649f6217c0331b885cf787f1d175963e2a1d2
change-id: 20251028-pwm_fixes-cca9db267458
prerequisite-message-id: 20251016-rust-next-pwm-working-fan-for-sending-v16-0-a5df2405d2bd@samsung.com
prerequisite-patch-id: bddf445f74431c647c134eabb3eb029374455a2e
prerequisite-patch-id: 6fbf1d04b8ca1c72362d7f3a4e420be8f95a44a8
prerequisite-patch-id: d4adae5b56cd13089bfa070bc4bd3bbc6f50b097
prerequisite-patch-id: c1a631eb7a5d8f1d8dfdae847e8b32e8d5ea95d8
prerequisite-patch-id: 6c2a0d316d9d0aa99346cb12afe4b9dc5ac217db
prerequisite-patch-id: 4a05412207606f8df51db0068c4f57785b02a271
prerequisite-patch-id: e0a0d54562e883b07cbe9c5b3721687de5b4ea55
Best regards,
--
Michal Wilczynski <m.wilczynski@samsung.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 1/4] rust: macros: Add support for 'imports_ns' to module!
[not found] ` <CGME20251028122316eucas1p2733987cd4c1eb8f83d6572d542e76d2a@eucas1p2.samsung.com>
@ 2025-10-28 12:22 ` Michal Wilczynski
2025-10-28 22:32 ` Elle Rhumsaa
` (2 more replies)
0 siblings, 3 replies; 20+ messages in thread
From: Michal Wilczynski @ 2025-10-28 12:22 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Michal Wilczynski, Drew Fustini,
Guo Ren, Fu Wei, Uwe Kleine-König
Cc: Stephen Rothwell, rust-for-linux, linux-kernel, linux-pwm,
linux-riscv
Kernel modules that use C symbols exported via `EXPORT_SYMBOL_NS` must
declare this dependency for `modpost` verification. C modules achieve
this by using the `MODULE_IMPORT_NS(NAMESPACE)` macro, which embeds an
`import_ns=<NAMESPACE>` tag into the `.modinfo` section.
The Rust `module!` macro lacked the ability to generate these tags,
resulting in build warnings for Rust drivers (like the PWM driver) that
call namespaced C functions.
Modify the `module!` macro's internal parser (`ModuleInfo`) to accept a
new optional field `imports_ns`, which takes an array of namespace
strings. Update the code generator (`ModInfoBuilder::emit`) loop to
iterate over these strings and emit the corresponding
`import_ns=<NAMESPACE>` tags into the `.modinfo` section using the
existing `#[link_section]` mechanism.
This provides the necessary infrastructure for Rust modules to correctly
declare their C namespace dependencies.
Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
---
rust/macros/module.rs | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/rust/macros/module.rs b/rust/macros/module.rs
index 5ee54a00c0b65699596e660b2d4d60e64be2a50c..408cd115487514c8be79724d901c676435696376 100644
--- a/rust/macros/module.rs
+++ b/rust/macros/module.rs
@@ -98,6 +98,7 @@ struct ModuleInfo {
description: Option<String>,
alias: Option<Vec<String>>,
firmware: Option<Vec<String>>,
+ imports_ns: Option<Vec<String>>,
}
impl ModuleInfo {
@@ -112,6 +113,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self {
"license",
"alias",
"firmware",
+ "imports_ns",
];
const REQUIRED_KEYS: &[&str] = &["type", "name", "license"];
let mut seen_keys = Vec::new();
@@ -137,6 +139,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self {
"license" => info.license = expect_string_ascii(it),
"alias" => info.alias = Some(expect_string_array(it)),
"firmware" => info.firmware = Some(expect_string_array(it)),
+ "imports_ns" => info.imports_ns = Some(expect_string_array(it)),
_ => panic!("Unknown key \"{key}\". Valid keys are: {EXPECTED_KEYS:?}."),
}
@@ -195,6 +198,11 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
modinfo.emit("firmware", &fw);
}
}
+ if let Some(imports) = info.imports_ns {
+ for ns in imports {
+ modinfo.emit("import_ns", &ns);
+ }
+ }
// Built-in modules also export the `file` modinfo string.
let file =
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 2/4] rust: pwm: Add module_pwm_platform_driver! macro
[not found] ` <CGME20251028122317eucas1p1e7c925502a83dd3324478c0209de08c3@eucas1p1.samsung.com>
@ 2025-10-28 12:22 ` Michal Wilczynski
2025-10-28 22:32 ` Elle Rhumsaa
0 siblings, 1 reply; 20+ messages in thread
From: Michal Wilczynski @ 2025-10-28 12:22 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Michal Wilczynski, Drew Fustini,
Guo Ren, Fu Wei, Uwe Kleine-König
Cc: Stephen Rothwell, rust-for-linux, linux-kernel, linux-pwm,
linux-riscv
Rust PWM drivers using the abstractions in `kernel/pwm.rs` typically
call C functions (like `pwmchip_alloc`, `__pwmchip_add`, etc.) that are
exported to the `PWM` C symbol namespace.
With the introduction of `imports_ns` support in the `module!` macro,
every PWM driver would need to manually include `imports_ns: ["PWM"]` in
its module declaration.
To simplify this for driver authors and ensure consistency, introduce a
new helper macro `module_pwm_platform_driver!` in `pwm.rs`. This macro
wraps the standard `module_platform_driver!`, forwards all user provided
arguments using the `($($user_args:tt)*)` pattern, and automatically
injects the `imports_ns: ["PWM"]` declaration.
This follows the pattern used in other subsystems (e.g.,
`module_pci_driver!`) to provide specialized module registration
helpers. It makes writing PWM drivers slightly simpler and less error
prone regarding namespace imports.
Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
---
rust/kernel/pwm.rs | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/rust/kernel/pwm.rs b/rust/kernel/pwm.rs
index 79fbb13cd47f75681283648ddc4fffb7889be930..6f2f78c687d5b924739f59052e9b3393c922540d 100644
--- a/rust/kernel/pwm.rs
+++ b/rust/kernel/pwm.rs
@@ -760,3 +760,26 @@ fn drop(&mut self) {
unsafe { bindings::pwmchip_remove(chip_raw); }
}
}
+
+/// Declares a kernel module that exposes a single PWM driver.
+///
+/// # Examples
+///
+///```ignore
+/// kernel::module_pwm_platform_driver! {
+/// type: MyDriver,
+/// name: "Module name",
+/// authors: ["Author name"],
+/// description: "Description",
+/// license: "GPL v2",
+/// }
+///```
+#[macro_export]
+macro_rules! module_pwm_platform_driver {
+ ($($user_args:tt)*) => {
+ $crate::module_platform_driver! {
+ $($user_args)*
+ imports_ns: ["PWM"],
+ }
+ };
+}
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 3/4] pwm: th1520: Use module_pwm_platform_driver! macro
[not found] ` <CGME20251028122318eucas1p17161f0e1f2281c868688e8a4cc3d8f68@eucas1p1.samsung.com>
@ 2025-10-28 12:22 ` Michal Wilczynski
2025-10-28 22:33 ` Elle Rhumsaa
2025-10-29 0:59 ` Troy Mitchell
0 siblings, 2 replies; 20+ messages in thread
From: Michal Wilczynski @ 2025-10-28 12:22 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Michal Wilczynski, Drew Fustini,
Guo Ren, Fu Wei, Uwe Kleine-König
Cc: Stephen Rothwell, rust-for-linux, linux-kernel, linux-pwm,
linux-riscv
The `pwm_th1520` Rust driver calls C functions from the `PWM` namespace,
triggering `modpost` warnings due to missing namespace import
declarations in its `.modinfo` section.
Fix these warnings and simplify the module declaration by switching from
the generic `kernel::module_platform_driver!` macro to the newly
introduced PWM-specific `kernel::module_pwm_platform_driver!` macro.
The new macro automatically handles the required `imports_ns: ["PWM"]`
declaration.
Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
---
drivers/pwm/pwm_th1520.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pwm/pwm_th1520.rs b/drivers/pwm/pwm_th1520.rs
index 0ad38b78be854ab3c10268fb20763d9962f59c0f..5fb123f5e9c6dc3a8ee9a7a47fa778c23213e957 100644
--- a/drivers/pwm/pwm_th1520.rs
+++ b/drivers/pwm/pwm_th1520.rs
@@ -369,7 +369,7 @@ fn probe(
}
}
-kernel::module_platform_driver! {
+kernel::module_pwm_platform_driver! {
type: Th1520PwmPlatformDriver,
name: "pwm-th1520",
authors: ["Michal Wilczynski <m.wilczynski@samsung.com>"],
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 4/4] pwm: th1520: Fix clippy warning for redundant struct field init
[not found] ` <CGME20251028122318eucas1p1863a8b44efe27c28a1bcf427d2855c00@eucas1p1.samsung.com>
@ 2025-10-28 12:22 ` Michal Wilczynski
2025-10-28 22:33 ` Elle Rhumsaa
2025-10-30 22:05 ` Uwe Kleine-König
0 siblings, 2 replies; 20+ messages in thread
From: Michal Wilczynski @ 2025-10-28 12:22 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Michal Wilczynski, Drew Fustini,
Guo Ren, Fu Wei, Uwe Kleine-König
Cc: Stephen Rothwell, rust-for-linux, linux-kernel, linux-pwm,
linux-riscv
Clippy warns about redundant struct field initialization when the field
name and the variable name are the same (e.g., `status: status`).
No functional change.
Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
---
drivers/pwm/pwm_th1520.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pwm/pwm_th1520.rs b/drivers/pwm/pwm_th1520.rs
index 5fb123f5e9c6dc3a8ee9a7a47fa778c23213e957..95a809af48eb16fe13125d4d9f4ee5de20555e77 100644
--- a/drivers/pwm/pwm_th1520.rs
+++ b/drivers/pwm/pwm_th1520.rs
@@ -185,7 +185,7 @@ fn round_waveform_tohw(
);
Ok(pwm::RoundedWaveform {
- status: status,
+ status,
hardware_waveform: wfhw,
})
}
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 1/4] rust: macros: Add support for 'imports_ns' to module!
2025-10-28 12:22 ` [PATCH 1/4] rust: macros: Add support for 'imports_ns' to module! Michal Wilczynski
@ 2025-10-28 22:32 ` Elle Rhumsaa
2025-10-29 12:47 ` Alice Ryhl
2025-10-31 7:47 ` Uwe Kleine-König
2 siblings, 0 replies; 20+ messages in thread
From: Elle Rhumsaa @ 2025-10-28 22:32 UTC (permalink / raw)
To: Michal Wilczynski
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Drew Fustini, Guo Ren, Fu Wei,
Uwe Kleine-König, Stephen Rothwell, rust-for-linux,
linux-kernel, linux-pwm, linux-riscv
On Tue, Oct 28, 2025 at 01:22:32PM +0100, Michal Wilczynski wrote:
> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
> ---
Reviewed-by: Elle Rhumsaa <elle@weathered-steel.dev>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/4] rust: pwm: Add module_pwm_platform_driver! macro
2025-10-28 12:22 ` [PATCH 2/4] rust: pwm: Add module_pwm_platform_driver! macro Michal Wilczynski
@ 2025-10-28 22:32 ` Elle Rhumsaa
0 siblings, 0 replies; 20+ messages in thread
From: Elle Rhumsaa @ 2025-10-28 22:32 UTC (permalink / raw)
To: Michal Wilczynski
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Drew Fustini, Guo Ren, Fu Wei,
Uwe Kleine-König, Stephen Rothwell, rust-for-linux,
linux-kernel, linux-pwm, linux-riscv
On Tue, Oct 28, 2025 at 01:22:33PM +0100, Michal Wilczynski wrote:
> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
> ---
Reviewed-by: Elle Rhumsaa <elle@weathered-steel.dev>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/4] pwm: th1520: Use module_pwm_platform_driver! macro
2025-10-28 12:22 ` [PATCH 3/4] pwm: th1520: Use " Michal Wilczynski
@ 2025-10-28 22:33 ` Elle Rhumsaa
2025-10-29 0:59 ` Troy Mitchell
1 sibling, 0 replies; 20+ messages in thread
From: Elle Rhumsaa @ 2025-10-28 22:33 UTC (permalink / raw)
To: Michal Wilczynski
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Drew Fustini, Guo Ren, Fu Wei,
Uwe Kleine-König, Stephen Rothwell, rust-for-linux,
linux-kernel, linux-pwm, linux-riscv
On Tue, Oct 28, 2025 at 01:22:34PM +0100, Michal Wilczynski wrote:
> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
> ---
Reviewed-by: Elle Rhumsaa <elle@weathered-steel.dev>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/4] pwm: th1520: Fix clippy warning for redundant struct field init
2025-10-28 12:22 ` [PATCH 4/4] pwm: th1520: Fix clippy warning for redundant struct field init Michal Wilczynski
@ 2025-10-28 22:33 ` Elle Rhumsaa
2025-10-30 22:05 ` Uwe Kleine-König
1 sibling, 0 replies; 20+ messages in thread
From: Elle Rhumsaa @ 2025-10-28 22:33 UTC (permalink / raw)
To: Michal Wilczynski
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Drew Fustini, Guo Ren, Fu Wei,
Uwe Kleine-König, Stephen Rothwell, rust-for-linux,
linux-kernel, linux-pwm, linux-riscv
On Tue, Oct 28, 2025 at 01:22:35PM +0100, Michal Wilczynski wrote:
> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
> ---
Reviewed-by: Elle Rhumsaa <elle@weathered-steel.dev>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/4] pwm: th1520: Use module_pwm_platform_driver! macro
2025-10-28 12:22 ` [PATCH 3/4] pwm: th1520: Use " Michal Wilczynski
2025-10-28 22:33 ` Elle Rhumsaa
@ 2025-10-29 0:59 ` Troy Mitchell
1 sibling, 0 replies; 20+ messages in thread
From: Troy Mitchell @ 2025-10-29 0:59 UTC (permalink / raw)
To: Michal Wilczynski, Miguel Ojeda, Alex Gaynor, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich, Drew Fustini, Guo Ren,
Fu Wei, Uwe Kleine-König
Cc: Stephen Rothwell, rust-for-linux, linux-kernel, linux-pwm,
linux-riscv, Troy Mitchell
On Tue, Oct 28, 2025 at 01:22:34PM +0100, Michal Wilczynski wrote:
> The `pwm_th1520` Rust driver calls C functions from the `PWM` namespace,
> triggering `modpost` warnings due to missing namespace import
> declarations in its `.modinfo` section.
>
> Fix these warnings and simplify the module declaration by switching from
> the generic `kernel::module_platform_driver!` macro to the newly
> introduced PWM-specific `kernel::module_pwm_platform_driver!` macro.
> The new macro automatically handles the required `imports_ns: ["PWM"]`
> declaration.
>
> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
Reviewed-by: Troy Mitchell <troy.mitchell@linux.dev>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/4] Introduce import_ns support for Rust
2025-10-28 12:22 ` [PATCH 0/4] Introduce import_ns support for Rust Michal Wilczynski
` (3 preceding siblings ...)
[not found] ` <CGME20251028122318eucas1p1863a8b44efe27c28a1bcf427d2855c00@eucas1p1.samsung.com>
@ 2025-10-29 10:04 ` Uwe Kleine-König
2025-10-29 11:07 ` Michal Wilczynski
2025-10-29 18:18 ` Miguel Ojeda
4 siblings, 2 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2025-10-29 10:04 UTC (permalink / raw)
To: Michal Wilczynski
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Drew Fustini, Guo Ren, Fu Wei,
Stephen Rothwell, rust-for-linux, linux-kernel, linux-pwm,
linux-riscv
[-- Attachment #1: Type: text/plain, Size: 1879 bytes --]
Hello,
On Tue, Oct 28, 2025 at 01:22:31PM +0100, Michal Wilczynski wrote:
> This series addresses build warnings reported by `modpost` for the Rust
> PWM driver (`pwm_th1520`) in linux-next:
>
> WARNING: modpost: module pwm_th1520 uses symbol pwmchip_release from
> namespace PWM, but does not import it.
>
> These warnings occur because Rust modules, like C modules, need to
> declare their dependencies on C symbols exported to specific namespaces
> (using `EXPORT_SYMBOL_NS` in C). This is done by embedding
> "import_ns=<NAMESPACE>" tags into the module's `.modinfo` section, which
> `modpost` verifies. The C macro `MODULE_IMPORT_NS()` handles this, but
> the Rust `module!` macro lacked equivalent functionality.
>
> This series introduces the necessary support:
>
> Patch 1 extends the core `module!` macro in `rust/macros/module.rs`
> to parse an optional `imports_ns: [...]` field and generate the required
> `import_ns` tags in the `.modinfo` section.
>
> Patch 2 adds a convenience macro `module_pwm_platform_driver!` to
> `rust/kernel/pwm.rs`. This macro wraps the standard
> `module_platform_driver!` and automatically adds `imports_ns: ["PWM"]`,
> simplifying module declaration for PWM driver authors.
>
> Patch 3 updates the `pwm_th1520` driver to use the new helper macro,
> fixing the build warnings.
Given that for now the pwm_th1520 driver is the only user, does it make
sense to merge this series via my pwm tree? If it goes via a different
tree, I'd like to have a tag to merge into my tree to hand over code
which is free of warnings to Linus in the next merge window.
> Patch 4 includes a minor clippy style fix for the `pwm_th1520` driver.
If you could mention the command that makes this warning visible, I'd be
glad to add that to my repertoire of build checks.
Thanks for addressing the issue
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/4] Introduce import_ns support for Rust
2025-10-29 10:04 ` [PATCH 0/4] Introduce import_ns support for Rust Uwe Kleine-König
@ 2025-10-29 11:07 ` Michal Wilczynski
2025-10-29 18:18 ` Miguel Ojeda
1 sibling, 0 replies; 20+ messages in thread
From: Michal Wilczynski @ 2025-10-29 11:07 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Drew Fustini, Guo Ren, Fu Wei,
Stephen Rothwell, rust-for-linux, linux-kernel, linux-pwm,
linux-riscv
On 10/29/25 11:04, Uwe Kleine-König wrote:
> Hello,
>
> On Tue, Oct 28, 2025 at 01:22:31PM +0100, Michal Wilczynski wrote:
>> This series addresses build warnings reported by `modpost` for the Rust
>> PWM driver (`pwm_th1520`) in linux-next:
>>
>> WARNING: modpost: module pwm_th1520 uses symbol pwmchip_release from
>> namespace PWM, but does not import it.
>>
>> These warnings occur because Rust modules, like C modules, need to
>> declare their dependencies on C symbols exported to specific namespaces
>> (using `EXPORT_SYMBOL_NS` in C). This is done by embedding
>> "import_ns=<NAMESPACE>" tags into the module's `.modinfo` section, which
>> `modpost` verifies. The C macro `MODULE_IMPORT_NS()` handles this, but
>> the Rust `module!` macro lacked equivalent functionality.
>>
>> This series introduces the necessary support:
>>
>> Patch 1 extends the core `module!` macro in `rust/macros/module.rs`
>> to parse an optional `imports_ns: [...]` field and generate the required
>> `import_ns` tags in the `.modinfo` section.
>>
>> Patch 2 adds a convenience macro `module_pwm_platform_driver!` to
>> `rust/kernel/pwm.rs`. This macro wraps the standard
>> `module_platform_driver!` and automatically adds `imports_ns: ["PWM"]`,
>> simplifying module declaration for PWM driver authors.
>>
>> Patch 3 updates the `pwm_th1520` driver to use the new helper macro,
>> fixing the build warnings.
>
> Given that for now the pwm_th1520 driver is the only user, does it make
> sense to merge this series via my pwm tree? If it goes via a different
> tree, I'd like to have a tag to merge into my tree to hand over code
> which is free of warnings to Linus in the next merge window.
Hi,
I agree with you. Hopefully we can get an ack from the Rust maintainers
and the series can go through your tree.
>
>> Patch 4 includes a minor clippy style fix for the `pwm_th1520` driver.
>
> If you could mention the command that makes this warning visible, I'd be
> glad to add that to my repertoire of build checks.
I'm using the following command to compile the kernel:
$ make ARCH=riscv -j20 LLVM=1 CLIPPY=1
I guess you were missing the 'CLIPPY=1' part.
>
> Thanks for addressing the issue
> Uwe
Best regards,
--
Michal Wilczynski <m.wilczynski@samsung.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/4] rust: macros: Add support for 'imports_ns' to module!
2025-10-28 12:22 ` [PATCH 1/4] rust: macros: Add support for 'imports_ns' to module! Michal Wilczynski
2025-10-28 22:32 ` Elle Rhumsaa
@ 2025-10-29 12:47 ` Alice Ryhl
2025-10-31 7:47 ` Uwe Kleine-König
2 siblings, 0 replies; 20+ messages in thread
From: Alice Ryhl @ 2025-10-29 12:47 UTC (permalink / raw)
To: Michal Wilczynski
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Drew Fustini, Guo Ren, Fu Wei,
Uwe Kleine-König, Stephen Rothwell, rust-for-linux,
linux-kernel, linux-pwm, linux-riscv
On Tue, Oct 28, 2025 at 01:22:32PM +0100, Michal Wilczynski wrote:
> Kernel modules that use C symbols exported via `EXPORT_SYMBOL_NS` must
> declare this dependency for `modpost` verification. C modules achieve
> this by using the `MODULE_IMPORT_NS(NAMESPACE)` macro, which embeds an
> `import_ns=<NAMESPACE>` tag into the `.modinfo` section.
>
> The Rust `module!` macro lacked the ability to generate these tags,
> resulting in build warnings for Rust drivers (like the PWM driver) that
> call namespaced C functions.
>
> Modify the `module!` macro's internal parser (`ModuleInfo`) to accept a
> new optional field `imports_ns`, which takes an array of namespace
> strings. Update the code generator (`ModInfoBuilder::emit`) loop to
> iterate over these strings and emit the corresponding
> `import_ns=<NAMESPACE>` tags into the `.modinfo` section using the
> existing `#[link_section]` mechanism.
>
> This provides the necessary infrastructure for Rust modules to correctly
> declare their C namespace dependencies.
>
> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/4] Introduce import_ns support for Rust
2025-10-29 10:04 ` [PATCH 0/4] Introduce import_ns support for Rust Uwe Kleine-König
2025-10-29 11:07 ` Michal Wilczynski
@ 2025-10-29 18:18 ` Miguel Ojeda
2025-10-29 18:51 ` Michal Wilczynski
1 sibling, 1 reply; 20+ messages in thread
From: Miguel Ojeda @ 2025-10-29 18:18 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Michal Wilczynski, Miguel Ojeda, Alex Gaynor, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich, Drew Fustini, Guo Ren,
Fu Wei, Stephen Rothwell, rust-for-linux, linux-kernel, linux-pwm,
linux-riscv
On Wed, Oct 29, 2025 at 11:04 AM Uwe Kleine-König <ukleinek@kernel.org> wrote:
>
> If you could mention the command that makes this warning visible, I'd be
> glad to add that to my repertoire of build checks.
Yeah, please do!
I do my best to keep even linux-next and stable kernels Clippy clean
as much as possible, so it would be nice to have that Clippy fix added
to -next soon.
I have other steps that maintainers/contributors should run here:
https://rust-for-linux.com/contributing#submit-checklist-addendum
Essentially / most importantly: `rustfmt`, `rustdoc` and `CLIPPY=1`.
I am sending a couple fixes for those.
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/4] Introduce import_ns support for Rust
2025-10-29 18:18 ` Miguel Ojeda
@ 2025-10-29 18:51 ` Michal Wilczynski
0 siblings, 0 replies; 20+ messages in thread
From: Michal Wilczynski @ 2025-10-29 18:51 UTC (permalink / raw)
To: Miguel Ojeda, Uwe Kleine-König
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Drew Fustini, Guo Ren, Fu Wei,
Stephen Rothwell, rust-for-linux, linux-kernel, linux-pwm,
linux-riscv
On 10/29/25 19:18, Miguel Ojeda wrote:
> On Wed, Oct 29, 2025 at 11:04 AM Uwe Kleine-König <ukleinek@kernel.org> wrote:
>>
>> If you could mention the command that makes this warning visible, I'd be
>> glad to add that to my repertoire of build checks.
>
> Yeah, please do!
>
> I do my best to keep even linux-next and stable kernels Clippy clean
> as much as possible, so it would be nice to have that Clippy fix added
> to -next soon.
>
> I have other steps that maintainers/contributors should run here:
>
> https://protect2.fireeye.com/v1/url?k=0d35e0d3-6dd77d8e-0d346b9c-000babd9f1ba-e5d27bbbccd997ca&q=1&e=d4a64c99-aab6-4741-9747-63f10e63aed4&u=https%3A%2F%2Frust-for-linux.com%2Fcontributing%23submit-checklist-addendum
>
> Essentially / most importantly: `rustfmt`, `rustdoc` and `CLIPPY=1`.
Oh yeah I think I remembered to run 'rustfmt' couple months ago, but
over time when sending revisions forgot about that, sorry. I guess it
would be great to extend 'b4 prep --check' for those checks as well.
>
> I am sending a couple fixes for those.
>
> Thanks!
>
> Cheers,
> Miguel
>
Best regards,
--
Michal Wilczynski <m.wilczynski@samsung.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/4] pwm: th1520: Fix clippy warning for redundant struct field init
2025-10-28 12:22 ` [PATCH 4/4] pwm: th1520: Fix clippy warning for redundant struct field init Michal Wilczynski
2025-10-28 22:33 ` Elle Rhumsaa
@ 2025-10-30 22:05 ` Uwe Kleine-König
1 sibling, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2025-10-30 22:05 UTC (permalink / raw)
To: Michal Wilczynski
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Drew Fustini, Guo Ren, Fu Wei,
Stephen Rothwell, rust-for-linux, linux-kernel, linux-pwm,
linux-riscv
[-- Attachment #1: Type: text/plain, Size: 463 bytes --]
Hello,
On Tue, Oct 28, 2025 at 01:22:35PM +0100, Michal Wilczynski wrote:
> Clippy warns about redundant struct field initialization when the field
> name and the variable name are the same (e.g., `status: status`).
>
> No functional change.
>
> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
applied this patch only (for now) to
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next
.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/4] rust: macros: Add support for 'imports_ns' to module!
2025-10-28 12:22 ` [PATCH 1/4] rust: macros: Add support for 'imports_ns' to module! Michal Wilczynski
2025-10-28 22:32 ` Elle Rhumsaa
2025-10-29 12:47 ` Alice Ryhl
@ 2025-10-31 7:47 ` Uwe Kleine-König
2025-10-31 12:57 ` Miguel Ojeda
2 siblings, 1 reply; 20+ messages in thread
From: Uwe Kleine-König @ 2025-10-31 7:47 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor
Cc: Michal Wilczynski, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Drew Fustini, Guo Ren, Fu Wei, Stephen Rothwell,
rust-for-linux, linux-kernel, linux-pwm, linux-riscv
[-- Attachment #1: Type: text/plain, Size: 1610 bytes --]
Hello,
I already asked this in reply to the cover letter, but the question was
lost on the way (no offense!), so I'm asking again. As it only really
affects this patch, I'm doing that here:
On Tue, Oct 28, 2025 at 01:22:32PM +0100, Michal Wilczynski wrote:
> Kernel modules that use C symbols exported via `EXPORT_SYMBOL_NS` must
> declare this dependency for `modpost` verification. C modules achieve
> this by using the `MODULE_IMPORT_NS(NAMESPACE)` macro, which embeds an
> `import_ns=<NAMESPACE>` tag into the `.modinfo` section.
>
> The Rust `module!` macro lacked the ability to generate these tags,
> resulting in build warnings for Rust drivers (like the PWM driver) that
> call namespaced C functions.
>
> Modify the `module!` macro's internal parser (`ModuleInfo`) to accept a
> new optional field `imports_ns`, which takes an array of namespace
> strings. Update the code generator (`ModInfoBuilder::emit`) loop to
> iterate over these strings and emit the corresponding
> `import_ns=<NAMESPACE>` tags into the `.modinfo` section using the
> existing `#[link_section]` mechanism.
>
> This provides the necessary infrastructure for Rust modules to correctly
> declare their C namespace dependencies.
>
> Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
> ---
> rust/macros/module.rs | 8 ++++++++
> 1 file changed, 8 insertions(+)
Can I have some blessing to take this patch via my pwm tree? Would you
prefer a tag to also merge it into your tree? Then I would apply it on
top of 6.18-rc1 and provide a tag for you to merge.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/4] rust: macros: Add support for 'imports_ns' to module!
2025-10-31 7:47 ` Uwe Kleine-König
@ 2025-10-31 12:57 ` Miguel Ojeda
2025-10-31 13:12 ` Daniel Gomez
0 siblings, 1 reply; 20+ messages in thread
From: Miguel Ojeda @ 2025-10-31 12:57 UTC (permalink / raw)
To: Uwe Kleine-König, Luis Chamberlain, Petr Pavlu, Daniel Gomez,
Sami Tolvanen
Cc: Miguel Ojeda, Alex Gaynor, Michal Wilczynski, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich, Drew Fustini, Guo Ren,
Fu Wei, Stephen Rothwell, rust-for-linux, linux-kernel, linux-pwm,
linux-riscv, linux-modules
On Fri, Oct 31, 2025 at 8:47 AM Uwe Kleine-König <ukleinek@kernel.org> wrote:
>
> I already asked this in reply to the cover letter, but the question was
> lost on the way (no offense!), so I'm asking again. As it only really
> affects this patch, I'm doing that here:
>
> Can I have some blessing to take this patch via my pwm tree? Would you
> prefer a tag to also merge it into your tree? Then I would apply it on
> top of 6.18-rc1 and provide a tag for you to merge.
Sounds fine to me, but I am Cc'ing the modules maintainers since they
were not, just in case:
Acked-by: Miguel Ojeda <ojeda@kernel.org>
I think we don't need the tag/merge, unless someone else is looking to
use this (is there such a user? I may have missed it).
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/4] rust: macros: Add support for 'imports_ns' to module!
2025-10-31 12:57 ` Miguel Ojeda
@ 2025-10-31 13:12 ` Daniel Gomez
2025-11-01 8:06 ` Uwe Kleine-König
0 siblings, 1 reply; 20+ messages in thread
From: Daniel Gomez @ 2025-10-31 13:12 UTC (permalink / raw)
To: Miguel Ojeda, Uwe Kleine-König, Luis Chamberlain, Petr Pavlu,
Sami Tolvanen
Cc: Miguel Ojeda, Alex Gaynor, Michal Wilczynski, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Alice Ryhl, Trevor Gross, Danilo Krummrich, Drew Fustini, Guo Ren,
Fu Wei, Stephen Rothwell, rust-for-linux, linux-kernel, linux-pwm,
linux-riscv, linux-modules
On 31/10/2025 13.57, Miguel Ojeda wrote:
> On Fri, Oct 31, 2025 at 8:47 AM Uwe Kleine-König <ukleinek@kernel.org> wrote:
>>
>> I already asked this in reply to the cover letter, but the question was
>> lost on the way (no offense!), so I'm asking again. As it only really
>> affects this patch, I'm doing that here:
>>
>> Can I have some blessing to take this patch via my pwm tree? Would you
>> prefer a tag to also merge it into your tree? Then I would apply it on
>> top of 6.18-rc1 and provide a tag for you to merge.
>
> Sounds fine to me, but I am Cc'ing the modules maintainers since they
> were not, just in case:
>
> Acked-by: Miguel Ojeda <ojeda@kernel.org>
>
> I think we don't need the tag/merge, unless someone else is looking to
> use this (is there such a user? I may have missed it).
>
> Thanks!
>
> Cheers,
> Miguel
Uwe, that's okay from modules side:
Acked-by: Daniel Gomez <da.gomez@samsung.com>
FYI, I haven't merged Andreas's patches (rust: extend `module!` macro with
integer parameter support) yet, which add rust/macros/module.rs to our
MAINTAINERS file list. So, it's fine from modules side to go through your tree.
I was aiming to merge these patches along with some others for this week but
I've found a regression in kmod testing introduced in the latest v6.18-rc1,
which is taking me some extra time.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/4] rust: macros: Add support for 'imports_ns' to module!
2025-10-31 13:12 ` Daniel Gomez
@ 2025-11-01 8:06 ` Uwe Kleine-König
0 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2025-11-01 8:06 UTC (permalink / raw)
To: Daniel Gomez, Miguel Ojeda
Cc: Luis Chamberlain, Petr Pavlu, Sami Tolvanen, Miguel Ojeda,
Alex Gaynor, Michal Wilczynski, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, Drew Fustini, Guo Ren, Fu Wei,
Stephen Rothwell, rust-for-linux, linux-kernel, linux-pwm,
linux-riscv, linux-modules
[-- Attachment #1: Type: text/plain, Size: 1795 bytes --]
Hello Daniel, hello Miguel,
On Fri, Oct 31, 2025 at 02:12:29PM +0100, Daniel Gomez wrote:
> On 31/10/2025 13.57, Miguel Ojeda wrote:
> > On Fri, Oct 31, 2025 at 8:47 AM Uwe Kleine-König <ukleinek@kernel.org> wrote:
> > > Can I have some blessing to take this patch via my pwm tree? Would you
> > > prefer a tag to also merge it into your tree? Then I would apply it on
> > > top of 6.18-rc1 and provide a tag for you to merge.
> >
> > Sounds fine to me, but I am Cc'ing the modules maintainers since they
> > were not, just in case:
Good idea, thanks for catching that.
> > Acked-by: Miguel Ojeda <ojeda@kernel.org>
> > [...]
>
> Uwe, that's okay from modules side:
>
> Acked-by: Daniel Gomez <da.gomez@samsung.com>
Thanks for your Acks, I applied patches #1-#3 to
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next
(#4 was applied already).
> FYI, I haven't merged Andreas's patches (rust: extend `module!` macro with
> integer parameter support) yet, which add rust/macros/module.rs to our
> MAINTAINERS file list. So, it's fine from modules side to go through your tree.
> I was aiming to merge these patches along with some others for this week but
> I've found a regression in kmod testing introduced in the latest v6.18-rc1,
> which is taking me some extra time.
If the issues you mentioned are sorted out and you apply patches that
conflict with the changes I committed, please get in touch that we
coordinate if/how to sort them out.
Also if the need for a tag to share the commit arises, please coordinate
and don't just merge the just now created commits, as I like to be able
to rewrite my tree for late Acks etc. So I'd like to prepare and know
when commits become set in stone.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2025-11-01 8:07 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20251028122315eucas1p159b65037cf6f3f710c1917e2464399b5@eucas1p1.samsung.com>
2025-10-28 12:22 ` [PATCH 0/4] Introduce import_ns support for Rust Michal Wilczynski
[not found] ` <CGME20251028122316eucas1p2733987cd4c1eb8f83d6572d542e76d2a@eucas1p2.samsung.com>
2025-10-28 12:22 ` [PATCH 1/4] rust: macros: Add support for 'imports_ns' to module! Michal Wilczynski
2025-10-28 22:32 ` Elle Rhumsaa
2025-10-29 12:47 ` Alice Ryhl
2025-10-31 7:47 ` Uwe Kleine-König
2025-10-31 12:57 ` Miguel Ojeda
2025-10-31 13:12 ` Daniel Gomez
2025-11-01 8:06 ` Uwe Kleine-König
[not found] ` <CGME20251028122317eucas1p1e7c925502a83dd3324478c0209de08c3@eucas1p1.samsung.com>
2025-10-28 12:22 ` [PATCH 2/4] rust: pwm: Add module_pwm_platform_driver! macro Michal Wilczynski
2025-10-28 22:32 ` Elle Rhumsaa
[not found] ` <CGME20251028122318eucas1p17161f0e1f2281c868688e8a4cc3d8f68@eucas1p1.samsung.com>
2025-10-28 12:22 ` [PATCH 3/4] pwm: th1520: Use " Michal Wilczynski
2025-10-28 22:33 ` Elle Rhumsaa
2025-10-29 0:59 ` Troy Mitchell
[not found] ` <CGME20251028122318eucas1p1863a8b44efe27c28a1bcf427d2855c00@eucas1p1.samsung.com>
2025-10-28 12:22 ` [PATCH 4/4] pwm: th1520: Fix clippy warning for redundant struct field init Michal Wilczynski
2025-10-28 22:33 ` Elle Rhumsaa
2025-10-30 22:05 ` Uwe Kleine-König
2025-10-29 10:04 ` [PATCH 0/4] Introduce import_ns support for Rust Uwe Kleine-König
2025-10-29 11:07 ` Michal Wilczynski
2025-10-29 18:18 ` Miguel Ojeda
2025-10-29 18:51 ` Michal Wilczynski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).