From nobody Tue Oct 28 01:56:35 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151610874212174.70397448553206; Tue, 16 Jan 2018 05:19:02 -0800 (PST) Received: from localhost ([::1]:35716 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebR8n-0004kh-8q for importer@patchew.org; Tue, 16 Jan 2018 08:19:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebR6a-0003Ng-6d for qemu-devel@nongnu.org; Tue, 16 Jan 2018 08:16:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebR6U-0007ai-HL for qemu-devel@nongnu.org; Tue, 16 Jan 2018 08:16:44 -0500 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:39545) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ebR6U-0007aR-D3 for qemu-devel@nongnu.org; Tue, 16 Jan 2018 08:16:38 -0500 Received: by mail-qt0-x243.google.com with SMTP id k19so18149100qtj.6 for ; Tue, 16 Jan 2018 05:16:38 -0800 (PST) Received: from x1.local ([138.117.48.219]) by smtp.gmail.com with ESMTPSA id k29sm1436180qtc.87.2018.01.16.05.16.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2018 05:16:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jtc/PC9Ge9m+AXxxFtfOnPW5mB7v5zamHuteQje3hEU=; b=DPCiIRN3Fd7lGavTvTc+sK5F441g0KukLwed0hTKY2EWXxUAh1U2898QQN81IJvZ4Z f3WUyWKXPObXK/6QngOAmiQwCK50myjj6teFegHdeftm2Qca33T18EwPvaHQWVz/Zp4x MT+BdQpvusLs5eq01/hgwR0WrkGSmbr2o0IbRf5Dq+W7qmoNwrh4ZnmpOgM+JvQofC5s AVZt4Y6ULpfIxidt+AdGuvFvnostiSFxLDoqahD9OuNp4Lmulkf+f7F9nDUiw5PMhoMW FkHJ6REHr2nvPo5ULXDwna2ewNkWZ8DCFLNB9eNJQme3+5SU19ycBCsZQZl0klWuivaH LwpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=jtc/PC9Ge9m+AXxxFtfOnPW5mB7v5zamHuteQje3hEU=; b=q2z5gQPU90Uu9v08+ULKKSm7tJqNzOvAOGayvSxf2N+uBX365RU6lT7QZOmzCiInqE CcNp/R15+vrT69mWAIK4v13qSX4fbJCToKKV8OSIPDgnsDn3qVWCFE7DB0wMpkc5YuW5 xS0fuCSQKqFTe1rGJHSeoazfpnt3fNqB/47bqME40DxMZlvfYEh9y7AC148lAyx52qwr glgBvMzAHXI/+v6JGXS9XSZCYLc8jjqHvG9rgqRYyOoXVqKFSvGT7dVCInATLJkTlaq8 h/OCG8tUvyQ46yAzVytUfK7WBeiwwTrDFUkKBJaVqHK/HF6QvjrsZeoaeZVk+ZM+COxn 7M6g== X-Gm-Message-State: AKwxytdiH60YUxNbSk2CeoRWy7G2HvNT+PwQFHu5Yuq1UVrwxpNfiD0p cEsQBHrxp80A56OzAPENkOI= X-Google-Smtp-Source: ACJfBothmFM7dcA6mppDbDTCR7Tjk2JKkFhJvLI3EzxPyIg8i9HTn1B+VwJdivTtTS+nkDhCbd9sLQ== X-Received: by 10.237.43.162 with SMTP id e31mr11253777qtd.337.1516108598028; Tue, 16 Jan 2018 05:16:38 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Eduardo Habkost , Markus Armbruster , Peter Maydell , Paolo Bonzini , Eric Blake , Marcel Apfelbaum Date: Tue, 16 Jan 2018 10:15:51 -0300 Message-Id: <20180116131555.14242-8-f4bug@amsat.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180116131555.14242-1-f4bug@amsat.org> References: <20180116131555.14242-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [PATCH 07/11] qdev: simplify the SysBusDeviceClass::init path X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 The SysBusDevice is the last DeviceClass::init user. Instead of using SysBusDeviceClass::realize -> DeviceClass::realize -> DeviceClass::init -> sysbus_device_init -> SysBusDeviceClass::init Simplify the path by directly calling SysBusDeviceClass::init in SysBusDeviceClass::realize: SysBusDeviceClass::realize -> SysBusDeviceClass::init Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/qdev.c | 9 --------- hw/core/sysbus.c | 21 +++++++++------------ 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 11112951a5..a4f76c8f5d 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -221,15 +221,6 @@ void device_listener_unregister(DeviceListener *listen= er) =20 static void device_realize(DeviceState *dev, Error **errp) { - DeviceClass *dc =3D DEVICE_GET_CLASS(dev); - - if (dc->init) { - int rc =3D dc->init(dev); - if (rc < 0) { - error_setg(errp, "Device initialization failed."); - return; - } - } } =20 static void device_unrealize(DeviceState *dev, Error **errp) diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 04d6061f76..9edf43bc27 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -18,6 +18,7 @@ */ =20 #include "qemu/osdep.h" +#include "qapi/error.h" #include "hw/sysbus.h" #include "monitor/monitor.h" #include "exec/address-spaces.h" @@ -200,22 +201,19 @@ void sysbus_init_ioports(SysBusDevice *dev, uint32_t = ioport, uint32_t size) } } =20 -/* TODO remove, once users are converted to realize */ -static int sysbus_device_init(DeviceState *dev) +static void sysbus_realize(DeviceState *dev, Error **errp) { SysBusDevice *sd =3D SYS_BUS_DEVICE(dev); SysBusDeviceClass *sbc =3D SYS_BUS_DEVICE_GET_CLASS(sd); =20 - if (!sbc->init) { - return 0; + /* TODO remove, once users are converted to realize */ + if (sbc->init) { + int rc =3D sbc->init(sd); + if (rc < 0) { + error_setg(errp, "Device initialization failed."); + return; + } } - return sbc->init(sd); -} - -static void sysbus_realize(DeviceState *dev, Error **errp) -{ - SysBusDevice *sd =3D SYS_BUS_DEVICE(dev); - SysBusDeviceClass *sbc =3D SYS_BUS_DEVICE_GET_CLASS(sd); =20 if (sbc->realize) { sbc->realize(sd, errp); @@ -345,7 +343,6 @@ MemoryRegion *sysbus_address_space(SysBusDevice *dev) static void sysbus_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k =3D DEVICE_CLASS(klass); - k->init =3D sysbus_device_init; k->realize =3D sysbus_realize; k->unrealize =3D sysbus_unrealize; k->bus_type =3D TYPE_SYSTEM_BUS; --=20 2.15.1