On Tue Jun 24, 2025 at 10:23 PM JST, Danilo Krummrich wrote: > Implement From for u32 for all enum types used within the register!() > macro. > > This avoids a conflict with [1] as reported in [2]. > > Cc: Alexandre Courbot <[email protected]> > Cc: Miguel Ojeda <[email protected]> > Link: > https://lore.kernel.org/r/[email protected] [1] > Link: https://lore.kernel.org/all/[email protected]/ > [2] > Signed-off-by: Danilo Krummrich <[email protected]>
Reviewed-by: Alexandre Courbot <[email protected]> Also confirmed that Ampere still successfully probed with this: Tested-by: Alexandre Courbot <[email protected]> One small comment and question below. > --- > drivers/gpu/nova-core/falcon.rs | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/drivers/gpu/nova-core/falcon.rs b/drivers/gpu/nova-core/falcon.rs > index 07be1c30668c..1affffb109ec 100644 > --- a/drivers/gpu/nova-core/falcon.rs > +++ b/drivers/gpu/nova-core/falcon.rs > @@ -20,6 +20,16 @@ > mod hal; > pub(crate) mod sec2; > > +macro_rules! impl_from_enum_to_u32 { > + ($enum_type:ty) => { > + impl From<$enum_type> for u32 { > + fn from(value: $enum_type) -> Self { > + value as u32 > + } > + } > + }; > +} We might need some equivalent in other modules as well in the future - do you think we should move it to the root of the driver, and explain its purpose with a comment? I am also thinking that we might want to turn this into a derive macro in the future, similar to `FromPrimitive` - so maybe a TODO item is warranted for this. I haven't looked closely at the `FromPrimitive` patchset yet but it would be neat if we could leverage it somehow.
