From patchwork Mon Aug 5 15:19:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13753722 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 A57DBC3DA4A for ; Mon, 5 Aug 2024 15:21:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E7CE6B00A7; Mon, 5 Aug 2024 11:21:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 26F716B00A8; Mon, 5 Aug 2024 11:21:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E8D46B00A9; Mon, 5 Aug 2024 11:21:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E1AAD6B00A7 for ; Mon, 5 Aug 2024 11:21:31 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 94DEBA6B09 for ; Mon, 5 Aug 2024 15:21:31 +0000 (UTC) X-FDA: 82418555982.29.8C1ECD5 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf19.hostedemail.com (Postfix) with ESMTP id 46C881A0015 for ; Mon, 5 Aug 2024 15:21:28 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DQYjAm2s; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of dakr@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=dakr@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722871240; a=rsa-sha256; cv=none; b=lFXnMJu9qvRkuE8/Gtn4rfuszGMGjjnxor0gpq7ELDsAIMnpcWgJkcqCjBNNk56GXNYytj hjSloXEzkavwUHuQhfEUM6Gb1zv4f+wxPcfWBoSdqHcBWaYnnCxfQC58Ar6i2FYuQrrmYW lpRtdjRNAa57/+1hhCmWnVDoUlVWkPQ= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DQYjAm2s; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of dakr@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=dakr@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722871240; 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=b75RPPaRKO6PTBp3GK4AfXTSCFaDnd5ZrMI2l87YSCc=; b=KJYgt9e4kRUg4loL7DABrue7+hiCRr/yANkFQ9hyCvGmDmoJLGPNGqr1gogiHKe4rXUYcZ b6Uby8rrW8DOsjEYJMxrOW+nwF0HlndBD5sKKKbgeMIwZjhS50Ini4Jfh4DdWnXi6fNQW8 NsGYGP+f1JOGB3UlBs9/ig6O4g3CUrE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 6E8A5CE0AD4; Mon, 5 Aug 2024 15:21:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8145C32782; Mon, 5 Aug 2024 15:21:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722871285; bh=pVB6WWQkYTknQoh+SglRWl5bEx9KaiouK24Dn9ENpJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DQYjAm2sn0N6rVEH3rEmI88pOgI8cRwdDI2RVbhONdO8s774rHc+/ZyM38gA+TMDz O/mocm5GbuEzpZg9UYh4Uwo3tfa9QKVP5kxgGdwkxx/2Hvom/KgwaRf5pVIRcDUZ/N YtdkmL3LWu/gXveCzX1gQHv6V1pHg1AJwxZ+Njgnuq8lvmWDSetGbAcqgsArJAmgrN Q8O7wXU6pwrOYxUmXiKZFxHufxGJ7Vl3EHSde2TIC27WBazAjWKa7npwrVpWmxmqtq Sti3WOICk5Z7VUtMscEnq3sH83gFrz8TCDCqC8vn5tEk/WU2R4Ti+ANG/IvBqcYkAL sVr3GPTAsR56Q== 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 v4 13/28] rust: alloc: import kernel `Box` type in types.rs Date: Mon, 5 Aug 2024 17:19:32 +0200 Message-ID: <20240805152004.5039-14-dakr@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240805152004.5039-1-dakr@kernel.org> References: <20240805152004.5039-1-dakr@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 46C881A0015 X-Stat-Signature: tp6o67x33ehdanfboqxo1pshwdgeuu5r X-Rspam-User: X-HE-Tag: 1722871288-980441 X-HE-Meta: U2FsdGVkX1+3/TBaUqBEkyQQ16utETeDFHdFdWeP1g5J1MMHMrCWK5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BVWU+/uoQriU6mfE3syO0Ig60jqKo1nSa9Po+RdS9DcOtfOCyjDQ6kKNNHp5rtB2L3r3vAs+hLaElfeNPb9TplnppuR2dsE1g505nkWkTpODQE6GBUqL7FKGc90uOmXfP/WR6xhiJSY3MRsaQ8BTnMpFnPHtYCFerdyJO4rXHgcbzej+EJJHdS9fGKLhGjQd6sZgGrQuO8= 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. Reviewed-by: Alice Ryhl Signed-off-by: Danilo Krummrich --- rust/kernel/types.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs index b80a3b2b62ac..25761da5a816 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, @@ -68,14 +68,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,11 +89,11 @@ 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 _) } } } -impl ForeignOwnable for Pin> +impl ForeignOwnable for Pin> where A: Allocator, { @@ -101,7 +101,7 @@ impl ForeignOwnable for Pin> fn into_foreign(self) -> *const core::ffi::c_void { // SAFETY: We are still treating the box as pinned. - crate::alloc::Box::into_raw(unsafe { Pin::into_inner_unchecked(self) }) as _ + Box::into_raw(unsafe { Pin::into_inner_unchecked(self) }) as _ } unsafe fn borrow<'a>(ptr: *const core::ffi::c_void) -> Pin<&'a T> { @@ -118,7 +118,7 @@ unsafe fn borrow<'a>(ptr: *const core::ffi::c_void) -> Pin<&'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 { Pin::new_unchecked(crate::alloc::Box::from_raw(ptr as _)) } + unsafe { Pin::new_unchecked(Box::from_raw(ptr as _)) } } }