Re: [PATCH v2 11/11] RFC: rust: driver: support map-like syntax for ID table

"Danilo Krummrich" <[email protected]>
Newsgroups org.kernel.vger.linux-pm,dev.linux.lists.driver-core,dev.linux.lists.nova-gpu,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-acpi,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci,org.kernel.vger.linux-pwm,org.kernel.vger.linux-usb,org.kernel.vger.netdev,org.kernel.vger.rust-for-linux
Message-ID <[email protected]>
On Mon Jun 29, 2026 at 2:39 PM CEST, Gary Guo wrote:
> diff --git a/rust/kernel/device_id.rs b/rust/kernel/device_id.rs
> index c81fca5b4986..5f4d191fce51 100644
> --- a/rust/kernel/device_id.rs
> +++ b/rust/kernel/device_id.rs
> @@ -183,6 +183,17 @@ macro_rules! module_device_table {
>          $table_type: literal, $device_id_ty: ty,
>          $table_name: ident, $id_info_type: ty,
>          [$(($id: expr, $info:expr $(,)?)),* $(,)?]
> +    ) => {
> +        $crate::module_device_table!(
> +            $table_type, $device_id_ty, $table_name, $id_info_type,
> +            {$($id=>$info,)*}
> +        );
> +    };
> +
> +    (
> +        $table_type: literal, $device_id_ty: ty,
> +        $table_name: ident, $id_info_type: ty,
> +        {$($id: expr => $info:expr),* $(,)?}
>      ) => {
>          #[export_name =
>              concat!("__mod_device_table__", ::core::line!(),
> diff --git a/samples/rust/rust_driver_pci.rs b/samples/rust/rust_driver_pci.rs
> index 2282191e6292..652819dff082 100644
> --- a/samples/rust/rust_driver_pci.rs
> +++ b/samples/rust/rust_driver_pci.rs
> @@ -75,10 +75,9 @@ struct SampleDriverData<'bound> {
>  kernel::pci_device_table!(
>      PCI_TABLE,
>      <SampleDriver as pci::Driver>::IdInfo,
> -    [(
> -        pci::DeviceId::from_id(pci::Vendor::REDHAT, 0x5),
> -        TestIndex::NO_EVENTFD
> -    )]
> +    {
> +        pci::DeviceId::from_id(pci::Vendor::REDHAT, 0x5) => TestIndex::NO_EVENTFD,
> +    }
>  );

This LGTM, do you want to send a follow-up series?

Thanks,
Danilo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.