From patchwork Thu Jun 6 13:41:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 249417 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9E9F72C0091 for ; Thu, 6 Jun 2013 23:41:56 +1000 (EST) Received: from localhost ([::1]:41613 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkaRt-0007Lb-V9 for incoming@patchwork.ozlabs.org; Thu, 06 Jun 2013 09:41:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkaRT-0007Jp-HU for qemu-devel@nongnu.org; Thu, 06 Jun 2013 09:41:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkaRQ-0004Ok-0X for qemu-devel@nongnu.org; Thu, 06 Jun 2013 09:41:27 -0400 Received: from cantor2.suse.de ([195.135.220.15]:35472 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkaRP-0004O3-Nm for qemu-devel@nongnu.org; Thu, 06 Jun 2013 09:41:23 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 88070A5687; Thu, 6 Jun 2013 15:41:21 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Thu, 6 Jun 2013 15:41:09 +0200 Message-Id: <1370526073-18136-2-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1370526073-18136-1-git-send-email-afaerber@suse.de> References: <1370526073-18136-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: kraxel@redhat.com, =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH v5 1/5] usb/hcd-ehci-sysbus: Convert to QOM realize 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 The SysBus qdev initfn merely calls SysBusDeviceClass::init, so we can replace it with a realizefn already. This avoids getting into any initfn ambiguity with the upcoming Faraday EHCI implementation. Rename internal usb_ehci_initfn() to usb_ehci_realize() to allow to return Errors from common initialization code as well. Signed-off-by: Andreas Färber --- hw/usb/hcd-ehci-pci.c | 2 +- hw/usb/hcd-ehci-sysbus.c | 13 ++++++------- hw/usb/hcd-ehci.c | 2 +- hw/usb/hcd-ehci.h | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c index 0eb7826..70fc65e 100644 --- a/hw/usb/hcd-ehci-pci.c +++ b/hw/usb/hcd-ehci-pci.c @@ -68,7 +68,7 @@ static int usb_ehci_pci_initfn(PCIDevice *dev) s->capsbase = 0x00; s->opregbase = 0x20; - usb_ehci_initfn(s, DEVICE(dev)); + usb_ehci_realize(s, DEVICE(dev), NULL); pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mem); return 0; diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c index b68a66a..4be3d17 100644 --- a/hw/usb/hcd-ehci-sysbus.c +++ b/hw/usb/hcd-ehci-sysbus.c @@ -32,8 +32,9 @@ static Property ehci_sysbus_properties[] = { DEFINE_PROP_END_OF_LIST(), }; -static int usb_ehci_sysbus_initfn(SysBusDevice *dev) +static void usb_ehci_sysbus_realize(DeviceState *dev, Error **errp) { + SysBusDevice *d = SYS_BUS_DEVICE(dev); EHCISysBusState *i = SYS_BUS_EHCI(dev); SysBusEHCIClass *sec = SYS_BUS_EHCI_GET_CLASS(dev); EHCIState *s = &i->ehci; @@ -42,18 +43,16 @@ static int usb_ehci_sysbus_initfn(SysBusDevice *dev) s->opregbase = sec->opregbase; s->dma = &dma_context_memory; - usb_ehci_initfn(s, DEVICE(dev)); - sysbus_init_irq(dev, &s->irq); - sysbus_init_mmio(dev, &s->mem); - return 0; + usb_ehci_realize(s, dev, errp); + sysbus_init_irq(d, &s->irq); + sysbus_init_mmio(d, &s->mem); } static void ehci_sysbus_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); - k->init = usb_ehci_sysbus_initfn; + dc->realize = usb_ehci_sysbus_realize; dc->vmsd = &vmstate_ehci_sysbus; dc->props = ehci_sysbus_properties; } diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c index 0d3799d..66d0cee 100644 --- a/hw/usb/hcd-ehci.c +++ b/hw/usb/hcd-ehci.c @@ -2508,7 +2508,7 @@ const VMStateDescription vmstate_ehci = { } }; -void usb_ehci_initfn(EHCIState *s, DeviceState *dev) +void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp) { int i; diff --git a/hw/usb/hcd-ehci.h b/hw/usb/hcd-ehci.h index e95bb7e..8105fcb 100644 --- a/hw/usb/hcd-ehci.h +++ b/hw/usb/hcd-ehci.h @@ -322,7 +322,7 @@ struct EHCIState { extern const VMStateDescription vmstate_ehci; -void usb_ehci_initfn(EHCIState *s, DeviceState *dev); +void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp); #define TYPE_PCI_EHCI "pci-ehci-usb" #define PCI_EHCI(obj) OBJECT_CHECK(EHCIPCIState, (obj), TYPE_PCI_EHCI)