From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Kevin Wolf" <kwolf@redhat.com>,
"Anthony Liguori" <aliguori@us.ibm.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Anthony Liguori" <anthony@codemonkey.ws>,
"Amit Shah" <amit.shah@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH 11/22] qdev: Move bus properties to a separate global
Date: Mon, 18 Jun 2012 15:59:03 +0200 [thread overview]
Message-ID: <1340027954-19045-12-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1340027954-19045-1-git-send-email-afaerber@suse.de>
From: Paolo Bonzini <pbonzini@redhat.com>
Simple code movement in order to simplify future refactoring.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/i2c.c | 10 ++++++----
hw/ide/qdev.c | 10 ++++++----
hw/intel-hda.c | 10 ++++++----
hw/pci.c | 22 ++++++++++++----------
hw/scsi-bus.c | 14 ++++++++------
hw/spapr_vio.c | 10 ++++++----
hw/usb/bus.c | 15 +++++++++------
hw/usb/dev-smartcard-reader.c | 10 ++++++----
hw/virtio-serial-bus.c | 12 +++++++-----
9 files changed, 66 insertions(+), 47 deletions(-)
diff --git a/hw/i2c.c b/hw/i2c.c
index 23dfccb..cb10b1d 100644
--- a/hw/i2c.c
+++ b/hw/i2c.c
@@ -17,13 +17,15 @@ struct i2c_bus
uint8_t saved_address;
};
+static Property i2c_props[] = {
+ DEFINE_PROP_UINT8("address", struct I2CSlave, address, 0),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static struct BusInfo i2c_bus_info = {
.name = "I2C",
.size = sizeof(i2c_bus),
- .props = (Property[]) {
- DEFINE_PROP_UINT8("address", struct I2CSlave, address, 0),
- DEFINE_PROP_END_OF_LIST(),
- }
+ .props = i2c_props,
};
static void i2c_bus_pre_save(void *opaque)
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index a46578d..b67df3d 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -27,14 +27,16 @@
static char *idebus_get_fw_dev_path(DeviceState *dev);
+static Property ide_props[] = {
+ DEFINE_PROP_UINT32("unit", IDEDevice, unit, -1),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static struct BusInfo ide_bus_info = {
.name = "IDE",
.size = sizeof(IDEBus),
.get_fw_dev_path = idebus_get_fw_dev_path,
- .props = (Property[]) {
- DEFINE_PROP_UINT32("unit", IDEDevice, unit, -1),
- DEFINE_PROP_END_OF_LIST(),
- },
+ .props = ide_props,
};
void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id)
diff --git a/hw/intel-hda.c b/hw/intel-hda.c
index bb11af2..0994f6b 100644
--- a/hw/intel-hda.c
+++ b/hw/intel-hda.c
@@ -29,13 +29,15 @@
/* --------------------------------------------------------------------- */
/* hda bus */
+static Property hda_props[] = {
+ DEFINE_PROP_UINT32("cad", HDACodecDevice, cad, -1),
+ DEFINE_PROP_END_OF_LIST()
+};
+
static struct BusInfo hda_codec_bus_info = {
.name = "HDA",
.size = sizeof(HDACodecBus),
- .props = (Property[]) {
- DEFINE_PROP_UINT32("cad", HDACodecDevice, cad, -1),
- DEFINE_PROP_END_OF_LIST()
- }
+ .props = hda_props,
};
void hda_codec_bus_init(DeviceState *dev, HDACodecBus *bus,
diff --git a/hw/pci.c b/hw/pci.c
index 127b7ac..377039e 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -44,6 +44,17 @@ static char *pcibus_get_dev_path(DeviceState *dev);
static char *pcibus_get_fw_dev_path(DeviceState *dev);
static int pcibus_reset(BusState *qbus);
+static Property pci_props[] = {
+ DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
+ DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
+ DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1),
+ DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present,
+ QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false),
+ DEFINE_PROP_BIT("command_serr_enable", PCIDevice, cap_present,
+ QEMU_PCI_CAP_SERR_BITNR, true),
+ DEFINE_PROP_END_OF_LIST()
+};
+
struct BusInfo pci_bus_info = {
.name = "PCI",
.size = sizeof(PCIBus),
@@ -51,16 +62,7 @@ struct BusInfo pci_bus_info = {
.get_dev_path = pcibus_get_dev_path,
.get_fw_dev_path = pcibus_get_fw_dev_path,
.reset = pcibus_reset,
- .props = (Property[]) {
- DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
- DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
- DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1),
- DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present,
- QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false),
- DEFINE_PROP_BIT("command_serr_enable", PCIDevice, cap_present,
- QEMU_PCI_CAP_SERR_BITNR, true),
- DEFINE_PROP_END_OF_LIST()
- }
+ .props = pci_props,
};
static PCIBus *pci_find_bus_nr(PCIBus *bus, int bus_num);
diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
index 4a79821..3423b6c 100644
--- a/hw/scsi-bus.c
+++ b/hw/scsi-bus.c
@@ -12,17 +12,19 @@ static char *scsibus_get_fw_dev_path(DeviceState *dev);
static int scsi_req_parse(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf);
static void scsi_req_dequeue(SCSIRequest *req);
+static Property scsi_props[] = {
+ DEFINE_PROP_UINT32("channel", SCSIDevice, channel, 0),
+ DEFINE_PROP_UINT32("scsi-id", SCSIDevice, id, -1),
+ DEFINE_PROP_UINT32("lun", SCSIDevice, lun, -1),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static struct BusInfo scsi_bus_info = {
.name = "SCSI",
.size = sizeof(SCSIBus),
.get_dev_path = scsibus_get_dev_path,
.get_fw_dev_path = scsibus_get_fw_dev_path,
- .props = (Property[]) {
- DEFINE_PROP_UINT32("channel", SCSIDevice, channel, 0),
- DEFINE_PROP_UINT32("scsi-id", SCSIDevice, id, -1),
- DEFINE_PROP_UINT32("lun", SCSIDevice, lun, -1),
- DEFINE_PROP_END_OF_LIST(),
- },
+ .props = scsi_props,
};
static int next_scsi_bus;
diff --git a/hw/spapr_vio.c b/hw/spapr_vio.c
index 315ab80..ab4362a 100644
--- a/hw/spapr_vio.c
+++ b/hw/spapr_vio.c
@@ -49,13 +49,15 @@
do { } while (0)
#endif
+static Property spapr_vio_props[] = {
+ DEFINE_PROP_UINT32("irq", VIOsPAPRDevice, vio_irq_num, 0), \
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static struct BusInfo spapr_vio_bus_info = {
.name = "spapr-vio",
.size = sizeof(VIOsPAPRBus),
- .props = (Property[]) {
- DEFINE_PROP_UINT32("irq", VIOsPAPRDevice, vio_irq_num, 0), \
- DEFINE_PROP_END_OF_LIST(),
- },
+ .props = spapr_vio_props,
};
VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg)
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 2068640..3faf4cb 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -11,19 +11,22 @@ static char *usb_get_dev_path(DeviceState *dev);
static char *usb_get_fw_dev_path(DeviceState *qdev);
static int usb_qdev_exit(DeviceState *qdev);
+static Property usb_props[] = {
+ DEFINE_PROP_STRING("port", USBDevice, port_path),
+ DEFINE_PROP_BIT("full-path", USBDevice, flags,
+ USB_DEV_FLAG_FULL_PATH, true),
+ DEFINE_PROP_END_OF_LIST()
+};
+
static struct BusInfo usb_bus_info = {
.name = "USB",
.size = sizeof(USBBus),
.print_dev = usb_bus_dev_print,
.get_dev_path = usb_get_dev_path,
.get_fw_dev_path = usb_get_fw_dev_path,
- .props = (Property[]) {
- DEFINE_PROP_STRING("port", USBDevice, port_path),
- DEFINE_PROP_BIT("full-path", USBDevice, flags,
- USB_DEV_FLAG_FULL_PATH, true),
- DEFINE_PROP_END_OF_LIST()
- },
+ .props = usb_props,
};
+
static int next_usb_bus = 0;
static QTAILQ_HEAD(, USBBus) busses = QTAILQ_HEAD_INITIALIZER(busses);
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 3b7604e..357b7e8 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -1055,13 +1055,15 @@ static Answer *ccid_peek_next_answer(USBCCIDState *s)
: &s->pending_answers[s->pending_answers_start % PENDING_ANSWERS_NUM];
}
+static Property ccid_props[] = {
+ DEFINE_PROP_UINT32("slot", struct CCIDCardState, slot, 0),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static struct BusInfo ccid_bus_info = {
.name = "ccid-bus",
.size = sizeof(CCIDBus),
- .props = (Property[]) {
- DEFINE_PROP_UINT32("slot", struct CCIDCardState, slot, 0),
- DEFINE_PROP_END_OF_LIST(),
- }
+ .props = ccid_props,
};
void ccid_card_send_apdu_to_guest(CCIDCardState *card,
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 72287d1..ccdbdb3 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -728,15 +728,17 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
static void virtser_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
+static Property virtser_props[] = {
+ DEFINE_PROP_UINT32("nr", VirtIOSerialPort, id, VIRTIO_CONSOLE_BAD_ID),
+ DEFINE_PROP_STRING("name", VirtIOSerialPort, name),
+ DEFINE_PROP_END_OF_LIST()
+};
+
static struct BusInfo virtser_bus_info = {
.name = "virtio-serial-bus",
.size = sizeof(VirtIOSerialBus),
.print_dev = virtser_bus_dev_print,
- .props = (Property[]) {
- DEFINE_PROP_UINT32("nr", VirtIOSerialPort, id, VIRTIO_CONSOLE_BAD_ID),
- DEFINE_PROP_STRING("name", VirtIOSerialPort, name),
- DEFINE_PROP_END_OF_LIST()
- }
+ .props = virtser_props,
};
static void virtser_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
--
1.7.7
next prev parent reply other threads:[~2012-06-18 14:00 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-18 13:58 [Qemu-devel] [PULL] qom-next queue, second batch: QBus, API additions and cleanups Andreas Färber
2012-06-18 13:58 ` [Qemu-devel] [PATCH 01/22] qom: Add object_class_get_parent() Andreas Färber
2012-06-18 13:58 ` [Qemu-devel] [PATCH 02/22] qom: Introduce object_property_is_{child, link}() Andreas Färber
2012-06-18 13:58 ` [Qemu-devel] [PATCH 03/22] qom: Add object_child_foreach() Andreas Färber
2012-06-18 13:58 ` [Qemu-devel] [PATCH 04/22] qom: Add class_base_init Andreas Färber
2012-06-18 13:58 ` [Qemu-devel] [PATCH 05/22] qom: Make Object a type Andreas Färber
2012-06-18 13:58 ` [Qemu-devel] [PATCH 06/22] qom: Drop type_register_static_alias() macro Andreas Färber
2012-06-18 13:58 ` [Qemu-devel] [PATCH 07/22] qom: Assert that public types have a non-NULL parent field Andreas Färber
2012-06-18 13:59 ` [Qemu-devel] [PATCH 08/22] m48t59: Rename "type" property to "model" Andreas Färber
2012-06-18 13:59 ` [Qemu-devel] [PATCH 09/22] arm_l2x0: Rename "type" property to "cache-type" Andreas Färber
2012-06-18 13:59 ` [Qemu-devel] [PATCH 10/22] qdev: Push "type" property up to Object Andreas Färber
2012-06-18 13:59 ` Andreas Färber [this message]
2012-06-18 13:59 ` [Qemu-devel] [PATCH 12/22] qdev: Move bus properties to abstract superclasses Andreas Färber
2012-06-18 13:59 ` [Qemu-devel] [PATCH 13/22] qdev: Clean up global properties Andreas Färber
2012-06-18 13:59 ` [Qemu-devel] [PATCH 14/22] qdev: Remove qdev_prop_set_defaults Andreas Färber
2012-06-18 13:59 ` [Qemu-devel] [PATCH 15/22] qdev: Use wrapper for qdev_get_path Andreas Färber
2012-06-18 13:59 ` [Qemu-devel] [PATCH 16/22] qdev: Move SysBus initialization to sysbus.c Andreas Färber
2012-06-18 13:59 ` [Qemu-devel] [PATCH 17/22] qdev: Convert busses to QEMU Object Model Andreas Färber
2012-06-18 13:59 ` [Qemu-devel] [PATCH 18/22] qdev: Connect busses with their parent devices Andreas Färber
2012-06-18 13:59 ` [Qemu-devel] [PATCH 19/22] qbus: Make child devices links Andreas Färber
2012-06-18 13:59 ` [Qemu-devel] [PATCH 20/22] qbus: Initialize in standard way Andreas Färber
2012-06-18 13:59 ` [Qemu-devel] [PATCH 21/22] qdev: Remove qdev_prop_exists() Andreas Färber
2012-06-18 13:59 ` [Qemu-devel] [PATCH 22/22] qom: Push error reporting to object_property_find() Andreas Färber
2012-06-20 13:09 ` [Qemu-devel] [PULL] qom-next queue, second batch: QBus, API additions and cleanups Anthony Liguori
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=1340027954-19045-12-git-send-email-afaerber@suse.de \
--to=afaerber@suse.de \
--cc=aliguori@us.ibm.com \
--cc=amit.shah@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=kwolf@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).