From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D104D1A274; Fri, 6 Jun 2025 13:58:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749218313; cv=none; b=Mhj4gms/BeC6LHl7OSWoP3J+zrkhA4mcz38q/b3Uz2lPrYz7wee/rnjv3CfID2IVuz+PcK//OQ27aJYtyONlpztbGFLLxMjRx8sVLyjPKR59wSswL8PaPsdnQaUrzIHsnUAgxuhOxdLg69+qD9KWrLhiI41J7lWSE5Sr4Lv/qSg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749218313; c=relaxed/simple; bh=QyO94pd4hlnn9BKqJzgyhfcD8waNKskd+/HKP0CvpQg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ww8mU6cV9K1o3AopT1xdtfxLqa/LzXlCfSYy6+BROokUDewQrjyEJcHpFTcxlXJsnUhwD6WcbSfnuh/AdO6NbImBS3VxLTYSeKTLJhZwzB0FFfbtPldyGNh8w5OEENiYXdTR65j4zGXchPV/oMdGRdrPFiE1LdRKMykwBDjaiTo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=boD0tZeV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="boD0tZeV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC28FC4CEEB; Fri, 6 Jun 2025 13:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1749218311; bh=QyO94pd4hlnn9BKqJzgyhfcD8waNKskd+/HKP0CvpQg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=boD0tZeVz5UtG9+im6UihIJ+Z3HQVXLzuovQCa76Atf/9RHJd0Xy0unwT4wwKsQ+U IazlNovBJ4GSG7qM8+lXg86bB8VuD/12OnlxwVm1uCwbqBrW8OttMdBn3MyTyCX/+F KsHnXp2ftgx8rT65KtGmXpExDfPqjsWx6xc3RgjumuBb/LaoUAk/zru1lJg7Qa6BH+ haVxJHJCz808MLSPhmGUjOeyNUDeirD4ekFhd9PA8NGB7Q8ySMFMP0l+yE63y4hZ92 tw7ECnLbyvsMHl7sAIwFFTQzZXWhDhNbR+/zRiPCYRTyi9x6oOfMNjL1liJCxEvdGs fkfa4ID5MlTLA== Date: Fri, 6 Jun 2025 15:58:24 +0200 From: Danilo Krummrich To: Igor Korotin Cc: Miguel Ojeda , Alex Gaynor , Rob Herring , Saravana Kannan , "Rafael J . Wysocki" , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, devicetree@vger.kernel.org, Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Len Brown , Viresh Kumar , Wedson Almeida Filho , Alex Hung , Tamir Duberstein , FUJITA Tomonori , Xiangfei Ding Subject: Re: [PATCH v2 5/5] samples: rust: add ACPI match table example to platform driver Message-ID: References: <20250605161956.3658374-1-igor.korotin.linux@gmail.com> <20250605165231.3663810-1-igor.korotin.linux@gmail.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250605165231.3663810-1-igor.korotin.linux@gmail.com> On Thu, Jun 05, 2025 at 05:52:31PM +0100, Igor Korotin wrote: > Extend the Rust sample platform driver to probe using device/driver name > matching, OF ID table matching, or ACPI ID table matching. > > Signed-off-by: Igor Korotin > --- > samples/rust/rust_driver_platform.rs | 40 +++++++++++++++++++++++++++- > 1 file changed, 39 insertions(+), 1 deletion(-) > > diff --git a/samples/rust/rust_driver_platform.rs b/samples/rust/rust_driver_platform.rs > index e3992e7a71e9..ee0780c1d6ae 100644 > --- a/samples/rust/rust_driver_platform.rs > +++ b/samples/rust/rust_driver_platform.rs > @@ -17,10 +17,48 @@ struct SampleDriver { > [(of::DeviceId::new(c_str!("test,rust-device")), Info(42))] > ); > > +kernel::acpi_device_table!( > + ACPI_TABLE, > + MODULE_ACPI_TABLE, > + ::IdInfo, > + [(acpi::DeviceId::new(c_str!("TEST4321")), Info(0))] Can you please explain add a comment explaining how to make this probe? In the cover letter you mention: "Tested using QEMU with a custom SSDT that creates an ACPI device matching the sample Rust platform driver." > +); > + > +/// OF/ACPI match tables for Platform Driver implementation > +/// > +/// The platform::Driver requires declaration of both OF_ID_TABLE and > +/// ACPI_ID_TABLE, but if driver is not going to use either of them > +/// it can implement one of them or both as None. > +/// > +/// # Example: > +/// > +///``` > +/// impl platform::Driver for SampleDriver { > +/// type IdInfo = Info; > +/// const OF_ID_TABLE: Option> = None; > +/// const ACPI_ID_TABLE: Option> = None; > +/// > +/// fn probe( > +/// pdev: &platform::Device, > +/// info: Option<&Self::IdInfo>, > +/// ) -> Result>> { > +/// dev_dbg!(pdev.as_ref(), "Probe Rust Platform driver sample.\n"); > +/// > +/// if let Some(info) = info { > +/// dev_info!(pdev.as_ref(), "Probed with info: '{}'.\n", info.0); > +/// } > +/// > +/// let drvdata = KBox::new(Self { pdev: pdev.into() }, GFP_KERNEL)?; > +/// > +/// Ok(drvdata.into()) > +/// } > +/// } > +///``` I assume you want to make clear that both the ACPI and OF table are optional; not sure of that's required given their type is Option<...>. But I'm fine having this additional comment and example. Please make sure that it compiles though and remove everything unnecessary from probe() please. > + > impl platform::Driver for SampleDriver { > type IdInfo = Info; > const OF_ID_TABLE: Option> = Some(&OF_TABLE); > - const ACPI_ID_TABLE: Option> = None; > + const ACPI_ID_TABLE: Option> = Some(&ACPI_TABLE); > > fn probe( > pdev: &platform::Device, > -- > 2.43.0 >