qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Eduardo Habkost <eduardo@habkost.net>, qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
	"xiaoqiang zhao" <zxq_yx_007@163.com>,
	"Hu Tao" <hutao@cn.fujitsu.com>, "Thomas Huth" <thuth@redhat.com>,
	qemu-block@nongnu.org, qemu-s390x@nongnu.org,
	"Gonglei Arei" <arei.gonglei@huawei.com>,
	"Cao jin" <caoj.fnst@cn.fujitsu.com>, "Li Qiang" <liq3ea@163.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Stefan Weil" <sw@weilnetz.de>,
	"Jason Wang" <jasowang@redhat.com>
Subject: [PATCH 08/19] hw/net/eepro100: Introduce TYPE_EEPRO100 QOM abstract parent
Date: Sun, 12 Feb 2023 23:51:33 +0100	[thread overview]
Message-ID: <20230212225144.58660-9-philmd@linaro.org> (raw)
In-Reply-To: <20230212225144.58660-1-philmd@linaro.org>

Have all the EEPRO100-based devices share a common (abstract)
QOM parent.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/net/eepro100.c | 40 ++++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index dc07984ae9..dac42ba17b 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -235,8 +235,14 @@ typedef enum {
     ru_ready = 4
 } ru_state_t;
 
-typedef struct {
+#define TYPE_EEPRO100 "eepro100"
+OBJECT_DECLARE_SIMPLE_TYPE(EEPRO100State, EEPRO100)
+
+struct EEPRO100State {
+    /*< private >*/
     PCIDevice dev;
+    /*< public >*/
+
     /* Hash register (multicast mask array, multiple individual addresses). */
     uint8_t mult[8];
     MemoryRegion mmio_bar;
@@ -279,7 +285,7 @@ typedef struct {
     /* Quasi static device properties (no need to save them). */
     uint16_t stats_size;
     bool has_extended_tcb_support;
-} EEPRO100State;
+};
 
 /* Word indices in EEPROM. */
 typedef enum {
@@ -2082,21 +2088,27 @@ static void eepro100_class_init(ObjectClass *klass, void *data)
     k->subsystem_id = info->subsystem_id;
 }
 
+static const TypeInfo eepro100_info = {
+    .name          = TYPE_EEPRO100,
+    .parent        = TYPE_PCI_DEVICE,
+    .class_init    = eepro100_class_init,
+    .abstract      = true,
+    .instance_size = sizeof(EEPRO100State),
+    .instance_init = eepro100_instance_init,
+    .interfaces = (InterfaceInfo[]) {
+        { INTERFACE_CONVENTIONAL_PCI_DEVICE },
+        { },
+    },
+};
+
 static void eepro100_register_types(void)
 {
-    size_t i;
-    for (i = 0; i < ARRAY_SIZE(e100_devices); i++) {
-        TypeInfo type_info = {};
-        E100PCIDeviceInfo *info = &e100_devices[i];
+    type_register_static(&eepro100_info);
 
-        type_info.name = info->name;
-        type_info.parent = TYPE_PCI_DEVICE;
-        type_info.class_init = eepro100_class_init;
-        type_info.instance_size = sizeof(EEPRO100State);
-        type_info.instance_init = eepro100_instance_init;
-        type_info.interfaces = (InterfaceInfo[]) {
-            { INTERFACE_CONVENTIONAL_PCI_DEVICE },
-            { },
+    for (size_t i = 0; i < ARRAY_SIZE(e100_devices); i++) {
+        TypeInfo type_info = {
+            .name   = e100_devices[i].name,
+            .parent = TYPE_EEPRO100,
         };
 
         type_register(&type_info);
-- 
2.38.1



  parent reply	other threads:[~2023-02-12 22:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-12 22:51 [PATCH 00/19] hw: Use QOM macros and remove DO_UPCAST() uses Philippe Mathieu-Daudé
2023-02-12 22:51 ` [PATCH 01/19] hw/char/serial-pci: Replace DO_UPCAST(PCISerialState) by PCI_SERIAL() Philippe Mathieu-Daudé
2023-02-12 22:51 ` [PATCH 02/19] hw/char/serial-pci-multi: Batch register types using DEFINE_TYPES macro Philippe Mathieu-Daudé
2023-02-12 22:51 ` [PATCH 03/19] hw/char/serial-pci-multi: Introduce PCI_MULTISERIAL QOM abstract parent Philippe Mathieu-Daudé
2023-02-12 22:51 ` [PATCH 04/19] hw/char/serial-pci-multi: Factor multi_serial_class_initfn() out Philippe Mathieu-Daudé
2023-02-12 22:51 ` [PATCH 05/19] hw/char/serial-pci-multi: Replace DO_UPCAST() by PCI_MULTISERIAL() Philippe Mathieu-Daudé
2023-02-12 22:51 ` [PATCH 06/19] hw/ide/qdev: Replace DO_UPCAST(IDEDevice) by IDE_DEVICE() Philippe Mathieu-Daudé
2023-02-12 22:51 ` [PATCH 07/19] hw/ide/qdev: Replace DO_UPCAST(IDEBus) by IDE_BUS() Philippe Mathieu-Daudé
2023-02-12 22:51 ` Philippe Mathieu-Daudé [this message]
2023-02-12 22:51 ` [PATCH 09/19] hw/net/eepro100: Replace DO_UPCAST(EEPRO100State) by EEPRO100() Philippe Mathieu-Daudé
2023-02-12 22:51 ` [PATCH 10/19] hw/net/ne2000-pci: Replace DO_UPCAST(PCINE2000State) by PCI_NE2000() Philippe Mathieu-Daudé
2023-02-12 22:51 ` [PATCH 11/19] hw/net/tulip: Finish QOM conversion Philippe Mathieu-Daudé
2023-02-12 22:51 ` [PATCH 12/19] hw/pci/pci: Replace DO_UPCAST(PCIBus) by PCI_BUS() Philippe Mathieu-Daudé
2023-02-12 22:51 ` [PATCH 13/19] hw/scsi/scsi-bus: Replace DO_UPCAST(SCSIBus) by SCSI_BUS() Philippe Mathieu-Daudé
2023-02-12 22:51 ` [PATCH 14/19] hw/scsi/scsi-bus: Inline two uses of scsi_bus_from_device() Philippe Mathieu-Daudé
2023-02-12 22:51 ` [PATCH 15/19] hw/s390x/event-facility: Replace DO_UPCAST(SCLPEvent) by SCLP_EVENT() Philippe Mathieu-Daudé
2023-02-13 12:14   ` Thomas Huth
2023-02-12 22:51 ` [PATCH 16/19] hw/vfio/ccw: Replace DO_UPCAST(VFIOCCWDevice) by VFIO_CCW() Philippe Mathieu-Daudé
2023-02-12 22:51 ` [PATCH 17/19] hw/usb/dev-hub: Use QOM USB_HUB() macro instead of casting Philippe Mathieu-Daudé
2023-02-12 22:51 ` [PATCH 18/19] hw/usb: Replace DO_UPCAST(USBBus) by USB_BUS() Philippe Mathieu-Daudé
2023-02-12 22:51 ` [RFC PATCH 19/19] hw/usb: Inline usb_bus_from_device() Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230212225144.58660-9-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=arei.gonglei@huawei.com \
    --cc=caoj.fnst@cn.fujitsu.com \
    --cc=eduardo@habkost.net \
    --cc=hutao@cn.fujitsu.com \
    --cc=jasowang@redhat.com \
    --cc=liq3ea@163.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=sw@weilnetz.de \
    --cc=thuth@redhat.com \
    --cc=zxq_yx_007@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).