From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org, Eduardo Habkost <eduardo@habkost.net>
Cc: qemu-block@nongnu.org, "Hu Tao" <hutao@cn.fujitsu.com>,
"Gonglei Arei" <arei.gonglei@huawei.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Li Qiang" <liq3ea@163.com>, "Thomas Huth" <thuth@redhat.com>,
"Cao jin" <caoj.fnst@cn.fujitsu.com>,
"xiaoqiang zhao" <zxq_yx_007@163.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [PATCH v3 04/14] hw/char/serial-pci-multi: Factor multi_serial_class_initfn() out
Date: Mon, 13 Feb 2023 19:43:28 +0100 [thread overview]
Message-ID: <20230213184338.46712-5-philmd@linaro.org> (raw)
In-Reply-To: <20230213184338.46712-1-philmd@linaro.org>
Extract code common to multi_2x_serial_pci_class_initfn() and
multi_4x_serial_pci_class_initfn() to multi_serial_class_initfn().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/char/serial-pci-multi.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/hw/char/serial-pci-multi.c b/hw/char/serial-pci-multi.c
index e56c0bc841..704be5c294 100644
--- a/hw/char/serial-pci-multi.c
+++ b/hw/char/serial-pci-multi.c
@@ -155,14 +155,14 @@ static Property multi_4x_serial_pci_properties[] = {
DEFINE_PROP_END_OF_LIST(),
};
-static void multi_2x_serial_pci_class_initfn(ObjectClass *klass, void *data)
+static void multi_serial_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass);
+
pc->realize = multi_serial_pci_realize;
pc->exit = multi_serial_pci_exit;
pc->vendor_id = PCI_VENDOR_ID_REDHAT;
- pc->device_id = PCI_DEVICE_ID_REDHAT_SERIAL2;
pc->revision = 1;
pc->class_id = PCI_CLASS_COMMUNICATION_SERIAL;
dc->vmsd = &vmstate_pci_multi_serial;
@@ -170,19 +170,22 @@ static void multi_2x_serial_pci_class_initfn(ObjectClass *klass, void *data)
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
}
+static void multi_2x_serial_pci_class_initfn(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass);
+
+ pc->device_id = PCI_DEVICE_ID_REDHAT_SERIAL2;
+ device_class_set_props(dc, multi_2x_serial_pci_properties);
+}
+
static void multi_4x_serial_pci_class_initfn(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass);
- pc->realize = multi_serial_pci_realize;
- pc->exit = multi_serial_pci_exit;
- pc->vendor_id = PCI_VENDOR_ID_REDHAT;
+
pc->device_id = PCI_DEVICE_ID_REDHAT_SERIAL4;
- pc->revision = 1;
- pc->class_id = PCI_CLASS_COMMUNICATION_SERIAL;
- dc->vmsd = &vmstate_pci_multi_serial;
device_class_set_props(dc, multi_4x_serial_pci_properties);
- set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
}
static void multi_serial_init(Object *o)
@@ -202,6 +205,7 @@ static const TypeInfo multi_serial_pci_types[] = {
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(PCIMultiSerialState),
.instance_init = multi_serial_init,
+ .class_init = multi_serial_class_initfn,
.abstract = true,
.interfaces = (InterfaceInfo[]) {
{ INTERFACE_CONVENTIONAL_PCI_DEVICE },
--
2.38.1
next prev parent reply other threads:[~2023-02-13 18:44 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-13 18:43 [PATCH v3 00/14] hw: Use QOM macros and remove DO_UPCAST() uses Philippe Mathieu-Daudé
2023-02-13 18:43 ` [PATCH v3 01/14] hw/char/serial-pci: Replace DO_UPCAST(PCISerialState) by PCI_SERIAL() Philippe Mathieu-Daudé
2023-02-16 11:20 ` Thomas Huth
2023-02-16 13:00 ` Philippe Mathieu-Daudé
2023-02-16 14:17 ` BALATON Zoltan
2023-02-16 15:22 ` Philippe Mathieu-Daudé
2023-02-13 18:43 ` [PATCH v3 02/14] hw/char/serial-pci-multi: Batch register types using DEFINE_TYPES macro Philippe Mathieu-Daudé
2023-02-13 18:43 ` [PATCH v3 03/14] hw/char/serial-pci-multi: Introduce PCI_MULTISERIAL QOM abstract parent Philippe Mathieu-Daudé
2023-02-13 18:43 ` Philippe Mathieu-Daudé [this message]
2023-02-14 16:07 ` [PATCH v3 04/14] hw/char/serial-pci-multi: Factor multi_serial_class_initfn() out Bernhard Beschow
2023-02-13 18:43 ` [PATCH v3 05/14] hw/char/serial-pci-multi: Replace DO_UPCAST() by PCI_MULTISERIAL() Philippe Mathieu-Daudé
2023-02-13 18:43 ` [PATCH v3 06/14] hw/ide/qdev: Replace DO_UPCAST(IDEDevice) by IDE_DEVICE() Philippe Mathieu-Daudé
2023-02-13 18:43 ` [PATCH v3 07/14] hw/ide/qdev: Replace DO_UPCAST(IDEBus) by IDE_BUS() Philippe Mathieu-Daudé
2023-02-13 18:43 ` [PATCH v3 08/14] hw/net/ne2000-pci: Replace DO_UPCAST(PCINE2000State) by PCI_NE2000() Philippe Mathieu-Daudé
2023-02-28 13:39 ` Philippe Mathieu-Daudé
2023-02-13 18:43 ` [PATCH v3 09/14] hw/net/tulip: Finish QOM conversion Philippe Mathieu-Daudé
2023-02-28 13:39 ` Philippe Mathieu-Daudé
2023-03-06 3:03 ` Jason Wang
2023-02-13 18:43 ` [PATCH v3 10/14] hw/pci/pci: Replace DO_UPCAST(PCIBus) by PCI_BUS() Philippe Mathieu-Daudé
2023-02-13 18:43 ` [PATCH v3 11/14] hw/scsi/scsi-bus: Replace DO_UPCAST(SCSIBus) by SCSI_BUS() Philippe Mathieu-Daudé
2023-02-13 18:43 ` [PATCH v3 12/14] hw/scsi/scsi-bus: Inline two uses of scsi_bus_from_device() Philippe Mathieu-Daudé
2023-02-13 18:43 ` [PATCH v3 13/14] hw/usb/dev-hub: Use QOM USB_HUB() macro instead of casting Philippe Mathieu-Daudé
2023-02-13 18:43 ` [PATCH v3 14/14] hw/usb: Replace DO_UPCAST(USBBus) by USB_BUS() Philippe Mathieu-Daudé
2023-02-28 13:43 ` [PATCH v3 00/14] hw: Use QOM macros and remove DO_UPCAST() uses Philippe Mathieu-Daudé
2023-02-28 13:44 ` 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=20230213184338.46712-5-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=liq3ea@163.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--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).