rust: platform: impl TryFrom<&Device> for &platform::Device
authorDanilo Krummrich <dakr@kernel.org>
Fri, 21 Mar 2025 21:47:55 +0000 (22:47 +0100)
committerDanilo Krummrich <dakr@kernel.org>
Sat, 19 Apr 2025 08:20:25 +0000 (10:20 +0200)
commita38dfd60fe53a46a93517f02a061bb34c47946dc
tree1f51b84e91c35208b2573cebb8b38d12cdf73295
parenta095d0d1e4849ee25c28d43d713a8f433d7f1f27
rust: platform: impl TryFrom<&Device> for &platform::Device

Implement TryFrom<&device::Device> for &Device.

This allows us to get a &platform::Device from a generic &Device in a safe
way; the conversion fails if the device' bus type does not match with
the platform bus type.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20250321214826.140946-4-dakr@kernel.org
[ Support device context types, use dev_is_platform() helper. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
rust/helpers/platform.c
rust/kernel/platform.rs