From nobody Wed Sep 10 05:59:24 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2C0573218CE for ; Mon, 8 Sep 2025 18:53:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757357590; cv=none; b=D4GyUAli9lY1DCT+eui12+UcRMoa1LOYCYk7kZNAFZOwnyYVnR/drYGMARV2PeThgONKs/FIkmsRn15TWCBC0p71vxQCKmub9U2IqjXIB2zX6vQzN90z64S1gtoENVX21ddCC48N0QPDWHsyFpXDiuo+4Xio3J1BpZj0VTNmVKc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757357590; c=relaxed/simple; bh=H/FSWL63xIZKSCywlgkiG5ai9QZb7obJazmxalID+Eg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PEDXO9LuYpQkNIPToIuQm+8rBtaK/8FMPIwYHrhDjE6w/il8clHkFJLx4af2VztlXY9oIZ7xCdkZELSzZlYOHbtqMJyDYocifUZwRt/TJDz+I72gdYzMIb1C0U4fsXaRt8smStcNOnyXfXr9IHZVsNNzEgPclLoPIHFYQ1psZrg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=QmWqxyUz; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QmWqxyUz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1757357588; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=opAGkIhbvhKIewW0fRaLtnVMRxdcOzp+hJRom4X2iRs=; b=QmWqxyUzp9NB8yIIVciia7dXgA3XcUGK1JH+d88ms88GXybwFquGPqMC3j33v/9Rox7d7C CU67RxTxgY5WwLWovrVvBmK0XWc17yW0X3hobAdZm+tcI6nfLk/wQjWhkLmun/ia7yF8Su 9Gm5ua56nYZx5WSx4vo8j9mvBLw4hGA= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-614-0w0UybFCMcy3QK-zazC4fA-1; Mon, 08 Sep 2025 14:53:04 -0400 X-MC-Unique: 0w0UybFCMcy3QK-zazC4fA-1 X-Mimecast-MFC-AGG-ID: 0w0UybFCMcy3QK-zazC4fA_1757357582 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 183B0195609F; Mon, 8 Sep 2025 18:53:02 +0000 (UTC) Received: from chopper.redhat.com (unknown [10.22.64.41]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 116BB1800446; Mon, 8 Sep 2025 18:52:56 +0000 (UTC) From: Lyude Paul To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Alice Ryhl Cc: Daniel Almeida , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Asahi Lina Subject: [PATCH v4 2/3] rust: drm: gem: Add DriverFile type alias Date: Mon, 8 Sep 2025 14:46:37 -0400 Message-ID: <20250908185239.135849-3-lyude@redhat.com> In-Reply-To: <20250908185239.135849-1-lyude@redhat.com> References: <20250908185239.135849-1-lyude@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Just to reduce the clutter with the File<=E2=80=A6> types in gem.rs. Signed-off-by: Lyude Paul Reviewed-by: Daniel Almeida Acked-by: Danilo Krummrich --- V3: * Rename ObjectFile to DriverFile rust/kernel/drm/gem/mod.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs index f5b19865d7453..ead723980b276 100644 --- a/rust/kernel/drm/gem/mod.rs +++ b/rust/kernel/drm/gem/mod.rs @@ -14,6 +14,13 @@ }; use core::{mem, ops::Deref, ptr::NonNull}; =20 +/// A type alias for retrieving a [`Driver`]s [`DriverFile`] implementatio= n from its +/// [`DriverObject`] implementation. +/// +/// [`Driver`]: drm::Driver +/// [`DriverFile`]: drm::file::DriverFile +pub type DriverFile =3D drm::File<<::Driver as drm::= Driver>::File>; + /// GEM object functions, which must be implemented by drivers. pub trait DriverObject: Sync + Send + Sized { /// Parent `Driver` for this object. @@ -23,19 +30,12 @@ pub trait DriverObject: Sync + Send + Sized { fn new(dev: &drm::Device, size: usize) -> impl PinInit; =20 /// Open a new handle to an existing object, associated with a File. - fn open( - _obj: &::Object, - _file: &drm::File<::File>, - ) -> Result { + fn open(_obj: &::Object, _file: &DriverFi= le) -> Result { Ok(()) } =20 /// Close a handle to an existing object, associated with a File. - fn close( - _obj: &::Object, - _file: &drm::File<::File>, - ) { - } + fn close(_obj: &::Object, _file: &DriverF= ile) {} } =20 /// Trait that represents a GEM object subtype @@ -79,7 +79,8 @@ extern "C" fn open_callback( raw_file: *mut bindings::drm_file, ) -> core::ffi::c_int { // SAFETY: `open_callback` is only ever called with a valid pointer to= a `struct drm_file`. - let file =3D unsafe { drm::File::<::File>::f= rom_raw(raw_file) }; + let file =3D unsafe { DriverFile::::from_raw(raw_file) }; + // SAFETY: `open_callback` is specified in the AllocOps structure for = `DriverObject`, // ensuring that `raw_obj` is contained within a `DriverObject` let obj =3D unsafe { <::Object as IntoGEMObj= ect>::from_raw(raw_obj) }; @@ -95,7 +96,7 @@ extern "C" fn close_callback( raw_file: *mut bindings::drm_file, ) { // SAFETY: `open_callback` is only ever called with a valid pointer to= a `struct drm_file`. - let file =3D unsafe { drm::File::<::File>::f= rom_raw(raw_file) }; + let file =3D unsafe { DriverFile::::from_raw(raw_file) }; =20 // SAFETY: `close_callback` is specified in the AllocOps structure for= `Object`, ensuring // that `raw_obj` is indeed contained within a `Object`. --=20 2.51.0