Re: [PATCH DNM 2/2] interconnect: Add a test Rust consumer driver

From: Daniel Almeida
Date: Wed Jul 23 2025 - 09:19:32 EST


Hi Konrad, commenting in case this driver goes forward.

> On 22 Jul 2025, at 18:14, Konrad Dybcio <konradybcio@xxxxxxxxxx> wrote:
>
> From: Konrad Dybcio <konrad.dybcio@xxxxxxxxxxxxxxxx>
>
> Do not merge, this is for illustration / CI purposes only.
>
> Signed-off-by: Konrad Dybcio <konrad.dybcio@xxxxxxxxxxxxxxxx>
> ---
> drivers/interconnect/Makefile | 1 +
> drivers/interconnect/test.rs | 47 +++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 48 insertions(+)
>
> diff --git a/drivers/interconnect/Makefile b/drivers/interconnect/Makefile
> index b0a9a6753b9dc30083781163ccc01dafcfcd0485..913b92080cc0b79846b74c239e14959b45b5450c 100644
> --- a/drivers/interconnect/Makefile
> +++ b/drivers/interconnect/Makefile
> @@ -2,6 +2,7 @@
>
> CFLAGS_core.o := -I$(src)
> icc-core-objs := core.o bulk.o debugfs-client.o
> +icc-core-$(CONFIG_RUST) += test.o
>
> obj-$(CONFIG_INTERCONNECT) += icc-core.o
> obj-$(CONFIG_INTERCONNECT_IMX) += imx/
> diff --git a/drivers/interconnect/test.rs b/drivers/interconnect/test.rs
> new file mode 100644
> index 0000000000000000000000000000000000000000..f4ba2000d0f1fd2d91aedf8aace0b0b54bfd48f2
> --- /dev/null
> +++ b/drivers/interconnect/test.rs
> @@ -0,0 +1,47 @@
> +// SPDX-License-Identifier: GPL-2.0
> +// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
> +
> +//! Test interconnect consumer driver
> +use kernel::{
> + c_str, device::Core, icc::*, module_platform_driver, of, of::DeviceId, platform, prelude::*,
> +};
> +
> +#[pin_data]
> +struct IccTestConsumerDriver {
> + #[pin]
> + path: IccPath,
> +}

I don’t think this does anything useful without PhantomPinned, but Benno is
the right person to chime in here.

More importantly though, why do you have #[pin] on IccPath?

> +
> +kernel::of_device_table!(
> + OF_TABLE,
> + MODULE_OF_TABLE,
> + <IccTestConsumerDriver as platform::Driver>::IdInfo,
> + [(DeviceId::new(c_str!("linux,icc-consumer-test")), ())]
> +);
> +
> +impl platform::Driver for IccTestConsumerDriver {
> + type IdInfo = ();
> + const OF_ID_TABLE: Option<of::IdTable<Self::IdInfo>> = Some(&OF_TABLE);
> +
> + fn probe(
> + pdev: &platform::Device<Core>,
> + _id_info: Option<&Self::IdInfo>,
> + ) -> Result<Pin<KBox<Self>>> {
> + let path = IccPath::of_get(pdev.as_ref(), None)?;
> +
> + path.set_bw(
> + IccBwUnit::from_megabits_per_sec(400),
> + IccBwUnit::from_megabits_per_sec(800),
> + )?;
> +
> + Ok(KBox::pin_init(Self { path }, GFP_KERNEL)?.into())
> + }
> +}
> +
> +module_platform_driver! {
> + type: IccTestConsumerDriver,
> + name: "icc-test-consumer",
> + authors: ["Konrad Dybcio <konrad.dybcio@xxxxxxxxxxxxxxxx>"],
> + description: "Test interconnect consumer driver",
> + license: "GPL",
> +}
>
> --
> 2.50.1
>
>

— Daniel