Commit 4c9f6a78 authored by Alice Ryhl's avatar Alice Ryhl Committed by Danilo Krummrich
Browse files

rust: driver: fix broken intra-doc links to example driver types



The `auxiliary` and `pci` modules are conditional on
`CONFIG_AUXILIARY_BUS` and `CONFIG_PCI` respectively. When these are
disabled, the intra-doc links to `auxiliary::Driver` and `pci::Driver`
break, causing rustdoc warnings (or errors with `-D warnings`).

error: unresolved link to `kernel::auxiliary::Driver`
  --> rust/kernel/driver.rs:82:28
   |
82 | //! [`auxiliary::Driver`]: kernel::auxiliary::Driver
   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `auxiliary` in module `kernel`

Fix this by making the documentation for these examples conditional on
the corresponding configuration options.

Fixes: 970a7c68 ("driver: rust: expand documentation for driver infrastructure")
Signed-off-by: default avatarAlice Ryhl <aliceryhl@google.com>
Reported-by: default avatarFUJITA Tomonori <fujita.tomonori@gmail.com>
Closes: https://lore.kernel.org/rust-for-linux/20251209.151817.744108529426448097.fujita.tomonori@gmail.com/
Link: https://patch.msgid.link/20251227-driver-types-v1-1-1916154fbe5e@google.com


Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
parent 3691fd19
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -33,7 +33,14 @@
//! }
//! ```
//!
//! For specific examples see [`auxiliary::Driver`], [`pci::Driver`] and [`platform::Driver`].
//! For specific examples see:
//!
//! * [`platform::Driver`](kernel::platform::Driver)
#![cfg_attr(
    CONFIG_AUXILIARY_BUS,
    doc = "* [`auxiliary::Driver`](kernel::auxiliary::Driver)"
)]
#![cfg_attr(CONFIG_PCI, doc = "* [`pci::Driver`](kernel::pci::Driver)")]
//!
//! The `probe()` callback should return a `impl PinInit<Self, Error>`, i.e. the driver's private
//! data. The bus abstraction should store the pointer in the corresponding bus device. The generic
@@ -79,7 +86,6 @@
//!
//! For this purpose the generic infrastructure in [`device_id`] should be used.
//!
//! [`auxiliary::Driver`]: kernel::auxiliary::Driver
//! [`Core`]: device::Core
//! [`Device`]: device::Device
//! [`Device<Core>`]: device::Device<device::Core>
@@ -87,8 +93,6 @@
//! [`DeviceContext`]: device::DeviceContext
//! [`device_id`]: kernel::device_id
//! [`module_driver`]: kernel::module_driver
//! [`pci::Driver`]: kernel::pci::Driver
//! [`platform::Driver`]: kernel::platform::Driver

use crate::error::{Error, Result};
use crate::{acpi, device, of, str::CStr, try_pin_init, types::Opaque, ThisModule};