Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1897020rdb; Wed, 31 Jan 2024 12:28:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBXlkEpow6ZVmbuNtxbyHOLLuGBkNw85aZTwrt4RgmgxxTNin/j4v/lV4UCWbvi4FK2Ae6 X-Received: by 2002:a62:5bc1:0:b0:6de:1cae:a53b with SMTP id p184-20020a625bc1000000b006de1caea53bmr92625pfb.8.1706732902871; Wed, 31 Jan 2024 12:28:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706732902; cv=pass; d=google.com; s=arc-20160816; b=rbRRGZm8DWpiVxQRyuZOG0umJJ3WS3BemZYKx2aGybtxFknKdkBNGIrLSboPF8cbDQ WZ63aC3j+HtP4niAijcIJlHE91BMEzsxL8nhxo8w0XMDDt9ouvJxi0kuwr+rDm1lislw NIc0Ko4e06mClMNOFxDEJI96qlIn3E7RUwVN7uyPNah4u9DNddtJZkK8aThaq7RehbWX 2leYIuf37slvmIfa8hO7ClHCxPRy/S/wxihXQAGfGK4ItekLGpBONBYr4vCCUZ6zbLFd zpLkdO10ukI/PmxDcIGPquT5M/GMC250spX0BB3NWsHUmZafGJly/oxpVobnQTe00GJV UiOg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=ME2KCEsP7OA1thHrJFksGB0bf+kxLWrWYzD24TXElM8=; fh=3mUFo1oqMErxZ3aFSaQY0eiH3o1sx5jzJ8932iJ3kXk=; b=BQYpKcWSoF+JXAhpCP8vioqm0al3KrT1Yb4IgTE8C3DHvmCmcw7zjSpnJAAns7VPY/ GtyhBKhzjdrvSsRuQgi5WZWmQhW7suQ3JOwb0vuQLEXgLxwLSKWWjEfDgZaXEEx/IsC4 2YacU/J2TdeJSIvArtw3MZxpZv0c2CjqWEhONz0dO+zNNsb/SGejLAbX9gPaPfiYzjV9 XWY6HtrL6HUGCKUQb2e5qnDyoeQDyUL7J8dV0RtEP9MGukLduJDuqHT71O20ma1atvqZ gRAEopLnvto66fB7Evpsa7TeOANGS/eaZzv8fDdk1vOAESKFIvhtAzDOqKCL7c3CXd/P czDg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="mxAIl+/U"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47072-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47072-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUxJZd+/GWAfXSoFOEOGeGyIkaPMu0+RXHMYLisHCdbETUU0m7C+xmeSNDas+G3/NUkxMs643HSpsECjR2A4WSVnooONs0cW38+VKzZVw== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l188-20020a6325c5000000b005d6dd7fab87si8754834pgl.884.2024.01.31.12.28.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 12:28:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47072-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="mxAIl+/U"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47072-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47072-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7803EB28164 for ; Wed, 31 Jan 2024 20:27:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 263CD13DB8C; Wed, 31 Jan 2024 20:24:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mxAIl+/U" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 89F383FE24; Wed, 31 Jan 2024 20:24:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706732649; cv=none; b=Ya8YX7y6ALWZx+Z7Crv1AodviFhXb6HEVyU0pYYqZBFpd+bIUxipNjxMVNVAictAvFVsk8GA97PJ83EtNTk97KRjSSHO1kf2t/VS0UpQ/i42raiXnPbPXvl8i7bdaSKkzZbOEDYT25zrw2DA8oc3p0ip6ZQy4fdJJNXjdc9dLyQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706732649; c=relaxed/simple; bh=GarbNP+2iuIwr6VxBD7bVTYXmjv1I2yVW0qul64RfeA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ifAvwbIittZgjmNb2h1EGYj2gr7DXgac+5/4HKNyb//UIFhCOoxkmHbjXwixnGWcfc7SePJZbkB80LX2dcA/ojUPv/bMLqkiMrxMptxFqZ//Z2FpIpqmL3uZjWOlXXDdw6dk+/kWb4BtIbbU3yatQsvtUauF0i3+wkkarLmidYg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mxAIl+/U; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 2AD03C41674; Wed, 31 Jan 2024 20:24:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706732649; bh=GarbNP+2iuIwr6VxBD7bVTYXmjv1I2yVW0qul64RfeA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=mxAIl+/UeHg4Y+01Q2LDQ93mLlXEwonoxVcEvnu9lOv2UspOYOR/y/3LFL0tPqrW3 471t7BwNr8mJjTr5CnlID2RyJ5XAF96K5IzrKdmUjNsodPXA0sK395b7Kice2z4mk6 sWxJrBxrKdw2INKj0FvwtzgU7ibOp4+QNf1ywH/YJToe2Q6R9jWPgraDgwLCsIdoc8 O6yPFHaKrLl1NsTm2f8scj5PSA2vD8NOroDPwrwQRizKr3L6vGKEg2jumicnqU9OW4 xLIlkNi1fpKAyGaiMJT8ydmNh81/lJo37OjOLK+5C3nAgIOoPCwMCwO/gOD1Ou2+qZ KsdltbFS/ML9A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 194AEC47DB3; Wed, 31 Jan 2024 20:24:09 +0000 (UTC) From: Valentin Obst via B4 Relay Date: Wed, 31 Jan 2024 21:23:32 +0100 Subject: [PATCH v3 10/12] rust: kernel: add doclinks Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240131-doc-fixes-v3-v3-10-0c8af94ed7de@valentinobst.de> References: <20240131-doc-fixes-v3-v3-0-0c8af94ed7de@valentinobst.de> In-Reply-To: <20240131-doc-fixes-v3-v3-0-0c8af94ed7de@valentinobst.de> To: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Valentin Obst , Trevor Gross , Martin Rodriguez Reboredo X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706732646; l=8480; i=kernel@valentinobst.de; s=20240131; h=from:subject:message-id; bh=+UXljfH8wlx7xaY4WJ467vxrBsuNMbjA2jEIytFPfIs=; b=rj2UxYJPHYdYlXqRXd4c6xgALp7XYJwoNoByMd3YVtyR7KVpB6mNm0amP9b+45CxN6jo5OOEf t0qmiR4CqhGCG/XkubDOwhShE9UQV1SqSjwNrDSxEV1N/xcgGZV/Rl3 X-Developer-Key: i=kernel@valentinobst.de; a=ed25519; pk=3s7U8y0mqkaiurgHSQQTYWOo2tw5HgzCg5vnJVfw37Y= X-Endpoint-Received: by B4 Relay for kernel@valentinobst.de/20240131 with auth_id=124 X-Original-From: Valentin Obst Reply-To: From: Valentin Obst Add doclinks to existing documentation. Signed-off-by: Valentin Obst Reviewed-by: Trevor Gross Reviewed-by: Martin Rodriguez Reboredo Reviewed-by: Alice Ryhl --- 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 10ccc0e39147..5b5c8efe427a 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