On Fri, Dec 20, 2024 at 03:29:48PM +0100, Paolo Bonzini wrote:
> Date: Fri, 20 Dec 2024 15:29:48 +0100
> From: Paolo Bonzini <[email protected]>
> Subject: [PATCH 06/12] rust: qom: move device_id to PL011 class side
> X-Mailer: git-send-email 2.47.1
>
> There is no need to monkeypatch DeviceId::Luminary into the
> already-initialized
> PL011State. Instead, now that we can define a class hierarchy, we can define
> PL011Class and make device_id a field in there.
>
> There is also no need anymore to have "Arm" as zero, so change DeviceId into a
> wrapper for the array; all it does is provide an Index<hwaddr> implementation
> because arrays can only be indexed by usize.
>
> Signed-off-by: Paolo Bonzini <[email protected]>
> ---
> rust/hw/char/pl011/src/device.rs | 59 +++++++++++++++-----------------
> 1 file changed, 28 insertions(+), 31 deletions(-)
...
> impl DeviceId {
> - const PL011_ID_ARM: [c_uchar; 8] = [0x11, 0x10, 0x14, 0x00, 0x0d, 0xf0,
> 0x05, 0xb1];
> - const PL011_ID_LUMINARY: [c_uchar; 8] = [0x11, 0x00, 0x18, 0x01, 0x0d,
> 0xf0, 0x05, 0xb1];
> + const ARM: Self = Self(&[0x11, 0x10, 0x14, 0x00, 0x0d, 0xf0, 0x05,
> 0xb1]);
> + const LUMINARY: Self = Self(&[0x11, 0x00, 0x18, 0x01, 0x0d, 0xf0, 0x05,
> 0xb1]);
> }
>
It seems you didn't choose to hardcode device ID to save 3 lines of code :)
Both are fine for me,
Reviewed-by: Zhao Liu <[email protected]>