From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnTz9-0003q8-7R for qemu-devel@nongnu.org; Mon, 02 Dec 2013 08:56:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VnTz1-0007ut-UL for qemu-devel@nongnu.org; Mon, 02 Dec 2013 08:56:27 -0500 Received: from cantor2.suse.de ([195.135.220.15]:44513 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnTz1-0007uS-N4 for qemu-devel@nongnu.org; Mon, 02 Dec 2013 08:56:19 -0500 Message-ID: <529C917F.4030801@suse.de> Date: Mon, 02 Dec 2013 14:56:15 +0100 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <529C8656.4040406@suse.de> <529C8977.4030808@redhat.com> In-Reply-To: <529C8977.4030808@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH arm-devs v4 4/4] cpu/a9mpcore: Add Global Timer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: peter.maydell@linaro.org, Peter Crosthwaite , qemu-devel@nongnu.org, Anthony Liguori Am 02.12.2013 14:21, schrieb Paolo Bonzini: > Il 02/12/2013 14:08, Andreas F=C3=A4rber ha scritto: >>>> + object_initialize(&s->gtimer, sizeof(s->gtimer), TYPE_A9_GTIMER= ); >>>> + qdev_set_parent_bus(DEVICE(&s->gtimer), sysbus_get_default()); >>>> + >>>> object_initialize(&s->mptimer, sizeof(s->mptimer), TYPE_ARM_MPT= IMER); >>>> qdev_set_parent_bus(DEVICE(&s->mptimer), sysbus_get_default()); >>>> =20 >> This code resulted from inlining qdev_create() and switching to in-pla= ce >> instantiation. >> >> Seeing this repetitive code again and again makes me wonder whether we >> can just set a SysBusDevice's parent_bus in its instance_init function >> to simplify it? >=20 > Could we do it instead in the init function, only if parent_bus is stil= l > NULL? I'll interpret that as realize function. ;) Apart from assuming that no sysbus_*() or qdev_*() API depends on the bus being non-NULL, converted SysBusDevices have started to assume that SysBusDevice itself has no realize implementation. (At the time, we'd have needed to know what it does to determine when to call parent_*.) It would also make SysBusDevices differ from all others, which I find not so nice. Most devices will be instantiated with qdev_create(NULL, ...), so it may be feasible to just drop the NULL -> sysbus_get_default() conversion there and for device_add(), leaving only 14 occurrences to convert in qemu.git. :) Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3=BC= rnberg