diff options
| author | Lorenzo Delgado <lnsdev@proton.me> | 2026-09-27 18:11:38 +0000 |
|---|---|---|
| committer | Danilo Krummrich <dakr@kernel.org> | 2026-10-02 00:07:02 +0200 |
| commit | 7db73c69c8311bfe72b3acbd6807d57cd755bdc7 (patch) | |
| tree | 0aa850c085144ed2e865e62a786e6c0c9f8c8e4d /kernel | |
| parent | 2581f023a5a67dda50c481b6c53838ee1a1c997e (diff) | |
| download | linux-next-7db73c69c8311bfe72b3acbd6807d57cd755bdc7.tar.gz linux-next-7db73c69c8311bfe72b3acbd6807d57cd755bdc7.zip | |
rust: io: convert ResourceSize into a transparent newtype
`ResourceSize` is a bare type alias for `resource_size_t`, so it
inherits every integer operation and `as` cast. That allows operations
that make no sense for the size of a hardware resource, such as mixing
it with unrelated integers or truncating it with a cast.
Wrap it in a `#[repr(transparent)]` newtype so each conversion at a
boundary is explicit. The representation is unchanged, so this is
ABI-identical; only the spelling at the FFI boundary changes. Provide
`from_raw`/`into_raw`, `From` in both directions, and a fallible
`TryFrom<ResourceSize> for usize`, since `resource_size_t` can be wider
than `usize` on 32-bit.
Update the producer, `Resource::size`, and its consumers in `Region`
and `request_region`.
Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://github.com/Rust-for-Linux/linux/issues/1203
Signed-off-by: Lorenzo Delgado <lnsdev@proton.me>
Link: https://patch.msgid.link/20260927-resource-size-newtype-v4-2-447a08af23fb@proton.me
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'kernel')
0 files changed, 0 insertions, 0 deletions
