From nobody Tue Dec 16 11:13:11 2025 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 40C371EEE0; Sun, 9 Mar 2025 17:57:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741543058; cv=none; b=CsTeD+ufNf4y+KhshyQMBXC/TGHDdueIeeozkLzDIprBlX3AAH7lQvmoIRilg8RccyyQd/IUWBG+CQ6cOJl9otzWZ0W84ZuMhK3r6Ahz1BCvKvo79NfeZQnjJbWZwkX63OKOam2jf/zgbAguWRpiakwRb0y/9qbBITxMxE6a7lE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741543058; c=relaxed/simple; bh=JyfmwxfkhDQWHiwgvjB+4jZD9oKTfxClcnB8sh3GvKI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VPGmQqXvwaWX8vRwuzXEDoTL1aoSpSbRSK0/EciTfQDUECzj5hpadow9ALVPRoIe1BYmhahooVvdqqxvRLEwl0v/83hNvUqGtA1HFvfqmvsfIWtLJu131J/vdaTN8sVjs/6y72RoOnnM9g+u25y4T/Mjn76p/FRdy6HX25KSPNA= 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=J68GrS83; arc=none smtp.client-ip=209.85.214.174 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="J68GrS83" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-22398e09e39so60448965ad.3; Sun, 09 Mar 2025 10:57:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741543053; x=1742147853; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5tE39xgV6/KwKFHWvHCsh8kdiR8Jp34269cQhzUG4M8=; b=J68GrS83DU3ND687GZORJTdLMofyzo3qF53qxaQs8n/Fl9D7FObZH32c+2FuM22cjE 72NoDLRGtrosqsW1CpqzPRwq6KzLhhCSn/iAYClYam6DDdMY9L2X2DRlgwoZbCu1B6eT UE/0ozQaS22vdf+qc0ul+QPtTveoCL5PW8742VmSXDcrwyagJI1Jr29iKnPrqcoAiDG5 l42Mc/dEnbvQtMJiIMnI1rJte5GtSCBHiuq7jlYcwyxxh2DI3Pcutx5i108CZaDvhtkQ R5AvqPlP8AKpVNBjbTDKdSPzAtaPjCtB7IPPCiodLGGehNWyTg1aYhLe3PEmIHvTMT5I uCvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741543053; x=1742147853; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5tE39xgV6/KwKFHWvHCsh8kdiR8Jp34269cQhzUG4M8=; b=VZqie5RKG+UzNPyz5JFOl7LUh5EDPBzA3Ej8TrpFpO7JIwIUkP24SQ3THRiqTZ6cm+ YK+6LH1DL7kcq1sR7q054fJl//yjkLzMAH6J2V2QoYZuAHqbrCbMVFYtjrx7t+RXgUq3 34qxKIofGnP/RHa5JKnnLOUtJxQI323DGOjbmB+yV0Vq+oqpzYFbDUy5dpqg/mtJ5i7f awbkAKo/Wa/wTBjgY45ilG1VI21b1dgV77X1YWpaUSs7GkhCbe42kuxav4mPfoU3nPeg XDjekpwPXPd2c2kVvnQNh3nUzml3ahn9SfOVvOZaIU1AJhpMMtdskPyP/kqOZC6MDL6T 9jvA== X-Forwarded-Encrypted: i=1; AJvYcCUisshKhW18Qp/+Vuse1pwm0ZDPs4rO44os1ZKd1Ny+93b1CV7rwu3KFhuMHvrfYEuqj9Xze2yhzXkLvfEqmPM=@vger.kernel.org, AJvYcCXNB7fwty4aTaA2UuNJFYhewb0gPJdkSBtjt/5Zp21Kp763vXjr0UQvGEKALbEy1Bz1T5DEC9rUbGTOxic=@vger.kernel.org X-Gm-Message-State: AOJu0YyvYiEhZsiFnBYdqR6He7aKRk82nKefdkZ5gHA4ZfsI3HWC/Upx QyCYDQeuohL/R5ZCfTPiiYyd4L4NADbpvyRlG+yn84VVqwF9iwCx X-Gm-Gg: ASbGncv0KTU1ADBPwdqAj98zHytDTbE2RcjEMvdsodfofTnTGs2bamqtahfBTl2Cs1A 7jvYbht9t+BgVM/PU1sV+BvlUt1hzVa/yZsDLTjNWL9YIGqUBhlYjJeO78b827+FJfZwj6+yRSF SNER/ral6DoYCh/6V+UwBUkRdw5pQ1FYDkHVpPQovmeI32aDN5bwdkgJ+29iPtOdvS8vs+dM0YD oA5ZnARgLPh1Pfd1ga5oljZkATSIxx3xHv14ah4aSkLvdFG1ZcaK6sYEXwg188EKfKRaoTMwqzO ibPojquKc8SRMS42Wh8aMOw2ixoYiG8bYIHCmafeQDY6aS07qvyOJToYu3n56qA= X-Google-Smtp-Source: AGHT+IFOhgvAcQT5DCLx8A3LfXsTB9h6JtOpQzqVzw3Q2GufFPipku7mN87Wq1Dv9tCRZ3MBwDdgdw== X-Received: by 2002:a17:902:e802:b0:220:da88:2009 with SMTP id d9443c01a7336-22428c12f78mr159958355ad.45.1741543053377; Sun, 09 Mar 2025 10:57:33 -0700 (PDT) Received: from linuxsimoes.. ([187.120.156.44]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-224109e944csm62675505ad.74.2025.03.09.10.57.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Mar 2025 10:57:32 -0700 (PDT) From: Guilherme Giacomo Simoes To: a.hindborg@kernel.org, alex.gaynor@gmail.com, aliceryhl@google.com, apw@canonical.com, arnd@arndb.de, aswinunni01@gmail.com, axboe@kernel.dk, benno.lossin@proton.me, bhelgaas@google.com, bjorn3_gh@protonmail.com, boqun.feng@gmail.com, dakr@kernel.org, dwaipayanray1@gmail.com, ethan.twardy@gmail.com, fujita.tomonori@gmail.com, gary@garyguo.net, gregkh@linuxfoundation.org, joe@perches.com, lukas.bulwahn@gmail.com, ojeda@kernel.org, pbonzini@redhat.com, tmgross@umich.edu, walmeida@microsoft.com, charmitro@posteo.net Cc: trintaeoitogc@gmail.com, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Miguel Ojeda Subject: [PATCH V9 1/2] rust: module: change author to an array Date: Sun, 9 Mar 2025 14:57:11 -0300 Message-Id: <20250309175712.845622-2-trintaeoitogc@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250309175712.845622-1-trintaeoitogc@gmail.com> References: <20250309175712.845622-1-trintaeoitogc@gmail.com> 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 Content-Type: text/plain; charset="utf-8" In the module! macro, the author field is currently of type String. Since modules can have multiple authors, this limitation prevents specifying more than one. Change the author field to Option> to allow creating modules with multiple authors. Additionally, rename the field from author to authors to make it explicit that it can refer to multiple authors. In modules that use the author field, update its value to an array of strings, and also rename it from author to authors. Suggested-by: Miguel Ojeda Link: https://github.com/Rust-for-Linux/linux/issues/244 Reviewed-by: Charalampos Mitrodimas Reviewed-by: Alice Ryhl Reviewed-by: Andreas Hindborg Signed-off-by: Guilherme Giacomo Simoes --- drivers/block/rnull.rs | 2 +- drivers/net/phy/ax88796b_rust.rs | 2 +- drivers/net/phy/qt2025.rs | 2 +- rust/kernel/net/phy.rs | 4 ++-- rust/kernel/pci.rs | 2 +- rust/kernel/platform.rs | 2 +- rust/macros/lib.rs | 6 +++--- rust/macros/module.rs | 12 +++++++----- samples/rust/rust_driver_faux.rs | 2 +- samples/rust/rust_driver_pci.rs | 2 +- samples/rust/rust_driver_platform.rs | 2 +- samples/rust/rust_minimal.rs | 2 +- samples/rust/rust_misc_device.rs | 2 +- samples/rust/rust_print_main.rs | 2 +- 14 files changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/block/rnull.rs b/drivers/block/rnull.rs index ddf3629d8894..d07e76ae2c13 100644 --- a/drivers/block/rnull.rs +++ b/drivers/block/rnull.rs @@ -27,7 +27,7 @@ module! { type: NullBlkModule, name: "rnull_mod", - author: "Andreas Hindborg", + authors: ["Andreas Hindborg"], description: "Rust implementation of the C null block driver", license: "GPL v2", } diff --git a/drivers/net/phy/ax88796b_rust.rs b/drivers/net/phy/ax88796b_ru= st.rs index 8c7eb009d9fc..bc73ebccc2aa 100644 --- a/drivers/net/phy/ax88796b_rust.rs +++ b/drivers/net/phy/ax88796b_rust.rs @@ -19,7 +19,7 @@ DeviceId::new_with_driver::() ], name: "rust_asix_phy", - author: "FUJITA Tomonori ", + authors: ["FUJITA Tomonori "], description: "Rust Asix PHYs driver", license: "GPL", } diff --git a/drivers/net/phy/qt2025.rs b/drivers/net/phy/qt2025.rs index 1ab065798175..520daeb42089 100644 --- a/drivers/net/phy/qt2025.rs +++ b/drivers/net/phy/qt2025.rs @@ -26,7 +26,7 @@ phy::DeviceId::new_with_driver::(), ], name: "qt2025_phy", - author: "FUJITA Tomonori ", + authors: ["FUJITA Tomonori "], description: "AMCC QT2025 PHY driver", license: "GPL", firmware: ["qt2025-2.0.3.3.fw"], diff --git a/rust/kernel/net/phy.rs b/rust/kernel/net/phy.rs index bb654a28dab3..a59469c785e3 100644 --- a/rust/kernel/net/phy.rs +++ b/rust/kernel/net/phy.rs @@ -790,7 +790,7 @@ const fn as_int(&self) -> u32 { /// DeviceId::new_with_driver::() /// ], /// name: "rust_sample_phy", -/// author: "Rust for Linux Contributors", +/// authors: ["Rust for Linux Contributors"], /// description: "Rust sample PHYs driver", /// license: "GPL", /// } @@ -819,7 +819,7 @@ const fn as_int(&self) -> u32 { /// module! { /// type: Module, /// name: "rust_sample_phy", -/// author: "Rust for Linux Contributors", +/// authors: ["Rust for Linux Contributors"], /// description: "Rust sample PHYs driver", /// license: "GPL", /// } diff --git a/rust/kernel/pci.rs b/rust/kernel/pci.rs index 4c98b5b9aa1e..f7b2743828ae 100644 --- a/rust/kernel/pci.rs +++ b/rust/kernel/pci.rs @@ -103,7 +103,7 @@ extern "C" fn remove_callback(pdev: *mut bindings::pci_= dev) { /// kernel::module_pci_driver! { /// type: MyDriver, /// name: "Module name", -/// author: "Author name", +/// authors: ["Author name"], /// description: "Description", /// license: "GPL v2", /// } diff --git a/rust/kernel/platform.rs b/rust/kernel/platform.rs index 50e6b0421813..1297f5292ba9 100644 --- a/rust/kernel/platform.rs +++ b/rust/kernel/platform.rs @@ -101,7 +101,7 @@ fn of_id_table() -> Option> { /// kernel::module_platform_driver! { /// type: MyDriver, /// name: "Module name", -/// author: "Author name", +/// authors: ["Author name"], /// description: "Description", /// license: "GPL v2", /// } diff --git a/rust/macros/lib.rs b/rust/macros/lib.rs index d61bc6a56425..7ce1cb891dfb 100644 --- a/rust/macros/lib.rs +++ b/rust/macros/lib.rs @@ -36,7 +36,7 @@ /// module!{ /// type: MyModule, /// name: "my_kernel_module", -/// author: "Rust for Linux Contributors", +/// authors: ["Rust for Linux Contributors"], /// description: "My very own kernel module!", /// license: "GPL", /// alias: ["alternate_module_name"], @@ -69,7 +69,7 @@ /// module!{ /// type: MyDeviceDriverModule, /// name: "my_device_driver_module", -/// author: "Rust for Linux Contributors", +/// authors: ["Rust for Linux Contributors"], /// description: "My device driver requires firmware", /// license: "GPL", /// firmware: ["my_device_firmware1.bin", "my_device_firmware2.bin"], @@ -88,7 +88,7 @@ /// # Supported argument types /// - `type`: type which implements the [`Module`] trait (required). /// - `name`: ASCII string literal of the name of the kernel module (req= uired). -/// - `author`: string literal of the author of the kernel module. +/// - `authors`: array of ASCII string literals of the authors of the ke= rnel module. /// - `description`: string literal of the description of the kernel mod= ule. /// - `license`: ASCII string literal of the license of the kernel modul= e (required). /// - `alias`: array of ASCII string literals of the alias names of the = kernel module. diff --git a/rust/macros/module.rs b/rust/macros/module.rs index cdf94f4982df..db16f0af0855 100644 --- a/rust/macros/module.rs +++ b/rust/macros/module.rs @@ -94,7 +94,7 @@ struct ModuleInfo { type_: String, license: String, name: String, - author: Option, + authors: Option>, description: Option, alias: Option>, firmware: Option>, @@ -107,7 +107,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self { const EXPECTED_KEYS: &[&str] =3D &[ "type", "name", - "author", + "authors", "description", "license", "alias", @@ -135,7 +135,7 @@ fn parse(it: &mut token_stream::IntoIter) -> Self { match key.as_str() { "type" =3D> info.type_ =3D expect_ident(it), "name" =3D> info.name =3D expect_string_ascii(it), - "author" =3D> info.author =3D Some(expect_string(it)), + "authors" =3D> info.authors =3D Some(expect_string_array(i= t)), "description" =3D> info.description =3D Some(expect_string= (it)), "license" =3D> info.license =3D expect_string_ascii(it), "alias" =3D> info.alias =3D Some(expect_string_array(it)), @@ -183,8 +183,10 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream { let info =3D ModuleInfo::parse(&mut it); =20 let mut modinfo =3D ModInfoBuilder::new(info.name.as_ref()); - if let Some(author) =3D info.author { - modinfo.emit("author", &author); + if let Some(authors) =3D info.authors { + for author in authors { + modinfo.emit("authors", &author); + } } if let Some(description) =3D info.description { modinfo.emit("description", &description); diff --git a/samples/rust/rust_driver_faux.rs b/samples/rust/rust_driver_fa= ux.rs index 048c6cb98b29..378bab4b587d 100644 --- a/samples/rust/rust_driver_faux.rs +++ b/samples/rust/rust_driver_faux.rs @@ -7,7 +7,7 @@ module! { type: SampleModule, name: "rust_faux_driver", - author: "Lyude Paul", + authors: ["Lyude Paul"], description: "Rust faux device sample", license: "GPL", } diff --git a/samples/rust/rust_driver_pci.rs b/samples/rust/rust_driver_pci= .rs index 1fb6e44f3395..364a0660a743 100644 --- a/samples/rust/rust_driver_pci.rs +++ b/samples/rust/rust_driver_pci.rs @@ -104,7 +104,7 @@ fn drop(&mut self) { kernel::module_pci_driver! { type: SampleDriver, name: "rust_driver_pci", - author: "Danilo Krummrich", + authors: ["Danilo Krummrich"], description: "Rust PCI driver", license: "GPL v2", } diff --git a/samples/rust/rust_driver_platform.rs b/samples/rust/rust_drive= r_platform.rs index 8120609e2940..f7a0f1b29d1d 100644 --- a/samples/rust/rust_driver_platform.rs +++ b/samples/rust/rust_driver_platform.rs @@ -43,7 +43,7 @@ fn drop(&mut self) { kernel::module_platform_driver! { type: SampleDriver, name: "rust_driver_platform", - author: "Danilo Krummrich", + authors: ["Danilo Krummrich"], description: "Rust Platform driver", license: "GPL v2", } diff --git a/samples/rust/rust_minimal.rs b/samples/rust/rust_minimal.rs index 4aaf117bf8e3..1fc7a1be6b6d 100644 --- a/samples/rust/rust_minimal.rs +++ b/samples/rust/rust_minimal.rs @@ -7,7 +7,7 @@ module! { type: RustMinimal, name: "rust_minimal", - author: "Rust for Linux Contributors", + authors: ["Rust for Linux Contributors"], description: "Rust minimal sample", license: "GPL", } diff --git a/samples/rust/rust_misc_device.rs b/samples/rust/rust_misc_devi= ce.rs index 40ad7266c225..d3785e7c0330 100644 --- a/samples/rust/rust_misc_device.rs +++ b/samples/rust/rust_misc_device.rs @@ -116,7 +116,7 @@ module! { type: RustMiscDeviceModule, name: "rust_misc_device", - author: "Lee Jones", + authors: ["Lee Jones"], description: "Rust misc device sample", license: "GPL", } diff --git a/samples/rust/rust_print_main.rs b/samples/rust/rust_print_main= .rs index 7e8af5f176a3..8ea95e8c2f36 100644 --- a/samples/rust/rust_print_main.rs +++ b/samples/rust/rust_print_main.rs @@ -8,7 +8,7 @@ module! { type: RustPrint, name: "rust_print", - author: "Rust for Linux Contributors", + authors: ["Rust for Linux Contributors"], description: "Rust printing macros sample", license: "GPL", } --=20 2.34.1 From nobody Tue Dec 16 11:13:11 2025 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 7648F1DEFCD; Sun, 9 Mar 2025 17:57:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741543064; cv=none; b=rsoRHDl+X8yTXXzW4U7jJ1WsW7VqhdTfBYALrI/HVr/kwOFftbSZ9KRo2f2CFYgq8qxIBKsEOcnXS3PCo1cbqowYiPIWfBJanlZ9HLgm/L300LwiiSdrvwAbanDXWFXHddoJy1lGRc7j64dCvpluvebA/CGKL83b6A/3VAsFd5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741543064; c=relaxed/simple; bh=KE9IESEtCkoJrMIAAiXk6ocqr27htlDirj/MxdU439o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=K3BlW89M8YuHGbkUifRfYMtCA5e56YOjFhU6yjeiVjAkgh6ShmZhOYtMWb49Ae0D27yyLlcwcsYFZLhjabl2crNAynG0M0JRumGs/wTOmpIN7iDZpsgBfx6P1ltzOWm6loEn/i5cYL5s1OlnhKxY69jXYF/9SHcqbgvKbtWfefE= 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=GpYyIJdn; arc=none smtp.client-ip=209.85.214.180 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="GpYyIJdn" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-22401f4d35aso60643485ad.2; Sun, 09 Mar 2025 10:57:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741543062; x=1742147862; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sq0x2h1DIzoTL0oLbffmbZ2PvairrfstI9Dgg8MRk8A=; b=GpYyIJdnfd69yo4I9epnnnVgr3el9z4ME097wAsMYorOIAhyGs3G8XhoBr8wGg/AIj TFFDirTZKF8vE6oacjtKnl2klz2PyY4zpme9rt0nsWwrEqagRngKpcWyrG9ZonImPgn9 jRMo3uJcYkFkyBCnVsFV2EDZzBwJ+KcbaQmJAPFf+bvBThDqjZLRqyXA954EYqwsO7Ok QJ2KEWRPeEIUWSSpbH5wt0KzHw6cf42q8eHha4UZEUacWGRQzuPjlDA42Pr/yrjaa6fn bjng0eHZnaeLMF509e7CSaadOMVPEJ6H56FGidQJAptfs5GZrcOqBDCrtZ9+1ZnXOIHv 5FWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741543062; x=1742147862; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sq0x2h1DIzoTL0oLbffmbZ2PvairrfstI9Dgg8MRk8A=; b=lcS78zUBfcEHDUKco1SL19Wst4bi3IgEJ6Tlfu2PQ+Vd/QmzeBpFL+Z8YWYUZxksPQ mTNXrhYHT7T/8caApgkFiHw1YpDAfVBaMt7ck/kMrwNh3JhkNfxAWQiUuJpTbnSZywn7 BAIMm6BcMlJtK01Ho5LQeKjHF65IlZ/PruNsc5A56NzZgDpsy0wtYNWWB9z919dTAeqh ROJb2gsAcG0bw7uiX3DGV3yZg4NebQvCdMMzurmYfhLHoKzi6HKRnaK8h+lTVgi/DaqB SuU+aUIYxK3Y0ogfMvfAEbtl/+cjDqrqsOgi2HoNzs5cWcq6iC9ceNt4V473jRfpePkM xksQ== X-Forwarded-Encrypted: i=1; AJvYcCUOMpgMfHwwmu09x9muQyUUu+vkMdtVY99Ffad4QzCQElM5v6J1JxK9ODFe6S3cqLdi9cWTzHxC9y06H5k=@vger.kernel.org, AJvYcCUOjxbwXRKnR3xhskSQAel5NU0AWkuwHrNE0dwUvCfMGoYBXcHiSPBCoPwCAdnVPBH7j7oYOKivRohIIq7cbPA=@vger.kernel.org X-Gm-Message-State: AOJu0YyqtYfvDuwLhuVDP/7eCECPCTSHfEC/WDpzg1KeiRilyR9qaHxB rLGaFl4oMURXKboY5t+ZXTO36hAH13KWBe34cRy62xR8PBErGB5+ X-Gm-Gg: ASbGncuwk1jTi4bxnPmI2Vl8Pcwk2ZNmSznWypra/ajI8Sozb/bka4kH2E1jwiNWXPD jroTXPzwwgixhYNSZcMea8kiKqj8OBlOrz8z+qsyJhlmIWTFruSuYcpMmEByUMYGqM395gMCbj1 PFgCsaoygRn86CuqhL0fnNEHACKJn7ppC3pmOSxU9afNEB/1GR9bifI0VHmwA/8o1+YFAT9b/qe YFiQqdHEXnKC3VcDPVoyKlkQyvICXlc4UxqjcNs1kjfmmg9PEVKsLFNm7eryFEdXGNqXyXuyAqO x5JAzrrOn/VgNYhZWbeJIkpSsZL1vqEOlLgv0x7knxHWzieP32Cea13brSinVAA= X-Google-Smtp-Source: AGHT+IEExef/AatcpGlIuzT1Dp5e6/YXCkSrikxpnNgsA5brOhWF3jQHsn7ltG8iK1auy0jbF4FYbw== X-Received: by 2002:a17:903:1b63:b0:223:50f0:b97 with SMTP id d9443c01a7336-22428bd456dmr163822125ad.52.1741543061587; Sun, 09 Mar 2025 10:57:41 -0700 (PDT) Received: from linuxsimoes.. ([187.120.156.44]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-224109e944csm62675505ad.74.2025.03.09.10.57.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Mar 2025 10:57:41 -0700 (PDT) From: Guilherme Giacomo Simoes To: a.hindborg@kernel.org, alex.gaynor@gmail.com, aliceryhl@google.com, apw@canonical.com, arnd@arndb.de, aswinunni01@gmail.com, axboe@kernel.dk, benno.lossin@proton.me, bhelgaas@google.com, bjorn3_gh@protonmail.com, boqun.feng@gmail.com, dakr@kernel.org, dwaipayanray1@gmail.com, ethan.twardy@gmail.com, fujita.tomonori@gmail.com, gary@garyguo.net, gregkh@linuxfoundation.org, joe@perches.com, lukas.bulwahn@gmail.com, ojeda@kernel.org, pbonzini@redhat.com, tmgross@umich.edu, walmeida@microsoft.com, charmitro@posteo.net Cc: trintaeoitogc@gmail.com, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V9 2/2] checkpatch: check format of Vec in modules Date: Sun, 9 Mar 2025 14:57:12 -0300 Message-Id: <20250309175712.845622-3-trintaeoitogc@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250309175712.845622-1-trintaeoitogc@gmail.com> References: <20250309175712.845622-1-trintaeoitogc@gmail.com> 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 Content-Type: text/plain; charset="utf-8" Implement a check to ensure that the author, firmware, and alias fields of the module! macro are properly formatted. * If the array contains more than one value, enforce vertical formatting. * If the array contains only one value, it may be formatted on a single line Signed-off-by: Guilherme Giacomo Simoes --- scripts/checkpatch.pl | 67 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 7b28ad331742..dda89ffedd1e 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2775,6 +2775,12 @@ sub process { $realcnt =3D 0; $linenr =3D 0; $fixlinenr =3D -1; + + my %array_parse_module; + my $expected_spaces; + my $spaces; + my $herevet_space_add; + foreach my $line (@lines) { $linenr++; $fixlinenr++; @@ -3567,6 +3573,67 @@ sub process { # ignore non-hunk lines and lines being removed next if (!$hunk_line || $line =3D~ /^-/); =20 +# check if the field is about author, firmware or alias from module! macro= and find malformed arrays + my $inline =3D 0; + my $key =3D ""; + my $add_line =3D $line =3D~ /^\+/; + + if ($line =3D~ /\b(authors|alias|firmware)\s*:\s*\[/) { + $inline =3D 1; + $array_parse_module{$1} =3D 1; + } + + my @keys =3D keys %array_parse_module; + if (@keys) { + $key =3D $keys[0]; + } + + if (!$expected_spaces && (!$add_line && $key && !$inline)) { + if ($line =3D~ /^([\t ]+)(\s)/) { + $expected_spaces =3D $1; + } + } + + if ($add_line && $key) { + my $herevet =3D "$here\n" . cat_vet($rawline) . "\n"; + + my $counter =3D () =3D $line =3D~ /"/g; + my $more_than_one =3D $counter > 2; + if ($more_than_one) { + WARN("ARRAY_MODULE_MACRO", + "Prefer each array element on a separate line\n". $herevet); + } elsif ($inline && $line !~ /\]/ && $line !~ /,/ && $line =3D~ /"/) { + WARN("ARRAY_MODULE_MACRO", + "Prefer to declare ] on the same line\n" . $herevet); + } elsif (!$inline && $line =3D~ /\]/ && $line =3D~ /\"/) { + WARN("ARRAY_MODULE_MACRO", + "Prefer a new line after the last value and before ]\n" . $hereve= t); + } elsif ($inline && $line =3D~ /,/ && $line !~ /\]/) { + WARN("ARRAY_MODULE_MACRO", + "Prefer a new line after [\n" . $herevet); + } + + if ($line =3D~ /^\+\s*([\t ]+)(\S)/) { + $spaces =3D $1; + $herevet_space_add =3D $herevet; + } + } + + if ($expected_spaces && $spaces) { + if (length($spaces) !=3D length($expected_spaces)) { + WARN("ARRAY_MODULE_MACRO", + "Prefer aligned parameters\n" . $herevet_space_add); + } + + $spaces =3D undef; + } + + #END OF ANALYZE FIELD + if ($line =3D~ /\]/) { + delete $array_parse_module{$key}; + $expected_spaces =3D undef; + } + #trailing whitespace if ($line =3D~ /^\+.*\015/) { my $herevet =3D "$here\n" . cat_vet($rawline) . "\n"; --=20 2.34.1