]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: device: support `dev_printk` on all devices
authorGary Guo <gary@garyguo.net>
Fri, 23 Jan 2026 17:58:38 +0000 (17:58 +0000)
committerDanilo Krummrich <dakr@kernel.org>
Sat, 24 Jan 2026 00:12:49 +0000 (01:12 +0100)
commita38cd1fea98990e20021823cea251e6cb088eeab
tree714fa55308d8b0ab943c1e56bca9b502670a6ba8
parente62e48adf76cc4432c6d749a940da8649f8cb5a7
rust: device: support `dev_printk` on all devices

Currently, `dev_*` only works on the core `Device`, but not on any other
bus or class device objects. This causes a pattern of
`dev_info!(pdev.as_ref())` which is not ideal.

This adds support of using these devices directly with `dev_*` macros, by
adding `AsRef` call inside the macro. To make sure we can still use just
`kernel::device::Device`, as `AsRef` implementation is added for it; this
is typical for types that is designed to use with `AsRef` anyway, for
example, `str` implements `AsRef<str>` and `Path` implements `AsRef<Path>`.

Signed-off-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260123175854.176735-1-gary@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/kernel/device.rs