From patchwork Wed Apr 11 21:30:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 151937 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7D97DB7019 for ; Thu, 12 Apr 2012 09:38:28 +1000 (EST) Received: from localhost ([::1]:34822 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SI58u-0000hG-N7 for incoming@patchwork.ozlabs.org; Wed, 11 Apr 2012 17:31:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SI580-00075a-SS for qemu-devel@nongnu.org; Wed, 11 Apr 2012 17:31:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SI57y-0002Yj-BF for qemu-devel@nongnu.org; Wed, 11 Apr 2012 17:31:00 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:38481) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SI57x-0002WT-VZ for qemu-devel@nongnu.org; Wed, 11 Apr 2012 17:30:58 -0400 Received: by mail-wi0-f181.google.com with SMTP id hr17so1209460wib.10 for ; Wed, 11 Apr 2012 14:30:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=UWsE+sVcxK+PAOulbqDjIFipRQGV+l23Ff4B1MNjG7g=; b=pa7ksQuKDQZs5FwZKZpaj+fOpv9Zua/HcnFPJX7KQfOqlLrjxnNARBtyhcEIoEEs6Q yBxYA8Og3zxkRpX9Iq8OAHtmrPO7u2dle0nQWXnu3Roeojf/RPzSfvQcAjLibw+SCrHW aK/uZqFm7v8cR3VNZT3Aw2+gm9ADbsYF9IqdPUykTbJfTqqpJuCEAzHk51JOCOoKO/J3 0rYAPiTEaBQ1OeN0rWyMTJW96UEQJtDsx3lG6QSlbEBPZo2FfhZFU8n5aXOPZ6SlvgLO lxf00pBVNLfUS3Nhj9yA985SdSNNKTbrZ0vUIPgwdrOtMjes9DE8BmY7ldp8UtG+HGZW wMuQ== Received: by 10.180.95.74 with SMTP id di10mr3113532wib.1.1334179857083; Wed, 11 Apr 2012 14:30:57 -0700 (PDT) Received: from yakj.lan (93-34-182-16.ip50.fastwebnet.it. [93.34.182.16]) by mx.google.com with ESMTPS id h8sm13849678wix.4.2012.04.11.14.30.55 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 11 Apr 2012 14:30:56 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 11 Apr 2012 23:30:26 +0200 Message-Id: <1334179842-6061-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.9.3 In-Reply-To: <1334179793-5914-1-git-send-email-pbonzini@redhat.com> References: <1334179793-5914-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.212.181 Cc: aliguori@us.ibm.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH v2 08/24] qdev: move bus properties to a separate global X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Simple code movement in order to simplify future refactoring. Signed-off-by: Paolo Bonzini --- 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 | 11 +++++++---- hw/usb/dev-smartcard-reader.c | 10 ++++++---- hw/virtio-serial-bus.c | 12 +++++++----- 9 files changed, 64 insertions(+), 45 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 f6a4896..4d372f8 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 ed8ec99..fff4c4a 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 void pci_update_mappings(PCIDevice *d); diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index 8e76c5d..0352c59 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 dbf5a90..941a013 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 d3f8358..0271bc0 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -11,17 +11,20 @@ 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_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_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 8e66675..4a9cc16 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 e22940e..703c08d 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -677,15 +677,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)