[Background: based upon Peter's feedback at https://lists.gnu.org/archive/html/qemu-devel/2026-06/msg07717.html I realised that what we really need are object_class_property_add_*_ptr() equivalents to the existing object_property_add_*_ptr() functions to make it easier to convert existing properties.
There are actually existing functions with these names that are already in use but after observation these are really static properties, so these are renamed to aid porting object props to class props, as well as making the difference clearer.] [Note: this will have substantial conflicts with Marc-André's series "qom/qdev: associate properties with QAPI schema types" at https://patchew.org/QEMU/[email protected]/.] Since the use of object props is effectively deprecated, here is an attempt to convert all use of object props in hw/acpi to class props. The eventual aim is to continue working through the codebase, removing all remaining uses of object props. The series is lightly tested: it passes "make check", GitLab CI and some simple local tests. I'm mostly interested for feedback on the conversion strategy, and to get a feel for the best way to merge this series since once the basic conversion patterns are in place, the same patterns can be applied elsewhere and it would be good to minimise the merge window for such changes. The following warnings below are generated by checkpatch but are incorrect since they form part of macro definitions: 1/16 Checking commit 58e8d5fb5971 (qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) macro) ERROR: spaces required around that '*' (ctx:WxB) #41: FILE: qom/object.c:2720: + type##_t value = *(type##_t *)object_class_prop_ptr(obj, \ ^ total: 1 errors, 0 warnings, 28 lines checked Patch 1/16 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. 2/15 Checking commit 2068ae0d4ded (qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) macro) ERROR: spaces required around that '*' (ctx:WxV) #28: FILE: qom/object.c:2730: + type##_t *field = (type##_t *)object_class_prop_ptr(obj, \ ^ ERROR: spaces required around that '*' (ctx:WxB) #28: FILE: qom/object.c:2730: + type##_t *field = (type##_t *)object_class_prop_ptr(obj, \ Signed-off-by: Mark Cave-Ayland <[email protected]> (Patches still requiring review: 5, 6) v4: - Add R-B tags from Marc-André - Fix comments mismatch within object_class_property_add_*_ptr() descriptions in object.h - Add patch 5 implementing object_class_property_add_uint64_ptr() now required by patch 6 - Don't promote ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP to a Property in patch 6 since it must be marked as read-only: use object_class_property_add_uint64_ptr() instead v3: - Re-implement the object_class_property_add_*_ptr() get/set functions using new OBJECT_CLASS_PROPERTY_SCALAR_GETTER() and OBJECT_CLASS_PROPERTY_SCALAR_SETTER() macros, similar as has already been done for object properties - Drop most R-B tags since nearly all patches have changed since v2 - Split conversion of static variables to static class properties into separate commits to act as a reference for future conversions - Drop patch 6 from v2 since that has already been merged separately by Phil - Use UINT32_MAX to indicate ACPI_PCIHP_PROP_BSEL has not been set in patch 13 instead of -1. This is because the existing object_property_add_*_ptr() functions always use unsigned scalars: let's try and keep this the same for the object_class_property_add_*_ptr() functions if possible - Add a new object_class_property_add_bool_ptr() function rather than using object_class_property_add_bool() in patch 10 since it avoids writing explicit helpers for each property, and there will likely be other cases in future - Rebase onto master v2: - Add object_class_property_add_*_ptr() functions matching the existing object_property_add_*_ptr() functions for class functions - Rework patch to use new functions instead of manually adding get/set functions as part of the conversion - Ignore existing R-Bs since this approach is quite different to v1 - Rebase onto master Mark Cave-Ayland (16): qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_GETTER(type) macro qom/object.c: introduce OBJECT_CLASS_PROPERTY_SCALAR_SETTER(type) macro qom/object.c: introduce DEFINE_OBJECT_CLASS_PROPERTY_SCALAR_METHODS() macro qom/object.c: add object_class_property_add_uint8_ptr() qom/object.c: add object_class_property_add_uint64_ptr() hw/isa/lpc_ich9.c: convert ich9_lpc_initfn() object props to class props hw/acpi/ich9.c: don't pass ICH9LPCPMRegs via opaque for ACPI_PM_PROP_GPE0_BLK prop qom/object.c: add object_class_property_add_uint32_ptr() hw/acpi/ich9.c: convert ACPI_PM_PROP_GPE0_BLK_LEN to a static class property qom/object.c: add object_class_property_add_bool_ptr() hw/acpi/ich9.c: convert object props in ICH9_LPC_DEVICE to class props qom/object.c: add object_class_property_add_uint16_ptr() hw/acpi/pcihp.c: convert ACPI_PCIHP_IO_BASE_PROP and ACPI_PCIHP_IO_BASE_PROP to class props hw/acpi/pcihp.c: convert ACPI_PCIHP_PROP_BSEL from object prop to class prop hw/acpi/piix4.c: convert static variables to static class properties hw/acpi/piix4.c: convert ACPI_PM_PROP_PM_IO_BASE to a class prop include/hw/acpi/ich9.h | 2 +- include/hw/pci/pci_bus.h | 2 + include/qom/object.h | 90 +++++++++++++++++ hw/acpi/generic_event_device.c | 10 ++ hw/acpi/ich9.c | 126 +++++++++++------------- hw/acpi/pci-bridge.c | 9 +- hw/acpi/pcihp.c | 35 +++---- hw/acpi/piix4.c | 51 +++++++--- hw/arm/virt-acpi-build.c | 7 +- hw/i386/acpi-build.c | 7 +- hw/isa/lpc_ich9.c | 36 ++++--- hw/pci/pci.c | 7 ++ qom/object.c | 171 +++++++++++++++++++++++++++++++++ 13 files changed, 431 insertions(+), 122 deletions(-) -- 2.43.0
