[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 06/12] rust: qom: move device_id to PL011 class side
From: |
Zhao Liu |
Subject: |
Re: [PATCH 06/12] rust: qom: move device_id to PL011 class side |
Date: |
Thu, 26 Dec 2024 11:07:27 +0800 |
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 <pbonzini@redhat.com>
> 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 <pbonzini@redhat.com>
> ---
> 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 <zhao1.liu@intel.com>
- [PATCH 11/12] rust: qemu-api-macros: add automatic TryFrom/TryInto derivation, (continued)
- [PATCH 11/12] rust: qemu-api-macros: add automatic TryFrom/TryInto derivation, Paolo Bonzini, 2024/12/20
- [PATCH 07/12] rust: pl011: only leave embedded object initialization in instance_init, Paolo Bonzini, 2024/12/20
- [PATCH 09/12] rust: qdev: expose inherited methods to subclasses of SysBusDevice, Paolo Bonzini, 2024/12/20
- [PATCH 05/12] rust: qom: automatically use Drop trait to implement instance_finalize, Paolo Bonzini, 2024/12/20
- [PATCH 10/12] rust: qemu-api-macros: extend error reporting facility to parse errors, Paolo Bonzini, 2024/12/20
- [PATCH 06/12] rust: qom: move device_id to PL011 class side, Paolo Bonzini, 2024/12/20
- Re: [PATCH 06/12] rust: qom: move device_id to PL011 class side,
Zhao Liu <=
- [PATCH 08/12] rust: qom: make INSTANCE_POST_INIT take a shared reference, Paolo Bonzini, 2024/12/20
- [PATCH 12/12] rust: hide warnings for subprojects, Paolo Bonzini, 2024/12/20
- Re: [PATCH 00/12] Next round of qemu_api patches, Zhao Liu, 2024/12/23