Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp268782rdh; Sat, 23 Sep 2023 09:30:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJsLUmSs8lb0zhXc0KpLZbiYMT5gxb7hOY/e/WAwLSnpZWMcrsGbniacNYBPCPPtkHJepr X-Received: by 2002:a05:6a20:7f97:b0:14d:5796:bccd with SMTP id d23-20020a056a207f9700b0014d5796bccdmr2664232pzj.24.1695486652678; Sat, 23 Sep 2023 09:30:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695486652; cv=none; d=google.com; s=arc-20160816; b=z9dnE57EyGShRcJuaF5mE73fJFq+cThEK5SGVVSKi5xtAbftnIRQuS8qVOHKO2K9+6 zpxnW3fIYaMkChEsKoPLj0LD73CoWCZHKSvXNAOoy3xdxdAZ/5+R0hOVqrH1WwjCKBXt NIXyX0bybFynHb+EE/hTrudRhthQx2qgOdH9DjjPhMG9277hOwctb5XAdg/itLZIG2n/ dJ6Fh+EdDR2xwbf9gI1aFAtmubDlldiJq+PoALTpkp+9xY6Hdvoj0pcVELkkG8SxoDeL IIfjiSOR0iwMXuKu3qqNM2RmewA8tNRurnuvhntYNyINFt1un2EKUB6LI0/wveVZEdr5 jJeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WM0ZLVHvV+NZ5kwdSJi8dtI3pr22k4r3qhjNO/EWTSA=; fh=BpeH/FUAN0wxLMH3ClwVqRp0rua8Kbn4MIwmp4atozc=; b=Zq8a8h5cgYSJmyLDFyto/ierlHLkli8PLnA9VwPwKJhm1OHWwRqvtGewI0GknmfpDa nw4OC0JGvjx6XjviMr/+YVbYxFZbp7g+VB0011VMBLJs3Sw9MYqCeUOBdiAHfBfJJ/MX KYAlNFRIZZXwT7kCdTnpYAOMUx/vAoPYVTyFfxgwWaZT1VvnKF3no1OWIrlzCaljq4QE LMxxLMT5bFnFyF/kYPxyQELto1BzA2GpKNBecl4H6M/Y8keHYG1unwERg04PmplHLHNJ fKxVXirmH4grTWwhip69fETEiAZ1eh50fHrwIrY3oi5PRAH+QVZYF9t4bsSa9KBE+NLd 3ZxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dmFulhyA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id rm2-20020a17090b3ec200b002741a4172a2si9201224pjb.84.2023.09.23.09.30.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 09:30:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dmFulhyA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 05FAB80C5FB4; Sat, 23 Sep 2023 07:50:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231739AbjIWOuC (ORCPT + 99 others); Sat, 23 Sep 2023 10:50:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231330AbjIWOuB (ORCPT ); Sat, 23 Sep 2023 10:50:01 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 741C2180; Sat, 23 Sep 2023 07:49:55 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-578d78ffdbcso2383592a12.2; Sat, 23 Sep 2023 07:49:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695480595; x=1696085395; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WM0ZLVHvV+NZ5kwdSJi8dtI3pr22k4r3qhjNO/EWTSA=; b=dmFulhyAqpyhfQ5adNZuxE6scb3rZTL3Nn5EAET3YmwhbF/xz2q9wehAb8pjhGxqoE Eh/JjYzcNMcXgTovgtLhhw/+9oQf1mA5dNm3OY4JX4m3ae9eO/ynicA/yD+q9YMrnuwF T7ampmiI3BZ9lRES/buWylqHAwriB5w1c7yF4GB3Pu3kYFsNotKCDm3hom79RDm4CwJE aGKn0IZkIjYVCYMuLQPKsXOnJvHXo5pwdwIXs9X6GAgys942wYx+x/rLCduaxcM+VgSW 1sLw6Z+xwwFmibglsN39UENu07FV0gLMB8pmazF8K7fBFSTwlFMiMZB6TRfAxI3/rlQX L9Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695480595; x=1696085395; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WM0ZLVHvV+NZ5kwdSJi8dtI3pr22k4r3qhjNO/EWTSA=; b=W3HyuCDsnmhrlEkkvkax0VwLDrQ1z3F1plOvbTtro2TnI8mf/Naz34TeSQ86YAW01i dmKm1DWM/Xi19/dG3TfRVXOl6B/aTyEeA4dw7s4N2On6Uh5TRR5s+MtutgJRHWyzZhMq 6nyLExhaJ5bhMTGuIA45VAoKVA64lePG2ow9uLfrR5QySsEmbpoMwiB8qfsKbV/UJJEp zZZXwt8Ku0B8xKtZ7SfxR5OItffaqQvkX2AI/M0C9ta7fYRay82EME3DdWsYJEzkv6QE XYC84uzxtGHTIhk1U/ycL4NWYs0mBQeMiIUDmNd9YWgJf5CEpORzdVbQh+4qJg/CaWGM pPQw== X-Gm-Message-State: AOJu0Yz/l8FsYvN8o949jjCfIL6psa4Yn81FeK1muf1pLp7M86iAPJhE 80OsujksPMOWLfbN996uUNTRI55GTDc= X-Received: by 2002:a05:6a20:5482:b0:13a:fa9e:787b with SMTP id i2-20020a056a20548200b0013afa9e787bmr2611143pzk.12.1695480594833; Sat, 23 Sep 2023 07:49:54 -0700 (PDT) Received: from wedsonaf-dev.home.lan ([189.124.190.154]) by smtp.googlemail.com with ESMTPSA id s3-20020a170902ea0300b001c42d4b3675sm5392806plg.309.2023.09.23.07.49.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 07:49:54 -0700 (PDT) From: Wedson Almeida Filho To: rust-for-linux@vger.kernel.org Cc: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , linux-kernel@vger.kernel.org, Wedson Almeida Filho Subject: [PATCH v2 1/2] rust: arc: rename `ArcInner` to `WithRef` Date: Sat, 23 Sep 2023 11:49:37 -0300 Message-Id: <20230923144938.219517-2-wedsonaf@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230923144938.219517-1-wedsonaf@gmail.com> References: <20230923144938.219517-1-wedsonaf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 23 Sep 2023 07:50:01 -0700 (PDT) From: Wedson Almeida Filho This is in preparation for removing `ArcBorrow` and making `WithRef` public. This is a pure name change with no functional changes intended. Suggested-by: Björn Roy Baron Signed-off-by: Wedson Almeida Filho --- rust/kernel/sync/arc.rs | 20 ++++++++++---------- rust/kernel/sync/arc/std_vendor.rs | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs index 3d496391a9bd..86bff1e0002c 100644 --- a/rust/kernel/sync/arc.rs +++ b/rust/kernel/sync/arc.rs @@ -126,13 +126,13 @@ /// # Ok::<(), Error>(()) /// ``` pub struct Arc { - ptr: NonNull>, - _p: PhantomData>, + ptr: NonNull>, + _p: PhantomData>, } #[pin_data] #[repr(C)] -struct ArcInner { +struct WithRef { refcount: Opaque, data: T, } @@ -164,7 +164,7 @@ impl Arc { /// Constructs a new reference counted instance of `T`. pub fn try_new(contents: T) -> Result { // INVARIANT: The refcount is initialised to a non-zero value. - let value = ArcInner { + let value = WithRef { // SAFETY: There are no safety requirements for this FFI call. refcount: Opaque::new(unsafe { bindings::REFCOUNT_INIT(1) }), data: contents, @@ -201,13 +201,13 @@ pub fn init(init: impl Init) -> error::Result } impl Arc { - /// Constructs a new [`Arc`] from an existing [`ArcInner`]. + /// Constructs a new [`Arc`] from an existing [`WithRef`]. /// /// # Safety /// /// The caller must ensure that `inner` points to a valid location and has a non-zero reference /// count, one of which will be owned by the new [`Arc`] instance. - unsafe fn from_inner(inner: NonNull>) -> Self { + unsafe fn from_inner(inner: NonNull>) -> Self { // INVARIANT: By the safety requirements, the invariants hold. Arc { ptr: inner, @@ -243,7 +243,7 @@ fn into_foreign(self) -> *const core::ffi::c_void { unsafe fn borrow<'a>(ptr: *const core::ffi::c_void) -> ArcBorrow<'a, T> { // SAFETY: By the safety requirement of this function, we know that `ptr` came from // a previous call to `Arc::into_foreign`. - let inner = NonNull::new(ptr as *mut ArcInner).unwrap(); + let inner = NonNull::new(ptr as *mut WithRef).unwrap(); // SAFETY: The safety requirements of `from_foreign` ensure that the object remains alive // for the lifetime of the returned value. @@ -376,7 +376,7 @@ fn from(item: Pin>) -> Self { /// # Ok::<(), Error>(()) /// ``` pub struct ArcBorrow<'a, T: ?Sized + 'a> { - inner: NonNull>, + inner: NonNull>, _p: PhantomData<&'a ()>, } @@ -406,7 +406,7 @@ impl ArcBorrow<'_, T> { /// Callers must ensure the following for the lifetime of the returned [`ArcBorrow`] instance: /// 1. That `inner` remains valid; /// 2. That no mutable references to `inner` are created. - unsafe fn new(inner: NonNull>) -> Self { + unsafe fn new(inner: NonNull>) -> Self { // INVARIANT: The safety requirements guarantee the invariants. Self { inner, @@ -526,7 +526,7 @@ pub fn try_new(value: T) -> Result { /// Tries to allocate a new [`UniqueArc`] instance whose contents are not initialised yet. pub fn try_new_uninit() -> Result>, AllocError> { // INVARIANT: The refcount is initialised to a non-zero value. - let inner = Box::try_init::(try_init!(ArcInner { + let inner = Box::try_init::(try_init!(WithRef { // SAFETY: There are no safety requirements for this FFI call. refcount: Opaque::new(unsafe { bindings::REFCOUNT_INIT(1) }), data <- init::uninit::(), diff --git a/rust/kernel/sync/arc/std_vendor.rs b/rust/kernel/sync/arc/std_vendor.rs index a66a0c2831b3..4b30e5597ba5 100644 --- a/rust/kernel/sync/arc/std_vendor.rs +++ b/rust/kernel/sync/arc/std_vendor.rs @@ -5,7 +5,7 @@ //! "Apache-2.0 OR MIT" and adapted for kernel use. For copyright details, //! see . -use crate::sync::{arc::ArcInner, Arc}; +use crate::sync::{arc::WithRef, Arc}; use core::any::Any; impl Arc { @@ -17,7 +17,7 @@ pub fn downcast(self) -> core::result::Result, Self> if (*self).is::() { // SAFETY: We have just checked that the type is correct, so we can cast the pointer. unsafe { - let ptr = self.ptr.cast::>(); + let ptr = self.ptr.cast::>(); core::mem::forget(self); Ok(Arc::from_inner(ptr)) } -- 2.34.1