Re: [PATCH v3 01/10] gpu: nova-core: convert PMC registers to kernel register macro
From: Danilo Krummrich
Date: Mon Mar 23 2026 - 07:22:12 EST
On Mon Mar 23, 2026 at 12:07 PM CET, Alexandre Courbot wrote:
> -impl TryFrom<u8> for Architecture {
> +impl TryFrom<Bounded<u32, 6>> for Architecture {
> type Error = Error;
>
> - fn try_from(value: u8) -> Result<Self> {
> - match value {
> + fn try_from(value: Bounded<u32, 6>) -> Result<Self> {
> + match u8::from(value) {
> 0x16 => Ok(Self::Turing),
> 0x17 => Ok(Self::Ampere),
> 0x19 => Ok(Self::Ada),
> @@ -155,23 +151,26 @@ fn try_from(value: u8) -> Result<Self> {
> }
> }
>
> -impl From<Architecture> for u8 {
> +impl From<Architecture> for Bounded<u32, 6> {
> fn from(value: Architecture) -> Self {
> - // CAST: `Architecture` is `repr(u8)`, so this cast is always lossless.
> - value as u8
> + match value {
> + Architecture::Turing => Bounded::<u32, _>::new::<0x16>(),
> + Architecture::Ampere => Bounded::<u32, _>::new::<0x17>(),
> + Architecture::Ada => Bounded::<u32, _>::new::<0x19>(),
> + }
> }
> }
Can this use bounded_enum!()?