mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
Currently Tyr defines a convenience type alias for its DRM device type, `TyrDrmDevice` but it does not use the alias outside of `tyr/driver.rs`. Replace `drm::Device<TyrDrmDriver>` with the alias `TyrDrmDevice` across the driver. This change will ease future upstream Tyr development by reducing the diffs when multiple series are touching these files. No functional changes are intended. Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260302202331.176140-1-deborah.brouwer@collabora.com Signed-off-by: Alice Ryhl <aliceryhl@google.com>
61 lines
1.6 KiB
Rust
61 lines
1.6 KiB
Rust
// SPDX-License-Identifier: GPL-2.0 or MIT
|
|
|
|
use kernel::{
|
|
drm,
|
|
prelude::*,
|
|
uaccess::UserSlice,
|
|
uapi, //
|
|
};
|
|
|
|
use crate::driver::{
|
|
TyrDrmDevice,
|
|
TyrDrmDriver, //
|
|
};
|
|
|
|
#[pin_data]
|
|
pub(crate) struct TyrDrmFileData {}
|
|
|
|
/// Convenience type alias for our DRM `File` type
|
|
pub(crate) type TyrDrmFile = drm::file::File<TyrDrmFileData>;
|
|
|
|
impl drm::file::DriverFile for TyrDrmFileData {
|
|
type Driver = TyrDrmDriver;
|
|
|
|
fn open(_dev: &drm::Device<Self::Driver>) -> Result<Pin<KBox<Self>>> {
|
|
KBox::try_pin_init(try_pin_init!(Self {}), GFP_KERNEL)
|
|
}
|
|
}
|
|
|
|
impl TyrDrmFileData {
|
|
pub(crate) fn dev_query(
|
|
ddev: &TyrDrmDevice,
|
|
devquery: &mut uapi::drm_panthor_dev_query,
|
|
_file: &TyrDrmFile,
|
|
) -> Result<u32> {
|
|
if devquery.pointer == 0 {
|
|
match devquery.type_ {
|
|
uapi::drm_panthor_dev_query_type_DRM_PANTHOR_DEV_QUERY_GPU_INFO => {
|
|
devquery.size = core::mem::size_of_val(&ddev.gpu_info) as u32;
|
|
Ok(0)
|
|
}
|
|
_ => Err(EINVAL),
|
|
}
|
|
} else {
|
|
match devquery.type_ {
|
|
uapi::drm_panthor_dev_query_type_DRM_PANTHOR_DEV_QUERY_GPU_INFO => {
|
|
let mut writer = UserSlice::new(
|
|
UserPtr::from_addr(devquery.pointer as usize),
|
|
devquery.size as usize,
|
|
)
|
|
.writer();
|
|
|
|
writer.write(&ddev.gpu_info)?;
|
|
|
|
Ok(0)
|
|
}
|
|
_ => Err(EINVAL),
|
|
}
|
|
}
|
|
}
|
|
}
|