From patchwork Thu Aug 1 00:02:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Danilo Krummrich X-Patchwork-Id: 13749352 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 90126C52D1D for ; Thu, 1 Aug 2024 00:08:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 133156B00AA; Wed, 31 Jul 2024 20:08:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0BCC56B00AC; Wed, 31 Jul 2024 20:08:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E78016B00AD; Wed, 31 Jul 2024 20:08:06 -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 C70886B00AA for ; Wed, 31 Jul 2024 20:08:06 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 82BC61C2DCB for ; Thu, 1 Aug 2024 00:08:06 +0000 (UTC) X-FDA: 82401738972.26.FEFF790 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf27.hostedemail.com (Postfix) with ESMTP id EC70F40002 for ; Thu, 1 Aug 2024 00:08:04 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=AYxUKb4V; spf=pass (imf27.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=1722470857; 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=ZE8k/WzEZ0nopWdJ6aywIWGXK0SDU6fjQFJzYLuntVY=; b=I3HgQxNqP26+ijwhkMYoNHLYi7aPyV/EIkWhhKfsLCvefbabP6w5H+w0btp3yMp10D5eOO 0YdRYWZVqiB8EwaLmB9/BDdT9Gr9rj5NmNRv+pWbN9sCR1lnehRSdrTDOYmkrqqU7Wl0Ox xDQ8+7g4ppz0B/Ii/JOcFuoL4hZY/Jw= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=AYxUKb4V; spf=pass (imf27.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=1722470857; a=rsa-sha256; cv=none; b=xQqeerh9cyOrTTJeKjTtPeaHvjZMNgPdHMeHKExmAlQK39kZQE2CGBj4Gz+VtN8iBajHqu uw7A5aVy7NM22gC9s3r5W/SXRdU4rTWNTrECvx940/NrPoWtdNFRYKRTTjBCH2z0dnbt0H dcf4kRJ9Yo7OwCYqpLyYJvYv9p0gXWQ= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 34C7962610; Thu, 1 Aug 2024 00:08:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4A4EC4AF0E; Thu, 1 Aug 2024 00:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722470883; bh=w6PgALWiEZslFA5r/x2p08ONTo0/JO09gDNDQem/zbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AYxUKb4V1+mWLyMLbmg/lrmQ/MpwgoFzMkBm5upnFiq0uNUepCersNXThbHOs+Ej4 vlt/uoEQ7BsgNjHg2m7bp+LWIoqeYyHeSFLzgioWidQeDHftOPwdv7rilxyAOS+WoO BGLdSDI7hLHpTiUtKzhWc+LxhbdrB1WEze5I2Vx7e0u518+fkzkgUwvnIa9MiTORkq o4iTRGGS69IqkRbQf+f7qsmMiSu3EDq3jLAcbTodaoS1v/AH00kGKq0CCJxtwr6+8X hJJXfsPN9BEBUDkmHG7lLcfbpSCl30d5gtzLttCAw1a8OZMyIXgUJEYM78Hcuy3oI1 2xs7GpyVzkJqw== 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 v3 13/25] rust: alloc: import kernel `Box` type in types.rs Date: Thu, 1 Aug 2024 02:02:12 +0200 Message-ID: <20240801000641.1882-14-dakr@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801000641.1882-1-dakr@kernel.org> References: <20240801000641.1882-1-dakr@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: EC70F40002 X-Stat-Signature: 5oner5cn5fdhnnmkhwjt5e5ihsrgy6z1 X-HE-Tag: 1722470884-869411 X-HE-Meta: U2FsdGVkX1+eYDUhA0qWPVhDwsVfeP02UxUKCDZThFpvIZabMwgP7RY2lHFkdQ+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/NgROXLU2NFrxhh3jQ8i9PtyELJF133nztukznTbHauTZ/h6qRQIEyqC47s7hXKz8+khQTG4CCDw/9Oqkfrnn+VoZ0zb1tskVxbwiSIIczxfHRExVwksf5SXJKUL2tpISfrfVfrSaZr3qDVwVHn9p3n3Y0eAow== 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs index 2aadf715b336..809653b9d945 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,14 +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 { @@ -88,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 _) } } }