From nobody Tue Feb 10 09:57:55 2026 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (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 BE399313E1C for ; Tue, 28 Oct 2025 12:23:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761654201; cv=none; b=Dr1lLJuXa5fphDWyB2fWPJxOlNvQfrOiVm16xQIB4dixBM93DeXxe5/z9gFmaVS4/eK8YyJygo4XLckwESgXi9OMHw5rMNd7XgC93ss/SwZ4LFeMxdYn6AH09DvWbYXXzbSBsZoiop/phB9Fj7fAA+9sD+6O/eWBe+5tcG2CO7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761654201; c=relaxed/simple; bh=ilXtrzC3TR5zhx7isAOn4iceKAqSG1FEMM/Y2Bz7K1I=; h=From:Date:Subject:MIME-Version:Message-Id:In-Reply-To:To:Cc: Content-Type:References; b=ASoiLu68spZBdy/vJX+EDudDZLrW6uoJ56GFk7Hc6cMDi9U33udG3Pr8pI+LOvP/Heg8LBiiP4d2ZlRszUCemvskxfZU1iZ6jyCkJQ1frqjKEqozpJiDx1EREh3S5/RTpNRxew1QwHvoEckGfjdpnxIRNBxM74JqkZui+UNlBgk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=W39YBq8g; arc=none smtp.client-ip=210.118.77.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="W39YBq8g" Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20251028122317euoutp021f1d3399f76e0895ce03c2805da0c9f9~ypyiowVyt3173531735euoutp02h for ; Tue, 28 Oct 2025 12:23:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20251028122317euoutp021f1d3399f76e0895ce03c2805da0c9f9~ypyiowVyt3173531735euoutp02h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1761654197; bh=S7Qb8GD7QtIdkNg1sJYTbyBiBhynyekDP/0KBPsG5fc=; h=From:Date:Subject:In-Reply-To:To:Cc:References:From; b=W39YBq8gRkSQRtmiqYbhAmCfOap53lZ4hkYWh/z6xZuBhkZ4AR5bJvtKO6Kip+d8h AMu6xTCU4OjpicB+jSJ/h6BmVSExYtvmu5N+KxQwjqGxlcfGSDHesf2OTIOgE/S2MQ 6bcTdPwtJmmGqXghLFxtr96X2pbe2jwJcZBY9e8s= Received: from eusmtip2.samsung.com (unknown [203.254.199.222]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20251028122316eucas1p2733987cd4c1eb8f83d6572d542e76d2a~ypyh4s3HI0846208462eucas1p2I; Tue, 28 Oct 2025 12:23:16 +0000 (GMT) Received: from AMDC4942.eu.corp.samsungelectronics.net (unknown [106.210.136.40]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20251028122315eusmtip2aa7fbb6e4d59ddf58d1f0e5dabdc826e~ypyg2_QJ10792007920eusmtip2f; Tue, 28 Oct 2025 12:23:15 +0000 (GMT) From: Michal Wilczynski Date: Tue, 28 Oct 2025 13:22:32 +0100 Subject: [PATCH 1/4] rust: macros: Add support for 'imports_ns' to module! Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <20251028-pwm_fixes-v1-1-25a532d31998@samsung.com> In-Reply-To: <20251028-pwm_fixes-v1-0-25a532d31998@samsung.com> To: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Michal Wilczynski , Drew Fustini , Guo Ren , Fu Wei , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Cc: Stephen Rothwell , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, linux-riscv@lists.infradead.org X-Mailer: b4 0.15-dev X-CMS-MailID: 20251028122316eucas1p2733987cd4c1eb8f83d6572d542e76d2a X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20251028122316eucas1p2733987cd4c1eb8f83d6572d542e76d2a X-EPHeader: CA X-CMS-RootMailID: 20251028122316eucas1p2733987cd4c1eb8f83d6572d542e76d2a References: <20251028-pwm_fixes-v1-0-25a532d31998@samsung.com> 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=3D` 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=3D` 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 Acked-by: Daniel Gomez Acked-by: Miguel Ojeda Reviewed-by: Alice Ryhl Reviewed-by: Elle Rhumsaa --- rust/macros/module.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rust/macros/module.rs b/rust/macros/module.rs index 5ee54a00c0b65699596e660b2d4d60e64be2a50c..408cd115487514c8be79724d901= c676435696376 100644 --- a/rust/macros/module.rs +++ b/rust/macros/module.rs @@ -98,6 +98,7 @@ struct ModuleInfo { description: Option, alias: Option>, firmware: Option>, + imports_ns: Option>, } =20 impl ModuleInfo { @@ -112,6 +113,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self { "license", "alias", "firmware", + "imports_ns", ]; const REQUIRED_KEYS: &[&str] =3D &["type", "name", "license"]; let mut seen_keys =3D Vec::new(); @@ -137,6 +139,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self { "license" =3D> info.license =3D expect_string_ascii(it), "alias" =3D> info.alias =3D Some(expect_string_array(it)), "firmware" =3D> info.firmware =3D Some(expect_string_array= (it)), + "imports_ns" =3D> info.imports_ns =3D Some(expect_string_a= rray(it)), _ =3D> panic!("Unknown key \"{key}\". Valid keys are: {EXP= ECTED_KEYS:?}."), } =20 @@ -195,6 +198,11 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream { modinfo.emit("firmware", &fw); } } + if let Some(imports) =3D info.imports_ns { + for ns in imports { + modinfo.emit("import_ns", &ns); + } + } =20 // Built-in modules also export the `file` modinfo string. let file =3D --=20 2.34.1