Re: [PATCH RFC v2 1/3] gpu: nova-core: register: use field type for Into implementation
From: Joel Fernandes
Date: Thu Oct 09 2025 - 11:17:50 EST
Hi Alex,
On 10/9/2025 8:37 AM, Alexandre Courbot wrote:
> 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@xxxxxxxxxx>
> Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
As these are incremental improvements, could you please rebase on top of the v6
bitfield series so it does not conflict?
https://git.kernel.org/pub/scm/linux/kernel/git/jfern/linux.git/log/?h=nova.dev.bitfield.submitted.v6
Thanks.