qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [for-5.0 PATCH 0/3] cpu: Clarify overloading of reset QOM methods
@ 2019-12-06 18:43 Greg Kurz
  2019-12-06 18:43 ` [for-5.0 PATCH 1/3] cpu: Introduce CPUReset callback typedef Greg Kurz
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Greg Kurz @ 2019-12-06 18:43 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Laurent Vivier, Peter Maydell, David Hildenbrand, Cornelia Huck,
	qemu-devel, Alistair Francis, Paolo Bonzini,
	Philippe Mathieu-Daudé, David Gibson

Each cpu subclass overloads the reset method of its parent class with
its own. But since it needs to call the parent method as well, it keeps
a parent_reset pointer to do so. This causes the same not very explicit
boiler plate to be duplicated all around the place:

    pcc->parent_reset = cc->reset;
    cc->reset = ppc_cpu_reset;

A similar concern was addressed some time back by Philippe Mathieu-Daudé
in qdev, with the addition of device_class_set_parent_reset() and friends:

https://git.qemu.org/?p=qemu.git;a=commit;h=46795cf2e2f6
https://git.qemu.org/?p=qemu.git;a=commit;h=bf853881690d

Follow the same approach with cpus.

--
Greg

---

Greg Kurz (3):
      cpu: Introduce CPUReset callback typedef
      cpu: Introduce cpu_class_set_parent_reset()
      cpu: Use cpu_class_set_parent_reset()


 hw/core/cpu.c                   |    8 ++++++++
 include/hw/core/cpu.h           |    8 +++++++-
 target/alpha/cpu-qom.h          |    2 +-
 target/arm/cpu-qom.h            |    2 +-
 target/arm/cpu.c                |    3 +--
 target/cris/cpu-qom.h           |    2 +-
 target/cris/cpu.c               |    3 +--
 target/hppa/cpu-qom.h           |    2 +-
 target/i386/cpu-qom.h           |    2 +-
 target/i386/cpu.c               |    3 +--
 target/lm32/cpu-qom.h           |    2 +-
 target/lm32/cpu.c               |    3 +--
 target/m68k/cpu-qom.h           |    2 +-
 target/m68k/cpu.c               |    3 +--
 target/microblaze/cpu-qom.h     |    2 +-
 target/microblaze/cpu.c         |    3 +--
 target/mips/cpu-qom.h           |    2 +-
 target/mips/cpu.c               |    3 +--
 target/moxie/cpu.c              |    3 +--
 target/moxie/cpu.h              |    2 +-
 target/nios2/cpu.c              |    3 +--
 target/nios2/cpu.h              |    2 +-
 target/openrisc/cpu.c           |    3 +--
 target/openrisc/cpu.h           |    2 +-
 target/ppc/cpu-qom.h            |    2 +-
 target/ppc/translate_init.inc.c |    3 +--
 target/riscv/cpu.c              |    3 +--
 target/riscv/cpu.h              |    2 +-
 target/s390x/cpu-qom.h          |    2 +-
 target/s390x/cpu.c              |    3 +--
 target/sh4/cpu-qom.h            |    2 +-
 target/sh4/cpu.c                |    3 +--
 target/sparc/cpu-qom.h          |    2 +-
 target/sparc/cpu.c              |    3 +--
 target/tilegx/cpu.c             |    3 +--
 target/tilegx/cpu.h             |    2 +-
 target/tricore/cpu-qom.h        |    2 +-
 target/tricore/cpu.c            |    3 +--
 target/xtensa/cpu-qom.h         |    2 +-
 target/xtensa/cpu.c             |    3 +--
 40 files changed, 53 insertions(+), 57 deletions(-)



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-12-09  9:14 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-06 18:43 [for-5.0 PATCH 0/3] cpu: Clarify overloading of reset QOM methods Greg Kurz
2019-12-06 18:43 ` [for-5.0 PATCH 1/3] cpu: Introduce CPUReset callback typedef Greg Kurz
2019-12-09  0:51   ` David Gibson
2019-12-09  5:32   ` Alistair Francis
2019-12-09  9:06   ` Cornelia Huck
2019-12-06 18:44 ` [for-5.0 PATCH 2/3] cpu: Introduce cpu_class_set_parent_reset() Greg Kurz
2019-12-09  0:51   ` David Gibson
2019-12-09  5:36   ` Alistair Francis
2019-12-09  9:12   ` Cornelia Huck
2019-12-06 18:44 ` [for-5.0 PATCH 3/3] cpu: Use cpu_class_set_parent_reset() Greg Kurz
2019-12-09  0:51   ` David Gibson
2019-12-09  5:36   ` Alistair Francis
2019-12-09  9:13   ` Cornelia Huck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).