Commit graph

6 commits

Author SHA1 Message Date
Miguel Ojeda
51a486feac rust: io: fix broken intra-doc links to platform::Device
`platform` is not accessible from here.

Thus fix the intra-doc links by qualifying the paths a bit more.

Fixes: 1d0d4b2851 ("rust: io: mem: add a generic iomem abstraction")
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://lore.kernel.org/r/20250722085500.1360401-2-ojeda@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2025-07-22 11:08:59 +02:00
Miguel Ojeda
83fb616072 rust: io: fix broken intra-doc link to missing flags module
There is no `mod flags` in this case, unlike others. Instead, they are
associated constants for the `Flags` type.

Thus reword the sentence to fix the broken intra-doc link, providing
an example of constant and linking to it to clarify which ones we are
referring to.

Fixes: 493fc33ec2 ("rust: io: add resource abstraction")
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://lore.kernel.org/r/20250722085500.1360401-1-ojeda@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2025-07-22 11:08:59 +02:00
Danilo Krummrich
696b2a6ce9 rust: io: mem: enable IoRequest doc-tests
When introduced, the IoRequest doc-tests did depend on infrastructure
added in subsequent patches, hence they temporarily had to be disabled.

Now that we have the corresponding platform device infrastructure,
enable them.

Link: https://lore.kernel.org/r/DBG39YMN2TX6.1VR4PEQSI8PSG@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2025-07-20 19:43:14 +02:00
Daniel Almeida
bc4f9045a5 rust: platform: add resource accessors
The previous patches have added the abstractions for Resources and the
ability to map them and therefore read and write the underlying memory .

The only thing missing to make this accessible for platform devices is
to provide accessors that return instances of IoRequest<'a>. These
ensure that the resource are valid only for the lifetime of the platform
device, and that the platform device is in the Bound state.

Therefore, add these accessors. Also make it possible to retrieve
resources from platform devices in Rust using either a name or an index.

Acked-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
Link: https://lore.kernel.org/r/20250717-topics-tyr-platform_iomem-v15-3-beca780b77e3@collabora.com
[ Remove #[expect(dead_code)] from IoRequest::new() and move SAFETY
  comments right on top of unsafe blocks to avoid clippy warnings for
  some (older) clippy versions. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2025-07-20 19:43:14 +02:00
Daniel Almeida
1d0d4b2851 rust: io: mem: add a generic iomem abstraction
Add a generic iomem abstraction to safely read and write ioremapped
regions. This abstraction requires a previously acquired IoRequest
instance. This makes it so that both the resource and the device match,
or, in other words, that the resource is indeed a valid resource for a
given bound device.

A subsequent patch will add the ability to retrieve IoRequest instances
from platform devices.

The reads and writes are done through IoRaw, and are thus checked either
at compile-time, if the size of the region is known at that point, or at
runtime otherwise.

Non-exclusive access to the underlying memory region is made possible to
cater to cases where overlapped regions are unavoidable.

Acked-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
Link: https://lore.kernel.org/r/20250717-topics-tyr-platform_iomem-v15-2-beca780b77e3@collabora.com
[ Add #[expect(dead_code)] to avoid a temporary warning, remove
  unnecessary OF_ID_TABLE constants in doc-tests and ignore doc-tests
  for now to avoid a temporary build failure. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2025-07-20 19:43:14 +02:00
Daniel Almeida
493fc33ec2 rust: io: add resource abstraction
In preparation for ioremap support, add a Rust abstraction for struct
resource.

A future commit will introduce the Rust API to ioremap a resource from a
platform device. The current abstraction, therefore, adds only the
minimum API needed to get that done.

Acked-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Co-developed-by: Fiona Behrens <me@kloenk.dev>
Signed-off-by: Fiona Behrens <me@kloenk.dev>
Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
Link: https://lore.kernel.org/r/20250717-topics-tyr-platform_iomem-v15-1-beca780b77e3@collabora.com
[ Capitalize safety comments and end it with a period. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2025-07-20 19:43:04 +02:00