From c69072d3a10976e48da97758a78c35305c24eeba Mon Sep 17 00:00:00 2001 From: Danilo Krummrich Date: Fri, 20 Jun 2025 16:18:49 +0100 Subject: [PATCH] samples: rust: platform: don't call as_ref() repeatedly In SampleDriver::probe() don't call pdev.as_ref() repeatedly, instead introduce a dedicated &Device. Signed-off-by: Igor Korotin Reviewed-by: Dirk Behme Link: https://lore.kernel.org/r/20250620151849.281238-1-igor.korotin.linux@gmail.com Signed-off-by: Danilo Krummrich --- samples/rust/rust_driver_platform.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/samples/rust/rust_driver_platform.rs b/samples/rust/rust_driver_platform.rs index 4dcedb22a4bb..db2edcd49a48 100644 --- a/samples/rust/rust_driver_platform.rs +++ b/samples/rust/rust_driver_platform.rs @@ -36,13 +36,15 @@ impl platform::Driver for SampleDriver { pdev: &platform::Device, info: Option<&Self::IdInfo>, ) -> Result>> { - dev_dbg!(pdev.as_ref(), "Probe Rust Platform driver sample.\n"); + let dev = pdev.as_ref(); + + dev_dbg!(dev, "Probe Rust Platform driver sample.\n"); if let Some(info) = info { - dev_info!(pdev.as_ref(), "Probed with info: '{}'.\n", info.0); + dev_info!(dev, "Probed with info: '{}'.\n", info.0); } - Self::properties_parse(pdev.as_ref())?; + Self::properties_parse(dev)?; let drvdata = KBox::new(Self { pdev: pdev.into() }, GFP_KERNEL)?; -- 2.47.2