]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
gpu: nova-core: register: use field type for Into implementation
authorAlexandre Courbot <acourbot@nvidia.com>
Thu, 16 Oct 2025 15:13:20 +0000 (11:13 -0400)
committerAlexandre Courbot <acourbot@nvidia.com>
Tue, 21 Oct 2025 13:37:37 +0000 (22:37 +0900)
commit3f674dc4ef1b3783f9d8dae33b46bf50eaac7c79
tree4af9063709571bf3a7537f1a9a91e36a470db9aa
parent91321980923477044eaf91ca6445a409c4b9712e
gpu: nova-core: register: use field type for Into implementation

The getter method of a field works with the field type, but its setter
expects the type of the register. This leads to an asymmetry in the
From/Into implementations required for a field with a dedicated type.
For instance, a field declared as

    pub struct ControlReg(u32) {
        3:0 mode as u8 ?=> Mode;
        ...
    }

currently requires the following implementations:

    impl TryFrom<u8> for Mode {
      ...
    }

    impl From<Mode> for u32 {
      ...
    }

Change this so the `From<Mode>` now needs to be implemented for `u8`,
i.e. the primitive type of the field. This is more consistent, and will
become a requirement once we start using the TryFrom/Into derive macros
to implement these automatically.

Reported-by: Edwin Peer <epeer@nvidia.com>
Closes: https://lore.kernel.org/rust-for-linux/F3853912-2C1C-4F9B-89B0-3168689F35B3@nvidia.com/
Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>
Signed-off-by: Joel Fernandes <joelagnelf@nvidia.com>
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Message-ID: <20251016151323.1201196-2-joelagnelf@nvidia.com>
drivers/gpu/nova-core/falcon.rs
drivers/gpu/nova-core/regs/macros.rs