On Wed, 25 Nov 2026 19:46:51 -0300, Daniel Almeida wrote:
> drm/tyr: reduce the number of `as` casts
>
> An `as` cast silently drops the bits that do not fit the target type,
> and nothing at the cast shows whether that can happen. Tyr has 86 of
> them, as counted by `clippy::as_conversions`. This series removes 62.
>
> Patches 1 to 4 change the type a value is kept in, so that it needs no
> cast. Patches 5 to 8 use what the kernel already provides:
> `SizeConstants`, `From`, `FromSafeCast`, `cv!` and the `all_bits()` of
> `impl_flags!`. Patches 10 and 11 move repeated casts into one place.
>
> [...]
Applied to drm-rust-next, thanks!
[01/13] drm/tyr: convert SeatInfo::slot from u8 to usize
commit: 2516151e6991240409286ddcce0303ef58989cf8
[02/13] drm/tyr: convert VmAsData::va_bits from u8 to u32
commit: a81bfbb59fb8e366940745393a9f3ea9e1c1c7c1
[03/13] drm/tyr: convert the lock region exponents from u8 to u32
commit: 276390084eb3b9a2997146b998e3a88d2d17cba7
[04/13] drm/tyr: convert EntryHeader to `bitfield!`
commit: 3bcd68a9ae28facac7702a511c94be87d04f713d
[05/13] drm/tyr: use SizeConstants for the u32 and u64 size constants
commit: e823dafce11aa766e5b2d66747a6499184de6975
[06/13] drm/tyr: replace lossless `as` casts with From and FromSafeCast
commit: 63be871b54a4f7fb91eedccca9f17b7c0cf877ac
[07/13] drm/tyr: use `cv!` for constant conversions
commit: 3452878e6c5655353c4ed786bc9b50e46e7e11aa
[08/13] drm/tyr: use VmMapFlags::all_bits() to validate map flags
commit: 3907aa0c69d4d04ae97bb512ef6756de523a8ebe
[09/13] drm/tyr: justify the casts of enums to their integer value
commit: c0a5f20ce4e0e92143966bb1f2e27ccba502412e
[10/13] drm/tyr: add split_u64() for the 64-bit register values
commit: fc056d093c091c707b5df95887d0f0edbd73f398
[11/13] drm/tyr: return usize from get_pgsize()
commit: 5be8e8a09c72d9d7c2dc74c97b56fe746f805e01
[12/13] drm/tyr: justify the physical address cast in pt_map()
commit: 9df201bd6c85ab606060cff899591aeaf6bbcdef
[13/13] drm/tyr: deny `clippy::as_conversions`
commit: 9ef5b2194e283d6cb52e9feca115160fd7acd416