On Thu Mar 5, 2026 at 3:14 AM JST, Artem Lytkin wrote:
> Add a declarative macro impl_num_enum!() to generate both From<Enum>
> for primitive and TryFrom<primitive> for Enum implementations for
> repr(primitive) enums. This addresses the TODO[FPRI] markers
> throughout the driver.
>
> The macro accepts a list of variants to map, allowing certain variants
> to be excluded from the reverse mapping (e.g. dead_code variants like
> FalconModSelAlgo::Aes).
>
> Replace the manual TryFrom and impl_from_enum_to_u8!() boilerplate for:
>   - FalconCoreRev
>   - FalconSecurityModel
>   - FalconModSelAlgo
>   - DmaTrfCmdSize
>   - FalconFbifTarget
>   - Architecture
>
> FalconCoreRevSubversion retains its manual TryFrom because it requires
> a bitmask operation on the input value. The Chipset enum retains its
> existing define_chipset!() macro which already generates TryFrom.
>
> While at it, add the missing repr(u8) attribute to FalconFbifTarget,
> which is needed for the enum-to-primitive cast to be well-defined.
>
> Signed-off-by: Artem Lytkin <[email protected]>

Thanks for looking into this - but actually there is a kernel-level
effort to do the same thing in progress:

https://lore.kernel.org/all/[email protected]/

Reply via email to