Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp67154rdb; Tue, 16 Jan 2024 15:21:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRfzmidWhmUBVme1O78T88ITuV1Cci/xLHGOdPmJUYPBX+2mFXsP8QSS77JCtu+fhL0taM X-Received: by 2002:a05:6a00:1401:b0:6d9:b302:d2ae with SMTP id l1-20020a056a00140100b006d9b302d2aemr10225910pfu.15.1705447291182; Tue, 16 Jan 2024 15:21:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705447291; cv=pass; d=google.com; s=arc-20160816; b=Ck6PTekTE5/Mv5iNUEahC5KtyGZ+kz1xPgTub1WoQEE5YHDrR+UHyD2HJxvQwm7Ng4 7DwNfjmv0EnQnl3n9Q2rMIz8M7/Unv7/YQJe2cOCIWAM+disJ2BOIXr/aTwZq7T3o0qr AMirTJ/wn9MiZeUEohyNLh/xdanDNiYs8TxSpxZIruBEw/J8uvCse5254bxXJyMq+5Le lxKfn2/l5HkQJPJsPDMjG4Tlsdem5px6npq7SQy73zoR3eraqSHtVNn5CjlFd5NnbjJf hqsl6aIA6EhfY6vkBoY7gZHxGVoQqz8FWRU1jeGz+3LKCk0+Kz4VEWtQJ7pjfkLpbpw2 QJSw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from; bh=BS6oor4M1b6KTZQ/xAElwbEC1KmGVeKtvjG/IfvfKPE=; fh=mB5qiQ7ps5IWvjuQS9+zcxjK3ZInVolb8UwIN1mvAmg=; b=jHQhFxEvBcao+R0yWGSZNCKBB+thLBT0/lkeo01986LqM6jbpyEnY1kVX5qZf2P88H gXlitpnZMitPeqfuQ338iong5wHimu9Z6DrhqAA7k3gy3X9Kjd2iIX82Ea8nnkfIM3xS A2bZLq1+pzUnUuPM9zx9htWdzSkLiJvzdLdxuxfyNMZ4bPRFEVODOpl3SckOABQq0QmV M4A73ovnBupGx/zZnUBnU2T/Zi/m+uiF8wsA//eOTf9QFlvcsEejG1nO/+51fO74qvpJ r5St00cU1dcwWJN4Igz2M5c0ICWr8hp1GxsPmciEveWRpqj1FQlkwzIl3BGQVzZfAqIf 1Xyg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=valentinobst.de); spf=pass (google.com: domain of linux-kernel+bounces-28368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28368-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h37-20020a632125000000b005b42f4443b7si12709567pgh.653.2024.01.16.15.21.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 15:21:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-28368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=valentinobst.de); spf=pass (google.com: domain of linux-kernel+bounces-28368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28368-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BFA432914C8 for ; Tue, 16 Jan 2024 23:11:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67E2D1D68B; Tue, 16 Jan 2024 23:11:26 +0000 (UTC) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A13231CFBF; Tue, 16 Jan 2024 23:11:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.126.134 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705446685; cv=none; b=Ncu/BSXxBq2D4wGnPLedFI+omQRjvgJ8gITh2ggCTrmSZKc55h4aiwi+R1ZeJ3K3+rJmP+ywECxPLp2vHXWN8QT4M9YdOnB/4iL3kJQW3mb6RUOSXXOAYwdlFIL98VpNMiAcriCe7FM1n3kzK2t8KGQyxoCDPG/f8JZumo8HjTw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705446685; c=relaxed/simple; bh=7MiaAc6W5AQRrrlOnAKaPlcWyVIYgzIpHuf2rLOhyAM=; h=Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:X-Provags-ID: X-Spam-Flag:UI-OutboundReport; b=sUbpgn8NEVcu4dQn5sPrRddv20GrDMluQabpuMsRo/pOCtGt7euZz+i8baXCIvxvyGvXxkdsFmkwkgnxCQYyOHZXvGkKzFyPXneJVPSOTheTrcm4wCvK2Boqxmhes6RsC/DTq0ZDz2WR2AZChqYiqwxkYYmtfvPGV730Iuwh1Ds= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=valentinobst.de; spf=pass smtp.mailfrom=valentinobst.de; arc=none smtp.client-ip=212.227.126.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=valentinobst.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=valentinobst.de Received: from localhost.localdomain ([217.245.156.100]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1Mtf39-1r8kba2vOh-00v5AO; Wed, 17 Jan 2024 00:11:09 +0100 From: Valentin Obst To: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho Cc: Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Valentin Obst Subject: [PATCH 10/13] rust: kernel: add doclinks Date: Wed, 17 Jan 2024 00:11:06 +0100 Message-ID: <20240116231106.168864-1-kernel@valentinobst.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116160141.165951-1-kernel@valentinobst.de> References: <20240116160141.165951-1-kernel@valentinobst.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:Z1CAg3hR5eUEZFAbmCMyk8n31l1hu3iGDoGIyb2TOJ9BQ6oZ66N xgh7g1pKxzlAf0WUIFDUKP6K/0/NaQU5EdLwvuiu82vHVUx/nWQVi7tTrEjqXbfEavV1qSq HrR7fNDf5NZEFnuJhaCpZnyoeNIhDAKWSzglIR75OwVbgo339n6EqHSswFeEYMbblYfusVm 74H2GunGWWkBY49egjj0A== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:JXSp30eQ2Vw=;J/G1TkfLaA88yilc2Ul0f19oerM eaVn2VYzWEyaVDNjswDND3Sg+cPLdiaIvpcHAGh0B0O/0TG3NrFW6pYG7WVLF9pTLsOTEtYul 4Hw+Di5Fx/4HRpJe0f71AnukTzancGUDaRdCOb7cTvJKI1j0GZuA1voIp6mKXunWnoBEOFR1C 9TPfdxc1ye9TTZb1xvbx9ppe4V4X0zan3jFJ2xIl2PxwgDCTL9f6sN81Bi182naEKhQ+qWs5e jj3WiPAsKOfxPInmfGLuihc4tQzGCpxuVrcqzkQoa/dktCSCnM45L0clZQyZKCDCQZISiVYoi h8mGL+tRfuV0z2cNzlq179xNC6C1G/p2MN2ywDR3se14Jiq5R+lGB7biUVlFsy5nCqrsdnsi0 6jCOzPoOF8i9Eu6Epul8OUrwkhTg1KN7NbsXw0pkzTMRl7EVpgXgDL6SxDHV2tMaU90VMYpMd RWdnpeTOGmv137kNwdJF6GK6jWduZEBl8BTmd65z+CA4FCQGVryHPJLK99trx1U3UV4fRNwuu DlvCUq9BeN9CpNjK1S0zlK+iG4LpnWefkshVw/rNSf8hHNGMcgQ3exSbFqwLwWCOadZuBIqcY RPskhAnNRaBr9DHLgWJDg70DoEZfE1JoCV/lqh0akdfvzCZrKuSBLHSakldF8XiyPXejt0skj /ta1coK7kGwz9wAXiVEBtZo+vOgKunEFMZXGBgxwgKHTYdcSQjPfT7EQaGT1330USsvtECsvt P8bJHL/b0EU2c2L6Q4j2KeVm7L9xCq2NuYdtI4UrGVV2PGkuHqp8NZ2J2bEqm/iDGi5xXeHIN hqe6I7kFUUoNMFRKgrRrcNbMDc4iUvsyLfEZUaWgZ1QF7XikFcOlDhLD+kmP4L5TWgsCofrM2 vqZIJquE0icTWfg== Add doclinks to existing documentation. Signed-off-by: Valentin Obst --- rust/kernel/sync/arc.rs | 6 +++--- rust/kernel/sync/lock.rs | 13 +++++++++--- rust/kernel/workqueue.rs | 45 ++++++++++++++++++++++++---------------- 3 files changed, 40 insertions(+), 24 deletions(-) diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs index 6c46b1affca5..936bc549a082 100644 --- a/rust/kernel/sync/arc.rs +++ b/rust/kernel/sync/arc.rs @@ -365,12 +365,12 @@ fn from(item: Pin>) -> Self { /// A borrowed reference to an [`Arc`] instance. /// /// For cases when one doesn't ever need to increment the refcount on the allocation, it is simpler -/// to use just `&T`, which we can trivially get from an `Arc` instance. +/// to use just `&T`, which we can trivially get from an [`Arc`] instance. /// /// However, when one may need to increment the refcount, it is preferable to use an `ArcBorrow` /// over `&Arc` because the latter results in a double-indirection: a pointer (shared reference) -/// to a pointer (`Arc`) to the object (`T`). An [`ArcBorrow`] eliminates this double -/// indirection while still allowing one to increment the refcount and getting an `Arc` when/if +/// to a pointer ([`Arc`]) to the object (`T`). An [`ArcBorrow`] eliminates this double +/// indirection while still allowing one to increment the refcount and getting an [`Arc`] when/if /// needed. /// /// # Invariants diff --git a/rust/kernel/sync/lock.rs b/rust/kernel/sync/lock.rs index 467249b39f71..f14179d19d4e 100644 --- a/rust/kernel/sync/lock.rs +++ b/rust/kernel/sync/lock.rs @@ -21,14 +21,21 @@ /// # Safety /// /// - Implementers must ensure that only one thread/CPU may access the protected data once the lock -/// is owned, that is, between calls to `lock` and `unlock`. -/// - Implementers must also ensure that `relock` uses the same locking method as the original +/// is owned, that is, between calls to [`lock`] and [`unlock`]. +/// - Implementers must also ensure that [`relock`] uses the same locking method as the original /// lock operation. +/// +/// [`lock`]: Backend::lock +/// [`unlock`]: Backend::unlock +/// [`relock`]: Backend::relock pub unsafe trait Backend { /// The state required by the lock. type State; - /// The state required to be kept between `lock` and `unlock`. + /// The state required to be kept between [`lock`] and [`unlock`]. + /// + /// [`lock`]: Backend::lock + /// [`unlock`]: Backend::unlock type GuardState; /// Initialises the lock. diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs index d900dc911149..ed3af3491b47 100644 --- a/rust/kernel/workqueue.rs +++ b/rust/kernel/workqueue.rs @@ -12,19 +12,19 @@ //! //! # The raw API //! -//! The raw API consists of the `RawWorkItem` trait, where the work item needs to provide an +//! The raw API consists of the [`RawWorkItem`] trait, where the work item needs to provide an //! arbitrary function that knows how to enqueue the work item. It should usually not be used //! directly, but if you want to, you can use it without using the pieces from the safe API. //! //! # The safe API //! -//! The safe API is used via the `Work` struct and `WorkItem` traits. Furthermore, it also includes -//! a trait called `WorkItemPointer`, which is usually not used directly by the user. +//! The safe API is used via the [`Work`] struct and [`WorkItem`] traits. Furthermore, it also +//! includes a trait called [`WorkItemPointer`], which is usually not used directly by the user. //! -//! * The `Work` struct is the Rust wrapper for the C `work_struct` type. -//! * The `WorkItem` trait is implemented for structs that can be enqueued to a workqueue. -//! * The `WorkItemPointer` trait is implemented for the pointer type that points at a something -//! that implements `WorkItem`. +//! * The [`Work`] struct is the Rust wrapper for the C `work_struct` type. +//! * The [`WorkItem`] trait is implemented for structs that can be enqueued to a workqueue. +//! * The [`WorkItemPointer`] trait is implemented for the pointer type that points at a something +//! that implements [`WorkItem`]. //! //! ## Example //! @@ -218,7 +218,9 @@ pub fn try_spawn(&self, func: T) -> Result<(), All } } -/// A helper type used in `try_spawn`. +/// A helper type used in [`try_spawn`]. +/// +/// [`try_spawn`]: Queue::try_spawn #[pin_data] struct ClosureWork { #[pin] @@ -258,9 +260,11 @@ fn run(mut this: Pin>) { /// /// # Safety /// -/// Implementers must ensure that any pointers passed to a `queue_work_on` closure by `__enqueue` +/// Implementers must ensure that any pointers passed to a `queue_work_on` closure by [`__enqueue`] /// remain valid for the duration specified in the guarantees section of the documentation for -/// `__enqueue`. +/// [`__enqueue`]. +/// +/// [`__enqueue`]: RawWorkItem::__enqueue pub unsafe trait RawWorkItem { /// The return type of [`Queue::enqueue`]. type EnqueueOutput; @@ -290,10 +294,11 @@ unsafe fn __enqueue(self, queue_work_on: F) -> Self::EnqueueOutput /// Defines the method that should be called directly when a work item is executed. /// -/// This trait is implemented by `Pin>` and `Arc`, and is mainly intended to be +/// This trait is implemented by `Pin>` and [`Arc`], and is mainly intended to be /// implemented for smart pointer types. For your own structs, you would implement [`WorkItem`] -/// instead. The `run` method on this trait will usually just perform the appropriate -/// `container_of` translation and then call into the `run` method from the [`WorkItem`] trait. +/// instead. The [`run`] method on this trait will usually just perform the appropriate +/// `container_of` translation and then call into the [`run`][WorkItem::run] method from the +/// [`WorkItem`] trait. /// /// This trait is used when the `work_struct` field is defined using the [`Work`] helper. /// @@ -309,8 +314,10 @@ pub unsafe trait WorkItemPointer: RawWorkItem { /// /// # Safety /// - /// The provided `work_struct` pointer must originate from a previous call to `__enqueue` where - /// the `queue_work_on` closure returned true, and the pointer must still be valid. + /// The provided `work_struct` pointer must originate from a previous call to [`__enqueue`] + /// where the `queue_work_on` closure returned true, and the pointer must still be valid. + /// + /// [`__enqueue`]: RawWorkItem::__enqueue unsafe extern "C" fn run(ptr: *mut bindings::work_struct); } @@ -328,12 +335,14 @@ pub trait WorkItem { /// Links for a work item. /// -/// This struct contains a function pointer to the `run` function from the [`WorkItemPointer`] +/// This struct contains a function pointer to the [`run`] function from the [`WorkItemPointer`] /// trait, and defines the linked list pointers necessary to enqueue a work item in a workqueue. /// /// Wraps the kernel's C `struct work_struct`. /// /// This is a helper type used to associate a `work_struct` with the [`WorkItem`] that uses it. +/// +/// [`run`]: WorkItemPointer::run #[repr(transparent)] pub struct Work { work: Opaque, @@ -409,7 +418,7 @@ pub unsafe fn raw_get(ptr: *const Self) -> *mut bindings::work_struct { /// } /// ``` /// -/// Note that since the `Work` type is annotated with an id, you can have several `work_struct` +/// Note that since the [`Work`] type is annotated with an id, you can have several `work_struct` /// fields by using a different id for each one. /// /// # Safety @@ -429,7 +438,7 @@ pub unsafe trait HasWork { /// Returns the offset of the [`Work`] field. /// /// This method exists because the [`OFFSET`] constant cannot be accessed if the type is not - /// `Sized`. + /// [`Sized`]. /// /// [`Work`]: Work /// [`OFFSET`]: HasWork::OFFSET -- 2.43.0