From patchwork Mon Aug 5 15:19:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13753723 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 29AF2C3DA4A for ; Mon, 5 Aug 2024 15:21:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B26BD6B00A9; Mon, 5 Aug 2024 11:21:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AD4366B00AA; Mon, 5 Aug 2024 11:21:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9736D6B00AB; Mon, 5 Aug 2024 11:21:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 779266B00A9 for ; Mon, 5 Aug 2024 11:21:34 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 305E3A6B09 for ; Mon, 5 Aug 2024 15:21:34 +0000 (UTC) X-FDA: 82418556108.28.D182BAD Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id 733EFA0019 for ; Mon, 5 Aug 2024 15:21:32 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=O1oXHRoz; spf=pass (imf25.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=1722871230; 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=UdyeIfTQAHA24KV5GBPEk2+Gwk2HBIVUmVSILtDmhlk=; b=of7LvaOxD9iqLvZ8NxtrxJYHDzzw5A264DVtorIF5MW3rYoisK6/v3wAlxO23JElxdUNNk qB5iHYANd62cIcRWO4hNDDB7kS3/A6W8UmOpiJBwWQZutC28iBlesTGsikC6At3DgnXC7v vdN4fmx1IYLIHloo6Gk4jefb9aGRODo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722871230; a=rsa-sha256; cv=none; b=ApddJMo/4xMZFmcrwvYBEhZWXv7jd75I0LDqx0FvSK5o3625gChwprXKIDykqScPEbgCLg 26zt/GYA39ZxPwPBk1GI2p0Mba/znmEyhktLf5zKl/tp+06jna+UVFzctcP9XCegLY4q35 9zFOUnYTYJu0xxvN2yT9U8vp0bHA1I8= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=O1oXHRoz; spf=pass (imf25.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 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 98DF660CEE; Mon, 5 Aug 2024 15:21:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37E80C4AF0C; Mon, 5 Aug 2024 15:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722871291; bh=Lu3sR+WGYMF1UUYzfkZ9j2xNETNWcnAc7sJFrR4A4JQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O1oXHRozCxElqWOZx7zUrpBUJXCIC5CrgbAKeFrqcKlcOBNs9+XpKdfy265PO/e2n 0GUo+PujPXsi41M3hy94E7O07PgxZUBhl0OgrkJ0S6nULlWzvpKrgUIEBg0GWG7nJL E3mn/JFadLIHEbOEsL3MQWJ3IdCYLT0JfGQ6cj5mhTUxBnpdtJ14VGxCnUZRyUb4If 1HQONpQID/uAQoBZH93bhl3KmSVoVKgO5rLNsLNr5bwE8QvS1oMqiE/Xmuofhnq0fD vmMbWClGaZPm9KtavkN4Jyq2LQxp6+IOqM/891vzyrtx2CP/fH8mwZGZny4FXDatGR UEkMf7445vvKw== 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 14/28] rust: alloc: import kernel `Box` type in init.rs Date: Mon, 5 Aug 2024 17:19:33 +0200 Message-ID: <20240805152004.5039-15-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-Stat-Signature: 7uf4hd8197u7b45hki1bkz9a1y8s7rw7 X-Rspamd-Queue-Id: 733EFA0019 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1722871292-9911 X-HE-Meta: U2FsdGVkX18g4ZtcFqZKbSVO5m9zOeA6yJUYZInhVIb5e3uOiCLU+RpIL67ix3P/P5z4MglNtTTkNIh9f39T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N0BBlhutr4A8C2B5r033LvypGhbpRG2YLH7W2Nr+Dvy+6Y+FKMZmb9Hrv2LlsKK2oTkcBAJ909R09CPAqQ6aDhMApr77b1fXH47ePaHJzux59ZIL6V46oIlpneeem0vfaN3k3fYIt8vCMEEW8HFtAzW8wnK4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 init.rs, add the new kernel `Box` type instead. Reviewed-by: Alice Ryhl Signed-off-by: Danilo Krummrich --- rust/kernel/init.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rust/kernel/init.rs b/rust/kernel/init.rs index ae533305d40e..350582662964 100644 --- a/rust/kernel/init.rs +++ b/rust/kernel/init.rs @@ -211,7 +211,7 @@ //! [`pin_init!`]: crate::pin_init! use crate::{ - alloc::{AllocError, Allocator, Flags, KBox}, + alloc::{AllocError, Allocator, Box, Flags, KBox}, error::{self, Error}, sync::UniqueArc, types::{Opaque, ScopeGuard}, @@ -1147,7 +1147,7 @@ fn init(init: impl Init, flags: Flags) -> error::Result } } -impl InPlaceInit for crate::alloc::Box +impl InPlaceInit for Box where A: Allocator + 'static, { @@ -1156,13 +1156,13 @@ fn try_pin_init(init: impl PinInit, flags: Flags) -> Result, where E: From, { - let mut this = crate::alloc::Box::<_, A>::new_uninit(flags)?; + let mut this = Box::<_, A>::new_uninit(flags)?; let slot = this.as_mut_ptr(); // SAFETY: When init errors/panics, slot will get deallocated but not dropped, // slot is valid and will not be moved, because we pin it later. unsafe { init.__pinned_init(slot)? }; // SAFETY: All fields have been initialized. - Ok(unsafe { crate::alloc::Box::assume_init(this) }.into()) + Ok(unsafe { Box::assume_init(this) }.into()) } #[inline] @@ -1170,13 +1170,13 @@ fn try_init(init: impl Init, flags: Flags) -> Result where E: From, { - let mut this = crate::alloc::Box::<_, A>::new_uninit(flags)?; + let mut this = Box::<_, A>::new_uninit(flags)?; let slot = this.as_mut_ptr(); // SAFETY: When init errors/panics, slot will get deallocated but not dropped, // slot is valid. unsafe { init.__init(slot)? }; // SAFETY: All fields have been initialized. - Ok(unsafe { crate::alloc::Box::assume_init(this) }) + Ok(unsafe { Box::assume_init(this) }) } }