From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgcUx-0001fv-C3 for qemu-devel@nongnu.org; Mon, 18 Jun 2012 10:00:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SgcUX-0003XE-Vh for qemu-devel@nongnu.org; Mon, 18 Jun 2012 10:00:06 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53249 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SgcUX-0003Wt-J7 for qemu-devel@nongnu.org; Mon, 18 Jun 2012 09:59:41 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Mon, 18 Jun 2012 15:59:03 +0200 Message-Id: <1340027954-19045-12-git-send-email-afaerber@suse.de> In-Reply-To: <1340027954-19045-1-git-send-email-afaerber@suse.de> References: <1340027954-19045-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 11/22] qdev: Move bus properties to a separate global List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Anthony Liguori , "Michael S. Tsirkin" , Anthony Liguori , Amit Shah , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= From: Paolo Bonzini Simple code movement in order to simplify future refactoring. Signed-off-by: Paolo Bonzini Signed-off-by: Andreas F=C3=A4rber --- 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; }; =20 +static Property i2c_props[] =3D { + DEFINE_PROP_UINT8("address", struct I2CSlave, address, 0), + DEFINE_PROP_END_OF_LIST(), +}; + static struct BusInfo i2c_bus_info =3D { .name =3D "I2C", .size =3D sizeof(i2c_bus), - .props =3D (Property[]) { - DEFINE_PROP_UINT8("address", struct I2CSlave, address, 0), - DEFINE_PROP_END_OF_LIST(), - } + .props =3D i2c_props, }; =20 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 @@ =20 static char *idebus_get_fw_dev_path(DeviceState *dev); =20 +static Property ide_props[] =3D { + DEFINE_PROP_UINT32("unit", IDEDevice, unit, -1), + DEFINE_PROP_END_OF_LIST(), +}; + static struct BusInfo ide_bus_info =3D { .name =3D "IDE", .size =3D sizeof(IDEBus), .get_fw_dev_path =3D idebus_get_fw_dev_path, - .props =3D (Property[]) { - DEFINE_PROP_UINT32("unit", IDEDevice, unit, -1), - DEFINE_PROP_END_OF_LIST(), - }, + .props =3D ide_props, }; =20 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 = */ =20 +static Property hda_props[] =3D { + DEFINE_PROP_UINT32("cad", HDACodecDevice, cad, -1), + DEFINE_PROP_END_OF_LIST() +}; + static struct BusInfo hda_codec_bus_info =3D { .name =3D "HDA", .size =3D sizeof(HDACodecBus), - .props =3D (Property[]) { - DEFINE_PROP_UINT32("cad", HDACodecDevice, cad, -1), - DEFINE_PROP_END_OF_LIST() - } + .props =3D hda_props, }; =20 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); =20 +static Property pci_props[] =3D { + 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 =3D { .name =3D "PCI", .size =3D sizeof(PCIBus), @@ -51,16 +62,7 @@ struct BusInfo pci_bus_info =3D { .get_dev_path =3D pcibus_get_dev_path, .get_fw_dev_path =3D pcibus_get_fw_dev_path, .reset =3D pcibus_reset, - .props =3D (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 =3D pci_props, }; =20 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 *bu= f); static void scsi_req_dequeue(SCSIRequest *req); =20 +static Property scsi_props[] =3D { + 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 =3D { .name =3D "SCSI", .size =3D sizeof(SCSIBus), .get_dev_path =3D scsibus_get_dev_path, .get_fw_dev_path =3D scsibus_get_fw_dev_path, - .props =3D (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 =3D scsi_props, }; static int next_scsi_bus; =20 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 =20 +static Property spapr_vio_props[] =3D { + DEFINE_PROP_UINT32("irq", VIOsPAPRDevice, vio_irq_num, 0), \ + DEFINE_PROP_END_OF_LIST(), +}; + static struct BusInfo spapr_vio_bus_info =3D { .name =3D "spapr-vio", .size =3D sizeof(VIOsPAPRBus), - .props =3D (Property[]) { - DEFINE_PROP_UINT32("irq", VIOsPAPRDevice, vio_irq_num, 0), \ - DEFINE_PROP_END_OF_LIST(), - }, + .props =3D spapr_vio_props, }; =20 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); =20 +static Property usb_props[] =3D { + 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 =3D { .name =3D "USB", .size =3D sizeof(USBBus), .print_dev =3D usb_bus_dev_print, .get_dev_path =3D usb_get_dev_path, .get_fw_dev_path =3D usb_get_fw_dev_path, - .props =3D (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 =3D usb_props, }; + static int next_usb_bus =3D 0; static QTAILQ_HEAD(, USBBus) busses =3D QTAILQ_HEAD_INITIALIZER(busses); =20 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]; } =20 +static Property ccid_props[] =3D { + DEFINE_PROP_UINT32("slot", struct CCIDCardState, slot, 0), + DEFINE_PROP_END_OF_LIST(), +}; + static struct BusInfo ccid_bus_info =3D { .name =3D "ccid-bus", .size =3D sizeof(CCIDBus), - .props =3D (Property[]) { - DEFINE_PROP_UINT32("slot", struct CCIDCardState, slot, 0), - DEFINE_PROP_END_OF_LIST(), - } + .props =3D ccid_props, }; =20 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 *op= aque, int version_id) =20 static void virtser_bus_dev_print(Monitor *mon, DeviceState *qdev, int i= ndent); =20 +static Property virtser_props[] =3D { + 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 =3D { .name =3D "virtio-serial-bus", .size =3D sizeof(VirtIOSerialBus), .print_dev =3D virtser_bus_dev_print, - .props =3D (Property[]) { - DEFINE_PROP_UINT32("nr", VirtIOSerialPort, id, VIRTIO_CONSOLE_BA= D_ID), - DEFINE_PROP_STRING("name", VirtIOSerialPort, name), - DEFINE_PROP_END_OF_LIST() - } + .props =3D virtser_props, }; =20 static void virtser_bus_dev_print(Monitor *mon, DeviceState *qdev, int i= ndent) --=20 1.7.7