From nobody Tue Oct 28 01:56:36 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 1516108740368915.469339389058; Tue, 16 Jan 2018 05:19:00 -0800 (PST) Received: from localhost ([::1]:35715 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebR8l-0004ji-B6 for importer@patchew.org; Tue, 16 Jan 2018 08:18:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59401) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ebR6X-0003MZ-D6 for qemu-devel@nongnu.org; Tue, 16 Jan 2018 08:16:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ebR6R-0007Xt-Dt for qemu-devel@nongnu.org; Tue, 16 Jan 2018 08:16:41 -0500 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:41709) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ebR6R-0007Xd-9w for qemu-devel@nongnu.org; Tue, 16 Jan 2018 08:16:35 -0500 Received: by mail-qk0-x243.google.com with SMTP id l29so11163865qkj.8 for ; Tue, 16 Jan 2018 05:16:35 -0800 (PST) Received: from x1.local ([138.117.48.219]) by smtp.gmail.com with ESMTPSA id k29sm1436180qtc.87.2018.01.16.05.16.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jan 2018 05:16:34 -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=mb7fouWc0FLnnsuEugFP8UJFuum7NWf2tDpbqfEmBQA=; b=ZQJpE/AE5XUU5Awq8MbNWlmfvs9i/V+lnKJmc5hXSv20XUbXzx8tBmAAyS7vA3gz/L A6eU9JaUSE1FUWWSQxNdrBr2R4tBQDLH5i/hNf+iwxwLexx33J9i3OAQpQYFdvuTxSUs EPTuSIphbTPFtUPwqCRHp9hIXaWcfH3rhzEYo9Tnqk4KAwV/4r3PHYACel8+gvzxWNBx 5UJES02BNuDqB7kEKq0MKJ9F3Jfep93P1BfEEeEmbGvi5Va8uapx4vtvaxqjUTmKzIIg cR94EAHfb8xtmXNgFJeRHQomdXGYO6zALtNk2ng9+H769OsUwL/kuB09lYQqechyl+O0 rFJg== 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=mb7fouWc0FLnnsuEugFP8UJFuum7NWf2tDpbqfEmBQA=; b=A0/lzTNY2WjXx7O0I9b9t77tIuY33hNsQffIai4JCaq5uA7skGUJ09/QOWjTZ274Uk qsMyioiFg5dpR19GcfDBFabaPaw1BrY5zf4NwafavABiCzaa+fzhpeZWpFQZeyyOIUTZ UiPNcC1wDL2jdoWuJZzMw4rjV3N6aeNCP1LXRWUj1XBhEU81GIthnFxetua3uWYA2beO P1ftO0kdJIdHo9CrD+N+kAVQ79sCsu+j4kxLXxMgUq/4kjnwOO7QQKVIBjiusttpayuC 06tMdd3x991e1ZJtgiOFH5v5J9s45Jcn0TEV97SIaaLtQ8xFpB+vxjmbUpmy3Cn+P/mC aUaA== X-Gm-Message-State: AKwxytd9FiJOzT2DAeNZPKZBpzN2sicY+iBFEfKph8iuMzqGV8PW9GUo 6lo/xAEWKa0XFLojSdBW4AI= X-Google-Smtp-Source: ACJfBosVJ246LPxiOzeljtYHdG0rQZNHcWC2n5l1ebF32JL6AW0YIaZ5ClkWekEmB98dCv63NvH5Xg== X-Received: by 10.55.245.3 with SMTP id l3mr1794207qkk.145.1516108594875; Tue, 16 Jan 2018 05:16:34 -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:50 -0300 Message-Id: <20180116131555.14242-7-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:c09::243 Subject: [Qemu-devel] [PATCH 06/11] sysbus: add realize() and unrealize() 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 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/sysbus.h | 4 ++++ hw/core/sysbus.c | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h index e88bb6dae0..c87a6df29e 100644 --- a/include/hw/sysbus.h +++ b/include/hw/sysbus.h @@ -40,6 +40,10 @@ typedef struct SysBusDeviceClass { DeviceClass parent_class; /*< public >*/ =20 + void (*realize)(SysBusDevice *dev, Error **errp); + void (*unrealize)(SysBusDevice *dev, Error **errp); + + /* TODO remove, once users are converted to realize */ int (*init)(SysBusDevice *dev); =20 /* diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 5d0887f499..04d6061f76 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -200,6 +200,7 @@ void sysbus_init_ioports(SysBusDevice *dev, uint32_t io= port, uint32_t size) } } =20 +/* TODO remove, once users are converted to realize */ static int sysbus_device_init(DeviceState *dev) { SysBusDevice *sd =3D SYS_BUS_DEVICE(dev); @@ -211,6 +212,26 @@ static int sysbus_device_init(DeviceState *dev) return sbc->init(sd); } =20 +static void sysbus_realize(DeviceState *dev, Error **errp) +{ + SysBusDevice *sd =3D SYS_BUS_DEVICE(dev); + SysBusDeviceClass *sbc =3D SYS_BUS_DEVICE_GET_CLASS(sd); + + if (sbc->realize) { + sbc->realize(sd, errp); + } +} + +static void sysbus_unrealize(DeviceState *dev, Error **errp) +{ + SysBusDevice *sd =3D SYS_BUS_DEVICE(dev); + SysBusDeviceClass *sbc =3D SYS_BUS_DEVICE_GET_CLASS(sd); + + if (sbc->unrealize) { + sbc->unrealize(sd, errp); + } +} + DeviceState *sysbus_create_varargs(const char *name, hwaddr addr, ...) { @@ -325,6 +346,8 @@ 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; /* * device_add plugs devices into a suitable bus. For "real" buses, --=20 2.15.1