mbox series

[0/2] Resolve some redundant property accessors

Message ID 20220217225351.140095-1-shentey@gmail.com (mailing list archive)
Headers show
Series Resolve some redundant property accessors | expand

Message

Bernhard Beschow Feb. 17, 2022, 10:53 p.m. UTC
The QOM API already provides appropriate accessors, so reuse them.

Testing done:

  :$ make check
  Ok:                 569
  Expected Fail:      0
  Fail:               0
  Unexpected Pass:    0
  Skipped:            178
  Timeout:            0

Bernhard Beschow (2):
  hw/vfio/pci-quirks: Resolve redundant property getters
  hw/riscv/sifive_u: Resolve redundant property accessors

 hw/riscv/sifive_u.c  | 24 ++++--------------------
 hw/vfio/pci-quirks.c | 34 +++++++++-------------------------
 2 files changed, 13 insertions(+), 45 deletions(-)

Comments

Philippe Mathieu-Daudé Feb. 21, 2022, 10:28 p.m. UTC | #1
On 17/2/22 23:53, Bernhard Beschow wrote:
> The QOM API already provides appropriate accessors, so reuse them.
> 
> Testing done:
> 
>    :$ make check
>    Ok:                 569
>    Expected Fail:      0
>    Fail:               0
>    Unexpected Pass:    0
>    Skipped:            178
>    Timeout:            0
> 
> Bernhard Beschow (2):
>    hw/vfio/pci-quirks: Resolve redundant property getters
>    hw/riscv/sifive_u: Resolve redundant property accessors

Good cleanup.

You might want to play with Coccinelle spatch [*] to clean all uses:

$ git grep object_property_add\(.*uint
hw/acpi/ich9.c:446:    object_property_add(obj, ACPI_PM_PROP_GPE0_BLK, 
"uint32",
hw/i386/sgx-epc.c:47:    object_property_add(obj, SGX_EPC_SIZE_PROP, 
"uint64", sgx_epc_get_size,
hw/intc/apic_common.c:462:    object_property_add(obj, "id", "uint32",
hw/mem/pc-dimm.c:175:    object_property_add(obj, PC_DIMM_SIZE_PROP, 
"uint64", pc_dimm_get_size,
hw/misc/aspeed_lpc.c:420:    object_property_add(obj, "idr1", "uint32", 
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:422:    object_property_add(obj, "odr1", "uint32", 
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:424:    object_property_add(obj, "str1", "uint32", 
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:426:    object_property_add(obj, "idr2", "uint32", 
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:428:    object_property_add(obj, "odr2", "uint32", 
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:430:    object_property_add(obj, "str2", "uint32", 
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:432:    object_property_add(obj, "idr3", "uint32", 
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:434:    object_property_add(obj, "odr3", "uint32", 
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:436:    object_property_add(obj, "str3", "uint32", 
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:438:    object_property_add(obj, "idr4", "uint32", 
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:440:    object_property_add(obj, "odr4", "uint32", 
aspeed_kcs_get_register_property,
hw/misc/aspeed_lpc.c:442:    object_property_add(obj, "str4", "uint32", 
aspeed_kcs_get_register_property,
hw/misc/npcm7xx_mft.c:493:        object_property_add(obj, "max_rpm[*]", 
"uint32",
hw/nvme/ctrl.c:6856:    object_property_add(obj, 
"smart_critical_warning", "uint8",
hw/pci-host/q35.c:224:    object_property_add(obj, 
PCI_HOST_PROP_PCI_HOLE_START, "uint32",
hw/pci-host/q35.c:228:    object_property_add(obj, 
PCI_HOST_PROP_PCI_HOLE_END, "uint32",
hw/pci-host/q35.c:232:    object_property_add(obj, 
PCI_HOST_PROP_PCI_HOLE64_START, "uint64",
hw/pci-host/q35.c:236:    object_property_add(obj, 
PCI_HOST_PROP_PCI_HOLE64_END, "uint64",
hw/ppc/spapr_drc.c:584:    object_property_add(obj, "index", "uint32", 
prop_get_index,
hw/riscv/sifive_u.c:736:    object_property_add(obj, "msel", "uint32",
hw/riscv/sifive_u.c:743:    object_property_add(obj, "serial", "uint32",
hw/sensor/adm1272.c:497:    object_property_add(obj, "vin", "uint16",
hw/sensor/adm1272.c:501:    object_property_add(obj, "vout", "uint16",
hw/sensor/adm1272.c:505:    object_property_add(obj, "iout", "uint16",
hw/sensor/adm1272.c:509:    object_property_add(obj, "pin", "uint16",
hw/sensor/max34451.c:730:        object_property_add(obj, "vout[*]", 
"uint16",
hw/sensor/max34451.c:740:        object_property_add(obj, 
"temperature[*]", "uint16",
hw/vfio/pci-quirks.c:1621:    object_property_add(OBJECT(vdev), 
"nvlink2-tgt", "uint64",
hw/vfio/pci-quirks.c:1682:    object_property_add(OBJECT(vdev), 
"nvlink2-tgt", "uint64",
hw/vfio/pci-quirks.c:1688:    object_property_add(OBJECT(vdev), 
"nvlink2-link-speed", "uint32",
net/colo-compare.c:1390:    object_property_add(obj, "compare_timeout", 
"uint64",
net/colo-compare.c:1394:    object_property_add(obj, 
"expired_scan_cycle", "uint32",
net/colo-compare.c:1398:    object_property_add(obj, "max_queue_size", 
"uint32",
softmmu/memory.c:1262:    object_property_add(OBJECT(mr), "priority", 
"uint32",
softmmu/memory.c:1266:    object_property_add(OBJECT(mr), "size", "uint64",
target/arm/cpu64.c:863:    object_property_add(obj, "sve-max-vq", 
"uint32", cpu_max_get_sve_max_vq,
tests/unit/test-qdev-global-props.c:155:    object_property_add(obj, 
"prop1", "uint32", prop1_accessor, prop1_accessor,
tests/unit/test-qdev-global-props.c:157:    object_property_add(obj, 
"prop2", "uint32", prop2_accessor, prop2_accessor,

[*] https://coccinelle.gitlabpages.inria.fr/website/
Bernhard Beschow Feb. 21, 2022, 10:52 p.m. UTC | #2
Am 21. Februar 2022 22:28:00 UTC schrieb "Philippe Mathieu-Daudé" <philippe.mathieu.daude@gmail.com>:
>On 17/2/22 23:53, Bernhard Beschow wrote:
>> The QOM API already provides appropriate accessors, so reuse them.
>> 
>> Testing done:
>> 
>>    :$ make check
>>    Ok:                 569
>>    Expected Fail:      0
>>    Fail:               0
>>    Unexpected Pass:    0
>>    Skipped:            178
>>    Timeout:            0
>> 
>> Bernhard Beschow (2):
>>    hw/vfio/pci-quirks: Resolve redundant property getters
>>    hw/riscv/sifive_u: Resolve redundant property accessors
>
>Good cleanup.
>
>You might want to play with Coccinelle spatch [*] to clean all uses:

Hi Philippe,

thanks for your review!

I've manually inspected most (all?) of them and found that the remaining setters were non-trivial, i.e. they do some extra stuff such as checking boundaries or invoking some extra actions. Do you have an idea how to deal with that?

Regards,
Bernhard

>$ git grep object_property_add\(.*uint
>hw/acpi/ich9.c:446:    object_property_add(obj, ACPI_PM_PROP_GPE0_BLK, 
>"uint32",
>hw/i386/sgx-epc.c:47:    object_property_add(obj, SGX_EPC_SIZE_PROP, 
>"uint64", sgx_epc_get_size,
>hw/intc/apic_common.c:462:    object_property_add(obj, "id", "uint32",
>hw/mem/pc-dimm.c:175:    object_property_add(obj, PC_DIMM_SIZE_PROP, 
>"uint64", pc_dimm_get_size,
>hw/misc/aspeed_lpc.c:420:    object_property_add(obj, "idr1", "uint32", 
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:422:    object_property_add(obj, "odr1", "uint32", 
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:424:    object_property_add(obj, "str1", "uint32", 
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:426:    object_property_add(obj, "idr2", "uint32", 
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:428:    object_property_add(obj, "odr2", "uint32", 
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:430:    object_property_add(obj, "str2", "uint32", 
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:432:    object_property_add(obj, "idr3", "uint32", 
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:434:    object_property_add(obj, "odr3", "uint32", 
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:436:    object_property_add(obj, "str3", "uint32", 
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:438:    object_property_add(obj, "idr4", "uint32", 
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:440:    object_property_add(obj, "odr4", "uint32", 
>aspeed_kcs_get_register_property,
>hw/misc/aspeed_lpc.c:442:    object_property_add(obj, "str4", "uint32", 
>aspeed_kcs_get_register_property,
>hw/misc/npcm7xx_mft.c:493:        object_property_add(obj, "max_rpm[*]", 
>"uint32",
>hw/nvme/ctrl.c:6856:    object_property_add(obj, 
>"smart_critical_warning", "uint8",
>hw/pci-host/q35.c:224:    object_property_add(obj, 
>PCI_HOST_PROP_PCI_HOLE_START, "uint32",
>hw/pci-host/q35.c:228:    object_property_add(obj, 
>PCI_HOST_PROP_PCI_HOLE_END, "uint32",
>hw/pci-host/q35.c:232:    object_property_add(obj, 
>PCI_HOST_PROP_PCI_HOLE64_START, "uint64",
>hw/pci-host/q35.c:236:    object_property_add(obj, 
>PCI_HOST_PROP_PCI_HOLE64_END, "uint64",
>hw/ppc/spapr_drc.c:584:    object_property_add(obj, "index", "uint32", 
>prop_get_index,
>hw/riscv/sifive_u.c:736:    object_property_add(obj, "msel", "uint32",
>hw/riscv/sifive_u.c:743:    object_property_add(obj, "serial", "uint32",
>hw/sensor/adm1272.c:497:    object_property_add(obj, "vin", "uint16",
>hw/sensor/adm1272.c:501:    object_property_add(obj, "vout", "uint16",
>hw/sensor/adm1272.c:505:    object_property_add(obj, "iout", "uint16",
>hw/sensor/adm1272.c:509:    object_property_add(obj, "pin", "uint16",
>hw/sensor/max34451.c:730:        object_property_add(obj, "vout[*]", 
>"uint16",
>hw/sensor/max34451.c:740:        object_property_add(obj, 
>"temperature[*]", "uint16",
>hw/vfio/pci-quirks.c:1621:    object_property_add(OBJECT(vdev), 
>"nvlink2-tgt", "uint64",
>hw/vfio/pci-quirks.c:1682:    object_property_add(OBJECT(vdev), 
>"nvlink2-tgt", "uint64",
>hw/vfio/pci-quirks.c:1688:    object_property_add(OBJECT(vdev), 
>"nvlink2-link-speed", "uint32",
>net/colo-compare.c:1390:    object_property_add(obj, "compare_timeout", 
>"uint64",
>net/colo-compare.c:1394:    object_property_add(obj, 
>"expired_scan_cycle", "uint32",
>net/colo-compare.c:1398:    object_property_add(obj, "max_queue_size", 
>"uint32",
>softmmu/memory.c:1262:    object_property_add(OBJECT(mr), "priority", 
>"uint32",
>softmmu/memory.c:1266:    object_property_add(OBJECT(mr), "size", "uint64",
>target/arm/cpu64.c:863:    object_property_add(obj, "sve-max-vq", 
>"uint32", cpu_max_get_sve_max_vq,
>tests/unit/test-qdev-global-props.c:155:    object_property_add(obj, 
>"prop1", "uint32", prop1_accessor, prop1_accessor,
>tests/unit/test-qdev-global-props.c:157:    object_property_add(obj, 
>"prop2", "uint32", prop2_accessor, prop2_accessor,
>
>[*] https://coccinelle.gitlabpages.inria.fr/website/
Bernhard Beschow Feb. 25, 2022, 8:48 p.m. UTC | #3
Am 17. Februar 2022 22:53:48 UTC schrieb Bernhard Beschow <shentey@gmail.com>:
>The QOM API already provides appropriate accessors, so reuse them.
>
>Testing done:
>
>  :$ make check
>  Ok:                 569
>  Expected Fail:      0
>  Fail:               0
>  Unexpected Pass:    0
>  Skipped:            178
>  Timeout:            0
>
>Bernhard Beschow (2):
>  hw/vfio/pci-quirks: Resolve redundant property getters
>  hw/riscv/sifive_u: Resolve redundant property accessors
>
> hw/riscv/sifive_u.c  | 24 ++++--------------------
> hw/vfio/pci-quirks.c | 34 +++++++++-------------------------
> 2 files changed, 13 insertions(+), 45 deletions(-)
>

Hi,

all 2 patches in this series are reviewed. What's missing?

Note: The lonely [PATCH] slipped underneath this series. Is this a problem?It was supposed to be submitted toplevel but git send-email doesn't seem to support sending multiple independent series at once.

Best regards,
Bernhard