From patchwork Tue Jul 23 18:10:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13740257 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CEE0C3DA49 for ; Tue, 23 Jul 2024 18:12:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BC0F6B00A6; Tue, 23 Jul 2024 14:12:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 26BF76B00A7; Tue, 23 Jul 2024 14:12:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C1726B00A8; Tue, 23 Jul 2024 14:12:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E02D66B00A6 for ; Tue, 23 Jul 2024 14:12:09 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 890DEA2014 for ; Tue, 23 Jul 2024 18:12:09 +0000 (UTC) X-FDA: 82371811578.26.7965EA8 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id D2DB6140004 for ; Tue, 23 Jul 2024 18:12:07 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sLoQu3Om; spf=pass (imf23.hostedemail.com: domain of dakr@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721758304; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=enfuyaAqiO5xRtG3CPqMrpQx0/Ig7WkcMI5Ys/LAMD8=; b=6/5mh2Rb9mi3Dl9mGunoYd7HzwANyGeuyvfzIg7bguh0xXNy+hr7QT98KvWGo1ogCrz+Cz vQ6G/lOYx6XIL/xjIDa/YCproyXQLIMtkqOkdpheSOBoihmaOhNd9jI9ePw9Nxqtvtv24s w8EvG77WBXhYDovnpAuSgzC5P2yL6cs= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sLoQu3Om; spf=pass (imf23.hostedemail.com: domain of dakr@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721758304; a=rsa-sha256; cv=none; b=cpiML14BBLAnf2zry6N12Gj7+gfGmZ06H2csKyWP0SNnTcGhmn63UCMqd1BjEan1R8CZVA 4f5pOeIFXACQ94VhEcj4EQUx5DoRe7HL+i7lVPrbj+coQN3eDEai4RrU599m7IZ3jNmnE1 tYq/vfbXKOclFEr2HP1QebKOrqmfhU0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id EB86260DF6; Tue, 23 Jul 2024 18:12:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78AACC4AF0B; Tue, 23 Jul 2024 18:12:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721758326; bh=/9+EutwFn2+cS9gNKuR0E554iCROCZoKL1CdsGgwb8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sLoQu3OmR4kR03BZ8aJlI9lV2J2cK5q15+YM0g9Mk3OdIv99lwhllIfwFbxAjDPC7 HEnHKhrUzctHyMCZubcBLDIYnasV0oih0b4l8i8KKkDl1cTVVSZeu5e8LCNtXC9umw ePCdXJCWkjhzKSab4zyxHHvCfTN1E96TI1Y98S+fDFoQZzdkh2+NlSOv7IoxINuKCO Zk2LoBFwQLTP4+xHE4wyhAHcPm8YeMUUFW0+qqSp6flIxknGQD42hXLewq85y1cAth FLFbS9W39HLuUQ5Wph9CZsa9pgiQFbH6DqanRCeBaRElTVvTKwdx9dPpacwWGPZdEF c8Bc9x1nNVNmw== From: Danilo Krummrich To: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@samsung.com, aliceryhl@google.com, akpm@linux-foundation.org Cc: daniel.almeida@collabora.com, faith.ekstrand@collabora.com, boris.brezillon@collabora.com, lina@asahilina.net, mcanal@igalia.com, zhiw@nvidia.com, acurrid@nvidia.com, cjia@nvidia.com, jhubbard@nvidia.com, airlied@redhat.com, ajanulgu@redhat.com, lyude@redhat.com, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-mm@kvack.org, Danilo Krummrich Subject: [PATCH v2 13/23] rust: alloc: import kernel `Box` type in types.rs Date: Tue, 23 Jul 2024 20:10:02 +0200 Message-ID: <20240723181024.21168-14-dakr@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240723181024.21168-1-dakr@kernel.org> References: <20240723181024.21168-1-dakr@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: D2DB6140004 X-Stat-Signature: 61qax3ntcrpmzb8qqx1yx1h5br6o3cw8 X-HE-Tag: 1721758327-936974 X-HE-Meta: U2FsdGVkX19lWSG3Zmv3SnoXDfpdy8WTo4SJ3Wwbw9Pw58ifG/XYP+SttgLjn3cIO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KQVjtsT5X8Jl2gla8MbJaCNTWxwW3LXpont4deUOzgNMJW5+jpQRy0LfY+VP2jvGVybReD35d/UovQDoALnvdKeyg8I327IigSCu5FtOtw4adnMlsDCA/VjDyuTPZmEOC0uJkx1+Zqhp32IpWK0XFzz8SGuyDTxnOEj7d29Rl+m8TQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Now that we removed `BoxExt` and the corresponding includes in types.rs, add the new kernel `Box` type instead. Signed-off-by: Danilo Krummrich --- rust/kernel/types.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs index d67b37a5edb8..ee0063a20d89 100644 --- a/rust/kernel/types.rs +++ b/rust/kernel/types.rs @@ -2,7 +2,7 @@ //! Kernel types. -use crate::alloc::Allocator; +use crate::alloc::{Allocator, Box}; use crate::init::{self, PinInit}; use core::{ cell::UnsafeCell, @@ -67,15 +67,14 @@ unsafe fn try_from_foreign(ptr: *const core::ffi::c_void) -> Option { } } - -impl ForeignOwnable for crate::alloc::Box +impl ForeignOwnable for Box where A: Allocator, { type Borrowed<'a> = &'a T; fn into_foreign(self) -> *const core::ffi::c_void { - crate::alloc::Box::into_raw(self) as _ + Box::into_raw(self) as _ } unsafe fn borrow<'a>(ptr: *const core::ffi::c_void) -> &'a T { @@ -89,7 +88,7 @@ unsafe fn borrow<'a>(ptr: *const core::ffi::c_void) -> &'a T { unsafe fn from_foreign(ptr: *const core::ffi::c_void) -> Self { // SAFETY: The safety requirements of this function ensure that `ptr` comes from a previous // call to `Self::into_foreign`. - unsafe { crate::alloc::Box::from_raw(ptr as _) } + unsafe { Box::from_raw(ptr as _) } } }