From nobody Mon Feb 9 08:29:02 2026 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0B6633A71A for ; Tue, 6 Jan 2026 16:13:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767716011; cv=none; b=Eilb4RIInpUvF6XZo8LycqVc2Hi6KRao/UrAH6GfdAnWvPkOmFLstZ5WH1aJbIl8DaaUSh/4j4japP0jdWrzQHdbFwBtvgW7L47BCBNVIErPYClSe8HucTrX6CDEEt2OI90oV3fkiINfOLRxfpxxUq9SxjUVqi+45kuvC9ieAps= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767716011; c=relaxed/simple; bh=31K3z/TeTL27blPoZfDSHOqEMPWwg63C71FzL1KNDBY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=htXQSg876POiTGIO1ov6u1acP2nPMAcDHS2MOe9RnwxJVK7zccwHCEkMiYJAeTPo1xYJpYhqUBW8WnzUzw9SnDWQ0+y75ykDhIKIdEldwRVM63PbnOawJVkRGYaEPdTK72C7JxHn74yiNrevw2DLt082/dcEY3WoLUEhDIn2jKM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=js9H5iCD; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="js9H5iCD" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-59b685d2b79so719119e87.3 for ; Tue, 06 Jan 2026 08:13:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767716007; x=1768320807; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Rzq6sT7GcMk+zrj1ACCJmSl03CZtKzXScBbEctCNtgE=; b=js9H5iCDT1xuYoBwfMQoX8HBM4fQF7ARMJuPtWMXdN/SRJqmJ8Am75E2rITcGr4lev UQvHdP7wDWL1e9hb/I05KwrWlQyoWRxVFEyQN24shW2lOTNJgavuFdAi+b9jxd7KoHwI drlhKUUVeWtBLXnvuJnuWGIFbMCCvYmzYhVIROeyAhClVX8diUQdEZC6iIqU06gvNCwA V/5xHrhFbEig4JJK9SZLTo3bv8Tqr5rHjSoTZKKDfPNAhx7AJs0qdRwGLOm4/JuQaSQi Fu+CQN/+YayRAjQKJxIW9RjPVf1bXvmUr0S7IrJJKqIfaE6mpbg0uUy3OTtCbvPp9Fub 16sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767716007; x=1768320807; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Rzq6sT7GcMk+zrj1ACCJmSl03CZtKzXScBbEctCNtgE=; b=oCqu0/GSKe2eV6M9CEs9qsiYGRIwb3BQC/8vZK413SyqovRnk2QbB1CoIDoyDAh4Ur 2RokRgct9DwREQGnlcyC3Jkl88ztVtiTUfPXpaDyzOHFntG2EDR7wXyfox9jNytYz1Po Zkc48XzCO/UAteQF2MM7fHBWts9KEw35R85Ovl6t9A11O832g6dATmosxvuWaMtlcvAM tfMdFZAhGXa1LESnIhbXVMrZnQOCTkqugY0amHEzhmiD//qhxcUzOTmRusvU3RtMDpAd JFuBiyfpPjOud/xY89ON97ANdF5xnpDkZOkMcmPbXld4Z5ydif+cvWnqawBKeM80rnaG YLlg== X-Forwarded-Encrypted: i=1; AJvYcCWoUEpol64h0Ro3uLocRMCBBu0NudGb0Uk9ilbgn6LOmh9gj9WFcHRGtJfHiZdcHGiwgqW9PiWijNpCle4=@vger.kernel.org X-Gm-Message-State: AOJu0Yyl/7TJKPHd9+tCqbM6gZpEthqa2uOz6kF/p4J4kHHB70SSw4rh ujNQKpzN1hT1L1x7MaA5s9kdydhJF72U40crvSvuPX9jA0UfTJJg0e2J X-Gm-Gg: AY/fxX7+sCJWbAhqCm8YHerWbPJYuVKhHjPbhMCzKB1NBvHuP3gTZHrXPK76ypYAZvY 92EUcM1MZUei2jol7TYiOjlVKzOx9Rtmfv/oVxFtnaTSKuMdFCNcCjlQiY7ee+iPW411BlFwJFV oCf7DcwBlWYur95Z70l4gsIUw8tUcD87eFBq5aye3baIiyQi9iAD/4mv6rBkL+1H0HobAEXEffv bfqOviirRk5C5Cp4d6TfH6O/KHPcTCbkLr7mTUMdKKAHW2VoKfjZsBl8UKdpfdKUTeVofYnC3hp +CITs4wOpChXf94kvJgiFe1JZfr7NE42WJPVfXkECDe9nBPT3UwlsBPwvruHzR4xepxKmuVpjsV uYUCeEYh2bgX5g014Q0p2KILYlZO1vQhPEpr9oqF+2hnz4Ju63PDULamH7+S6eTzAnHBbRTjWBa A2EnKK5p817VEwNRpCm9bK0BOzfpAqJyVqcwgv4WjDsokH/Z/9RbW5fYQ9iVn/8uP/FrMOk5k7r NYkQQ== X-Google-Smtp-Source: AGHT+IEP/ySDqe0fUbCPgt5iLWx19W1TWyDR8oFVojZghcOpc//7QvyUeu7CEG1drmNLRunieI+/Uw== X-Received: by 2002:a05:6512:10c5:b0:594:2f1a:6ff0 with SMTP id 2adb3069b0e04-59b6520ebe3mr1228667e87.9.1767716006851; Tue, 06 Jan 2026 08:13:26 -0800 (PST) Received: from LT-5CG5341NQ4.nordic.imtech.com (37-33-180-149.bb.dnainternet.fi. [37.33.180.149]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-382eb91dfbdsm5256091fa.44.2026.01.06.08.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jan 2026 08:13:26 -0800 (PST) From: Kari Argillander Date: Tue, 06 Jan 2026 18:11:48 +0200 Subject: [PATCH RFC v2 10/11] rust: remove kernel::ModuleMetadata Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260106-this_module_fix-v2-10-842ac026f00b@gmail.com> References: <20260106-this_module_fix-v2-0-842ac026f00b@gmail.com> In-Reply-To: <20260106-this_module_fix-v2-0-842ac026f00b@gmail.com> To: Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Alexandre Courbot Cc: Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org, Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Kari Argillander X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1767715983; l=3446; i=kari.argillander@gmail.com; s=20251219; h=from:subject:message-id; bh=31K3z/TeTL27blPoZfDSHOqEMPWwg63C71FzL1KNDBY=; b=aYpSyfVvVzRtx2jZBA0uzYh2qT6PaE4SsBkyhK757T6LX63SFZ5UAGbmaYOT6qU//VGxRLdbb ZCWh1rldZrwA3wKCYGu9+ZCmt5Du50a7ox3x1R5Wt+7hiG44za8CUbs X-Developer-Key: i=kari.argillander@gmail.com; a=ed25519; pk=RwSxyhTpE3z4sywdDbIkC3q33ZQLNyhYWxT44iTY6r4= We have all information available also in THIS_MODULE. Use that instead. This way we do not need to do ugly casts from driver struct. Signed-off-by: Kari Argillander --- drivers/gpu/nova-core/nova_core.rs | 2 +- rust/kernel/firmware.rs | 2 +- rust/kernel/lib.rs | 6 ------ rust/macros/module.rs | 8 -------- samples/rust/rust_driver_auxiliary.rs | 2 +- 5 files changed, 3 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/nova-core/nova_core.rs b/drivers/gpu/nova-core/nov= a_core.rs index b98a1c03f13d..fbfbcc9446c0 100644 --- a/drivers/gpu/nova-core/nova_core.rs +++ b/drivers/gpu/nova-core/nova_core.rs @@ -19,7 +19,7 @@ mod util; mod vbios; =20 -pub(crate) const MODULE_NAME: &kernel::str::CStr =3D ::NAME; +pub(crate) const MODULE_NAME: &kernel::str::CStr =3D THIS_MODULE::name(); =20 kernel::module_pci_driver! { type: driver::NovaCore, diff --git a/rust/kernel/firmware.rs b/rust/kernel/firmware.rs index 11372a8f7be4..42bae71f6af1 100644 --- a/rust/kernel/firmware.rs +++ b/rust/kernel/firmware.rs @@ -206,7 +206,7 @@ macro_rules! module_firmware { const __MODULE_FIRMWARE_PREFIX: &'static $crate::str::CStr =3D= if cfg!(MODULE) { c"" } else { - ::NAME + crate::THIS_MODULE::name() }; =20 #[link_section =3D ".modinfo"] diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs index e7bc52a6ad42..dec1d05ebe7b 100644 --- a/rust/kernel/lib.rs +++ b/rust/kernel/lib.rs @@ -201,12 +201,6 @@ fn init() -> impl pin_init::PinInit { } } =20 -/// Metadata attached to a [`Module`] or [`InPlaceModule`]. -pub trait ModuleMetadata { - /// The name of the module as specified in the `module!` macro. - const NAME: &'static crate::str::CStr; -} - /// Equivalent to `THIS_MODULE` in the C API. /// /// C header: [`include/linux/init.h`](srctree/include/linux/init.h) diff --git a/rust/macros/module.rs b/rust/macros/module.rs index 7473a377a3bd..97635aed1598 100644 --- a/rust/macros/module.rs +++ b/rust/macros/module.rs @@ -374,14 +374,6 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream { ::kernel::create_this_module!(\"{name}\"); =20 =20 - /// The `LocalModule` type is the type of the module created b= y `module!`, - /// `module_pci_driver!`, `module_platform_driver!`, etc. - type LocalModule =3D {type_}; - - impl ::kernel::ModuleMetadata for {type_} {{ - const NAME: &'static ::kernel::str::CStr =3D c\"{name}\"; - }} - // Double nested modules, since then nobody can access the pub= lic items inside. mod __module_init {{ mod __module_init {{ diff --git a/samples/rust/rust_driver_auxiliary.rs b/samples/rust/rust_driv= er_auxiliary.rs index 7b729687811d..528866b953aa 100644 --- a/samples/rust/rust_driver_auxiliary.rs +++ b/samples/rust/rust_driver_auxiliary.rs @@ -18,7 +18,7 @@ use core::any::TypeId; use pin_init::PinInit; =20 -const MODULE_NAME: &CStr =3D ::NAME; +const MODULE_NAME: &CStr =3D THIS_MODULE::name(); const AUXILIARY_NAME: &CStr =3D c"auxiliary"; =20 struct AuxiliaryDriver; --=20 2.43.0