linux/rust/helpers/platform.c
Danilo Krummrich a38dfd60fe 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>
2025-04-19 10:20:25 +02:00

18 lines
402 B
C

// SPDX-License-Identifier: GPL-2.0
#include <linux/platform_device.h>
void *rust_helper_platform_get_drvdata(const struct platform_device *pdev)
{
return platform_get_drvdata(pdev);
}
void rust_helper_platform_set_drvdata(struct platform_device *pdev, void *data)
{
platform_set_drvdata(pdev, data);
}
bool rust_helper_dev_is_platform(const struct device *dev)
{
return dev_is_platform(dev);
}