lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <82535e68-dde7-46b9-836f-cc6f2f8e7a78@de.bosch.com>
Date: Wed, 21 Jan 2026 07:52:48 +0100
From: Dirk Behme <dirk.behme@...bosch.com>
To: Gary Guo <gary@...yguo.net>, Greg Kroah-Hartman
	<gregkh@...uxfoundation.org>, "Rafael J. Wysocki" <rafael@...nel.org>,
	"Danilo Krummrich" <dakr@...nel.org>, Miguel Ojeda <ojeda@...nel.org>, Boqun
 Feng <boqun.feng@...il.com>, Björn Roy Baron
	<bjorn3_gh@...tonmail.com>, Benno Lossin <lossin@...nel.org>, "Andreas
 Hindborg" <a.hindborg@...nel.org>, Alice Ryhl <aliceryhl@...gle.com>, "Trevor
 Gross" <tmgross@...ch.edu>, Bjorn Helgaas <bhelgaas@...gle.com>,
	Krzysztof Wilczyński <kwilczynski@...nel.org>, "Abdiel
 Janulgue" <abdiel.janulgue@...il.com>, Daniel Almeida
	<daniel.almeida@...labora.com>, Robin Murphy <robin.murphy@....com>, "Dave
 Ertman" <david.m.ertman@...el.com>, Ira Weiny <ira.weiny@...el.com>, "Leon
 Romanovsky" <leon@...nel.org>, Igor Korotin <igor.korotin.linux@...il.com>
CC: <rust-for-linux@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<linux-pci@...r.kernel.org>
Subject: Re: [PATCH 2/4] rust: samples: remove redundant `.as_ref()` for
 `dev_*` print

Hi Gary

On 20/01/2026 19:11, Gary Guo wrote:
> From: Gary Guo <gary@...yguo.net>
> 
> This is now handled by the macro itself.
> 
> Signed-off-by: Gary Guo <gary@...yguo.net>
> ---
>   samples/rust/rust_dma.rs              |  2 +-
>   samples/rust/rust_driver_auxiliary.rs |  2 +-
>   samples/rust/rust_driver_faux.rs      |  2 +-
>   samples/rust/rust_driver_i2c.rs       |  4 ++--
>   samples/rust/rust_driver_pci.rs       |  6 +++---
>   samples/rust/rust_driver_platform.rs  |  2 +-
>   samples/rust/rust_i2c_client.rs       | 10 ++--------
>   7 files changed, 11 insertions(+), 17 deletions(-)
> 
> diff --git a/samples/rust/rust_dma.rs b/samples/rust/rust_dma.rs
> index f53bce2a73e3..a9ac7937ebaf 100644
> --- a/samples/rust/rust_dma.rs
> +++ b/samples/rust/rust_dma.rs
> @@ -57,7 +57,7 @@ impl pci::Driver for DmaSampleDriver {
>   
>       fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> impl PinInit<Self, Error> {
>           pin_init::pin_init_scope(move || {
> -            dev_info!(pdev.as_ref(), "Probe DMA test driver.\n");
> +            dev_info!(pdev, "Probe DMA test driver.\n");
>   
>               let mask = DmaMask::new::<64>();
>   
> diff --git a/samples/rust/rust_driver_auxiliary.rs b/samples/rust/rust_driver_auxiliary.rs
> index f148124fe81f..c20961f16835 100644
> --- a/samples/rust/rust_driver_auxiliary.rs
> +++ b/samples/rust/rust_driver_auxiliary.rs
> @@ -39,7 +39,7 @@ impl auxiliary::Driver for AuxiliaryDriver {
>   
>       fn probe(adev: &auxiliary::Device<Core>, _info: &Self::IdInfo) -> impl PinInit<Self, Error> {
>           dev_info!(
> -            adev.as_ref(),
> +            adev,
>               "Probing auxiliary driver for auxiliary device with id={}\n",
>               adev.id()
>           );
> diff --git a/samples/rust/rust_driver_faux.rs b/samples/rust/rust_driver_faux.rs
> index 5330b77ea986..99876c8e3743 100644
> --- a/samples/rust/rust_driver_faux.rs
> +++ b/samples/rust/rust_driver_faux.rs
> @@ -26,7 +26,7 @@ fn init(_module: &'static ThisModule) -> Result<Self> {
>   
>           let reg = faux::Registration::new(c"rust-faux-sample-device", None)?;
>   
> -        dev_info!(reg.as_ref(), "Hello from faux device!\n");
> +        dev_info!(reg, "Hello from faux device!\n");
>   
>           Ok(Self { _reg: reg })
>       }
> diff --git a/samples/rust/rust_driver_i2c.rs b/samples/rust/rust_driver_i2c.rs
> index 6be79f9e9fb5..e71b77196163 100644
> --- a/samples/rust/rust_driver_i2c.rs
> +++ b/samples/rust/rust_driver_i2c.rs
> @@ -56,11 +56,11 @@ fn probe(
>       }
>   
>       fn shutdown(idev: &i2c::I2cClient<Core>, _this: Pin<&Self>) {
> -        dev_info!(idev.as_ref(), "Shutdown Rust I2C driver sample.\n");
> +        dev_info!(idev, "Shutdown Rust I2C driver sample.\n");
>       }
>   
>       fn unbind(idev: &i2c::I2cClient<Core>, _this: Pin<&Self>) {
> -        dev_info!(idev.as_ref(), "Unbind Rust I2C driver sample.\n");
> +        dev_info!(idev, "Unbind Rust I2C driver sample.\n");
>       }
>   }
>   
> diff --git a/samples/rust/rust_driver_pci.rs b/samples/rust/rust_driver_pci.rs
> index ef04c6401e6a..d50828b642e5 100644
> --- a/samples/rust/rust_driver_pci.rs
> +++ b/samples/rust/rust_driver_pci.rs
> @@ -75,7 +75,7 @@ fn probe(pdev: &pci::Device<Core>, info: &Self::IdInfo) -> impl PinInit<Self, Er
>           pin_init::pin_init_scope(move || {
>               let vendor = pdev.vendor_id();
>               dev_dbg!(
> -                pdev.as_ref(),
> +                pdev,
>                   "Probe Rust PCI driver sample (PCI ID: {}, 0x{:x}).\n",
>                   vendor,
>                   pdev.device_id()
> @@ -91,7 +91,7 @@ fn probe(pdev: &pci::Device<Core>, info: &Self::IdInfo) -> impl PinInit<Self, Er
>                       let bar = bar.access(pdev.as_ref())?;
>   
>                       dev_info!(
> -                        pdev.as_ref(),
> +                        pdev,
>                           "pci-testdev data-match count: {}\n",
>                           Self::testdev(info, bar)?
>                       );
> @@ -112,7 +112,7 @@ fn unbind(pdev: &pci::Device<Core>, this: Pin<&Self>) {
>   #[pinned_drop]
>   impl PinnedDrop for SampleDriver {
>       fn drop(self: Pin<&mut Self>) {
> -        dev_dbg!(self.pdev.as_ref(), "Remove Rust PCI driver sample.\n");
> +        dev_dbg!(self.pdev, "Remove Rust PCI driver sample.\n");
>       }
>   }
>   
> diff --git a/samples/rust/rust_driver_platform.rs b/samples/rust/rust_driver_platform.rs
> index 9537dc38c563..f2229d176fb9 100644
> --- a/samples/rust/rust_driver_platform.rs
> +++ b/samples/rust/rust_driver_platform.rs
> @@ -180,7 +180,7 @@ fn properties_parse(dev: &device::Device) -> Result {
>   
>   impl Drop for SampleDriver {
>       fn drop(&mut self) {
> -        dev_dbg!(self.pdev.as_ref(), "Remove Rust Platform driver sample.\n");
> +        dev_dbg!(self.pdev, "Remove Rust Platform driver sample.\n");
>       }
>   }
>   
> diff --git a/samples/rust/rust_i2c_client.rs b/samples/rust/rust_i2c_client.rs
> index 8d2c12e535b0..72da5499f150 100644
> --- a/samples/rust/rust_i2c_client.rs
> +++ b/samples/rust/rust_i2c_client.rs
> @@ -113,10 +113,7 @@ fn probe(
>           pdev: &platform::Device<device::Core>,
>           _info: Option<&Self::IdInfo>,
>       ) -> impl PinInit<Self, Error> {
> -        dev_info!(
> -            pdev.as_ref(),
> -            "Probe Rust I2C Client registration sample.\n"
> -        );
> +        dev_info!(pdev, "Probe Rust I2C Client registration sample.\n");
>   
>           kernel::try_pin_init!( Self {
>               parent_dev: pdev.into(),
> @@ -130,10 +127,7 @@ fn probe(
>       }
>   
>       fn unbind(pdev: &platform::Device<device::Core>, _this: Pin<&Self>) {
> -        dev_info!(
> -            pdev.as_ref(),
> -            "Unbind Rust I2C Client registration sample.\n"
> -        );
> +        dev_info!(pdev, "Unbind Rust I2C Client registration sample.\n");
>       }
>   }


At least in samples/rust we have several places where we added helper 
variables for `dev`. For example in rust_driver_platform.rs [1] we have

let dev = pdev.as_ref();
dev_dbg!(dev, "Probe Rust Platform driver sample.\n");

Do we want to keep this?

I think there are places where this `dev` helper variable is used for 
printing, only. And there are places, like in the `probe()` of 
rust_driver_platform.rs, where the `dev` helper is additionally used 
elsewhere:

... Self::properties_parse(dev)?;

Hmm, I'm somehow under the impression what to use when in the end 
becomes slightly confusing in sum?

Best regards

Dirk

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/samples/rust/rust_driver_platform.rs#n106


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ